sdk.solana and sdk.ethereum) for optimal transaction handling.
Transaction security for embedded wallets: All transactions signed for embedded wallets pass through Phantom’s advanced simulation system before execution. This security layer automatically blocks malicious transactions and transactions from origins that have been reported as malicious, providing an additional layer of protection for your users’ assets.
Chain-specific transaction methods
Solana transactions (sdk.solana)
Ethereum transactions (sdk.ethereum)
Dapp-sponsored transactions
Pass apresignTransaction callback to signAndSendTransaction for Solana transactions that need double signing, such as dapp fee payer flows. Calls without it proceed normally — it is never applied globally.
presignTransaction only fires for Solana transactions via the embedded provider. EVM transactions and injected providers are unaffected.Transaction format
Thetransaction string passed to the callback is base64url-encoded (URL-safe base64 without = padding, using - and _ instead of + and /). The SDK exports base64urlDecode and base64urlEncode utilities:
Example: dapp fee payer
Transaction examples
Solana transaction examples
The SDK supports multiple Solana transaction libraries. Here are examples using both@solana/web3.js and @solana/kit:
Solana with @solana/web3.js
Solana with @solana/kit
Dapp-sponsored transactions
By default, the user’s embedded wallet is the fee payer for all Solana transactions. ThepresignTransaction hook lets your app co-sign the transaction before the wallet signs it, enabling use cases like:
- Dapp-as-fee-payer — your app covers the transaction fee so users don’t need SOL
- Platform fees — add a fee instruction signed by your app’s keypair
- Multi-signer flows — any scenario where the app needs to sign alongside the user’s wallet
presignTransaction directly to signAndSendTransaction for the specific calls that need it. Calls without it proceed normally — the function is never applied globally.
Example: app as fee payer
The hook only fires for Solana transactions via the embedded provider. EVM transactions and injected providers are unaffected.