The Basics
- Add Login / Signup
- Chains / Networks
- Wallets
- Users / VC's
- Design
- Onramps
Beyond The Basics
- Headless
- Global Wallets
- 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
Legacy: V1 Embedded Wallets
- V1 Embedded Wallets Overview
- Working with environments that have both v1 and v2 embedded wallets
- Transactional MFA
- Headless
Typed Solana signer
Here are some examples on how to use the Solana typed signer
Example for Solana embedded Wallet
import { IEmbeddedWalletSolanaSigner, isSignedMessage } from '@dynamic-labs/solana';
const App = () => {
const { primaryWallet } = useDynamicContext();
const signMessage = async () => {
if (!primaryWallet) return;
const signer = await primaryWallet.connector.getSigner<IEmbeddedWalletSolanaSigner>();
if (!signer) return;
const signedMessage = await signer.signMessage(
new TextEncoder().encode('example'),
);
if (!signedMessage) return;
const signature: Uint8Array = isSignedMessage(signedMessage)
? signedMessage.signature
: signedMessage;
}
...
}
Example for any external Solana wallet and Backpack wallet
import { ISolana, isSignedMessage } from '@dynamic-labs/solana';
const App = () => {
const { primaryWallet } = useDynamicContext();
const signMessage = async () => {
if (!primaryWallet) return;
const signer = await primaryWallet.connector.getSigner<ISolana>();
if (!signer) return;
const signedMessage = await signer.signMessage(
new TextEncoder().encode('example'),
);
if (!signedMessage) return;
const signature: Uint8Array = isSignedMessage(signedMessage)
? signedMessage.signature
: signedMessage;
}
...
}
Example for Solana common wallets
import { ISolanaSigner } from '@dynamic-labs/solana';
const App = () => {
const { primaryWallet } = useDynamicContext();
const signMessage = async () => {
if (!primaryWallet) return;
const signer = await primaryWallet.connector.getSigner<ISolanaSigner>();
if (!signer) return;
const signedMessage = await signer.signMessage(
new TextEncoder().encode('example'),
);
if (!signedMessage) return;
const signature: Uint8Array = signedMessage.signature
}
...
}
Example for Backpack wallet only
import { IBackpackSolanaSigner } from '@dynamic-labs/solana';
const App = () => {
const { primaryWallet } = useDynamicContext();
const signMessage = async () => {
if (!primaryWallet) return;
const signer = await primaryWallet.connector.getSigner<IBackpackSolanaSigner>();
if (!signer) return;
const signature: Uint8Array | void = await signer.signMessage(
new TextEncoder().encode('example'),
);
}
...
}
Example using isBackpackSolanaSigner type guard function
import { ISolana, isBackpackSolanaSigner } from '@dynamic-labs/solana';
const App = () => {
const { primaryWallet } = useDynamicContext();
const signMessage = async () => {
if (!primaryWallet) return;
const signer = await primaryWallet.connector.getSigner();
if (isBackpackSolanaSigner(signer)) {
const signature: Uint8Array | void = await signer.signMessage(
new TextEncoder().encode('example'),
);
}
}
...
}
Was this page helpful?