Execute smart contract calls on EVM chains using Solana assets as funding source
Execute smart contract calls on EVM chains using Solana assets as the funding source. These examples use the V3 calldata endpoints that support cross-chain contract execution.
For complete signing documentation covering all account types (EVM, Solana, EIP-7702), see the Signing Guide with detailed explanations and troubleshooting.
Copy
Ask AI
import { MessageV0, VersionedTransaction, PublicKey } from '@solana/web3.js';import bs58 from 'bs58';/** * Signs a Solana chain operation with a private key * @param accountAddress - The address of the account to sign the chain operation * @param privateKey - The private key in base58 format * @param chainOp - The chain operation object from quote response * @returns The signed chain operation with signature added */export function signSolanaChainOperation( accountAddress: string, privateKey: string, chainOp: any,): any { const msgBuffer = Buffer.from(chainOp.dataToSign, 'base64'); const message = MessageV0.deserialize(msgBuffer); const transaction = new VersionedTransaction(message); const decodedKey = bs58.decode(privateKey); transaction.sign([ { publicKey: new PublicKey(accountAddress), secretKey: Buffer.from(decodedKey), }, ]); const signature = bs58.encode(Buffer.from(transaction.signatures[transaction.signatures.length - 1])); return { ...chainOp, signature, };}
OneBalance supports EIP-7702 delegated accounts that can be funded using Solana assets. This enables seamless cross-chain contract execution where Solana provides the funding and EIP-7702 provides the execution context.
EIP-7702 accounts require delegation signatures before execution:
Delegation Required: When using deploymentType: "EIP7702", you must sign the delegation object from the prepare-call-quote response before proceeding to call-quote.
1
Get Delegation Object
The prepare-call-quote response includes delegation data that must be signed:
Copy
Ask AI
const prepareResponse = await prepareCallQuote(multiAccountRequest);// EIP-7702 delegation object is included in responseconst delegationObject = prepareResponse.delegation;console.log('Delegation to sign:', delegationObject);
2
Sign Delegation
Sign the delegation using your EIP-7702 signer:
Copy
Ask AI
// Sign the delegation object with your EIP-7702 signerconst delegationSignature = await evmSigner.signTypedData(delegationObject);// Include the signature in your call-quote requestconst callQuoteRequest = { ...prepareResponse, delegationSignature: delegationSignature};
3
Execute Operation
The signed delegation enables atomic execution:
Copy
Ask AI
// The operation will:// 1. Process delegation signature// 2. Use Solana assets for funding// 3. Execute contract calls via delegated account// 4. All in a single atomic transactionconst result = await executeQuote(signedQuote);
// Verify target chain supports the contractconst supportedChains = ['eip155:1', 'eip155:42161', 'eip155:137'];if (!supportedChains.includes(targetChain)) { throw new Error(`Contract not available on chain: ${targetChain}`);}
For questions about Solana contract calls or integration support, use the Intercom chat widget in the bottom right corner, join our Discord, or reach out via support.