Solana
This page guides to create and use Solana Wallet instance in multichain-wallet-sdk.
Import Solana Wallet
Reference
Create wallet SDK instance
class SolanaWallet(rpcUrl: string)
Pass RPC endpoint and create new wallet SDK instance. RPC endpoints Mainnet: https://api.mainnet-beta.solana.com Testnet: https://api.testnet.solana.com Devnet: https://api.devnet.solana.com
Initialize SDK instance
solanaWallet.initialize(privateKey?: string) => Promise<void>
Initialize SDK and create primary wallet with give private key or random generated one.
Create new wallet
solanaWallet.createWallet(derivedPath?: string) => Promise<Wallet>
Create random wallet (address, privateKey, mnemonic, nonce) and returns it as Wallet object.
Without passing derivedPath
argument, default solana HD wallet will be generated.
Recover wallet
solanaWawllet.recoverWallet(mnemonic: string, derivedPath?: string) => Promise<Wallet>
Recover wallet from mnemonic and derived path arguments and returns it as Wallet object. Without passing derivedPath
argument, SDK will generate standard solana HD wallet.
Get key pair from private key
solanaWallet.getKeyPairFromPrivateKey(privateKey: string) => KeyPair
Create key pair of private key <=> public key from private key.
Create account
solanaWallet.createAccount(derivedPath?: string) => Promise<Wallet>
Create random account from based on derived path or solana default path returns Wallet object.
Recover account
solanaWallet.importAccount(privateKey: string) => Promise<Wallet>
Recover account from private key string and returns Wallet object.
Get SOL balance
solanaWallet.getBalance(address: string, tokenAddress?: string) => Promise<number>
Get native coin or SPL token balance of account or given address.
Get token detail
solanaWallet.getTokenInfo(cluster: 'mainnet-beta' | 'testnet' | 'devnet', address: string) => Promise<ITokenInfo | null>
Get detail info of SPL token ITokenInfo object or null(If inputted address is not token address).
Send payment transaction
solanaWallet.sendSol(recipient: string, amount: number, privateKey?: string) => Promise<TransactionResponse | null>
Send native currency by create, sign, and broadcast payment transaction and returns executed transaction response object.
Transfer token
solanaWallet.transferToken(tokenAddress: string, recipient: string, amount: number, privateKey?: string) => Promise<TransactionResponse | null>
Transfer given amount of SPL token to recipient and returns executed transaction response object.
Get provider
solanaWallet.getProvider(rpcUrl: string) => Connection
Get solana provider (Connection) from RPC url.
Get transaction
solanaWallet.getTransaction(hash: string) => Promise<TransactionResponse | null>
Get transaction object from tx hash.
Get token list
solanaWallet.getTokenList(cluster: 'mainnet-beta' | 'testnet' | 'devnet') => Promise<Array<ISplTokenInfo>>
Get existing SPL token list of selected network.
Last updated