Solana Interactions
Send Solana Legacy Transaction
The Basics
- Installing Dynamic
- Chains / Networks
- Authentication
- Wallets
- Set Up Embedded Wallets
- Set Up Branded Wallets
- Smart Wallets
- Using Wallets
- Accessing Wallets
- Interacting with wallets
- General Interactions
- EVM Interactions
- Bitcoin Interactions
- Solana Interactions
- Multi Wallet
- Multi Asset UI
- Send Assets
- Users / VC's
- Design
- Onramps
Beyond The Basics
- Headless
- Cross-ecosystem Connectivity
- Bridge Widget
- Rate Limits
Developer Dashboard
- SDK and API Keys
- Sandbox vs Live
- Analytics
- User Management
- Test Accounts
- Settings
- Admin
- Webhooks
- Configuring Social Providers
Tutorials
- Farcaster
- Telegram
- Features
- Frameworks
- Integrations
- Webhooks
Migrating to Dynamic
- Migrating to Dynamic
- Migration Tutorials
For Wallets & Chains
Hackathons
Solana Interactions
Send Solana Legacy Transaction
import { ISolana, isSolanaWalet } from '@dynamic-labs/solana-core';
import { Connection } from '@solana/web3.js';
const { primaryWallet } = useDynamicContext();
if(!isSolanaWalet(primaryWallet)) {
return;
}
const connection: Connection = await primaryWallet.getConnection();
const fromKey = new PublicKey(primaryWallet.address);
const toKey = new PublicKey(address);
const amountInLamports = Number(amount) * 1000000000;
const transferTransaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: fromKey,
lamports: amountInLamports,
toPubkey: toKey,
}),
);
const blockhash = await connection.getLatestBlockhash();
transferTransaction.recentBlockhash = blockhash.blockhash;
transferTransaction.feePayer = fromKey;
const signer: ISolana = await primaryWallet.getSigner();
await signer
.signAndSendTransaction(transferTransaction)
.then((res: any) => {
console.log(
`Transaction successful: https://solscan.io/tx/${res.signature}?cluster=devnet`,
);
})
.catch((reason: any) => {
console.error(reason);
});
Was this page helpful?