X
Docs
SDK Reference
buildDAG()

buildDAG(intents)

Use buildTransaction to combine multiple intents into a single v0. If you overflow maxMessageSize (default 1232), split across messages.

import { buildTransaction, BasicPolicy, transferIntent, memoIntent } from '@rlock/cpsr-sdk';
import { Connection, Keypair } from '@solana/web3.js';

const connection = new Connection('https://api.devnet.solana.com');
const payer = Keypair.generate();

const intents = [
  transferIntent({ from: payer.publicKey, to: Keypair.generate().publicKey, lamports: 50_000 }),
  memoIntent({ payer: payer.publicKey, message: 'hello' }),
];

const plan = await new BasicPolicy().suggest();
const { blockhash } = await connection.getLatestBlockhash('confirmed');

const tx = await buildTransaction({
  intents,
  feePlan: plan,
  recentBlockhash: blockhash,
  payer: payer.publicKey,
});

For overflow handling, see Concepts → DAG & Dependencies (binary-search chunker).

Edit on GitHub