Generate Solana Address
Derive a deterministic Solana address from an MPC key share. Solana uses Ed25519 keys — the address is the base58-encoded raw public key.
Components used:
GET_SOLANA_DERIVATION_PATH— produce a BIP-44 path (m/44'/501'/account'/change')COMPUTE_PUBLIC_KEY— derive the Ed25519 public key from the key share at that pathCOMPUTE_SOLANA_ADDRESS— convert the public key to a base58 Solana address
Code
import { WorkspaceClient, ComponentModule } from 'caller-sdk';
const workspace = new WorkspaceClient({ apiKey: process.env.WR_API_KEY! });
async function generateSolanaAddress(keyId: string, accountIndex: number): Promise<string> {
// 1. Build BIP-44 derivation path for the given account
// Phantom/Solflare style: m/44'/501'/accountIndex'/0'
const { derivationPath } = await workspace
.call(ComponentModule.GET_SOLANA_DERIVATION_PATH, {
accountIndex,
changeIndex: 0,
addressIndex: null, // 4-level path (Phantom/Solflare style)
})
.promise();
// 2. Derive the Ed25519 public key from the MPC key share
const { publicKey } = await workspace
.call(ComponentModule.COMPUTE_PUBLIC_KEY, { keyId, derivationPath })
.promise();
// 3. Convert the public key to a Solana address (base58)
const { address } = await workspace
.call(ComponentModule.COMPUTE_SOLANA_ADDRESS, { publicKey })
.promise();
return address;
}
// Example: derive first Solana account address
const address = await generateSolanaAddress('your-key-id', 0);
console.log('Solana address:', address); // base58 string
Derivation path styles
| Style | Inputs | Path |
|---|---|---|
| Phantom / Solflare (4-level) | accountIndex: 0, changeIndex: 0, addressIndex: null | m/44'/501'/0'/0' |
| Ledger / CLI (5-level) | accountIndex: 0, changeIndex: 0, addressIndex: 0 | m/44'/501'/0'/0'/0' |
Use the 4-level path for compatibility with Phantom and Solflare wallets.
In a workflow
[Trigger: accountIndex]
│
▼
GET_SOLANA_DERIVATION_PATH
│ derivationPath
▼
COMPUTE_PUBLIC_KEY ← keyId (constant)
│ publicKey
▼
COMPUTE_SOLANA_ADDRESS
│ address
▼
[Output]