First, we need to prepare the transaction that will send 0.001 SOL.
For the transaction parameters:
Use "11111111111111111111111111111111" as the blockhash (Crossmint will replace this)
Use "11111111111111111111111111111112" as the payerKey (Crossmint will replace this)
Do not include the sending wallet in the signers array
Do not sign the transaction (Crossmint will handle signing)
The transaction will be properly configured on Crossmint’s servers with the correct values before execution. Crossmint will also pay for the transaction fee.
Copy
import { PublicKey, TransactionMessage, VersionedTransaction, SystemProgram } from "@solana/web3.js";import base58 from "bs58";// Addressesconst fromPublicKey = new PublicKey("your_wallet_address");const toPublicKey = new PublicKey("recipient_address");const amount = 10000000; // Amount in lamports (1 SOL = 1,000,000,000 lamports)// Create a transactionconst message = new TransactionMessage({ instructions: [ SystemProgram.transfer({ fromPubkey: fromPublicKey, toPubkey: toPublicKey, lamports: amount, }), ], recentBlockhash: "11111111111111111111111111111111", payerKey: new PublicKey("11111111111111111111111111111112"),}).compileToV0Message();const transaction = new VersionedTransaction(message);const serializedTransactionStr = base58.encode(transaction.serialize());console.log("Base58 Encoded Transaction:", serializedTransactionStr);
2
Send the transaction to the /transactions endpoint. We only need to send the transaction field with the base58 encoded transaction generated in the previous step.