// Create a Solana account
const account = await cdp.solana.createAccount();
// Build your transaction using @solana/kit
import {
address as solanaAddress,
appendTransactionMessageInstructions,
compileTransaction,
createNoopSigner,
createSolanaRpc,
createTransactionMessage,
getBase64EncodedWireTransaction,
pipe,
setTransactionMessageFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
} from "@solana/kit";
import { getTransferSolInstruction } from "@solana-program/system";
const rpc = createSolanaRpc("https://api.devnet.solana.com");
const { value: { blockhash, lastValidBlockHeight } } = await rpc.getLatestBlockhash().send();
const txMsg = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(solanaAddress(account.address), tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(
{ blockhash, lastValidBlockHeight },
tx,
),
(tx) => appendTransactionMessageInstructions([
getTransferSolInstruction({
source: createNoopSigner(solanaAddress(account.address)),
destination: solanaAddress("3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE"),
amount: 10000n,
}),
], tx),
);
// Base64 encode the compiled transaction
const transaction = getBase64EncodedWireTransaction(compileTransaction(txMsg));
// Send the transaction via the CDP API
const { transactionSignature } = await account.sendTransaction({
transaction,
});