Skip to main content

Code Examples

Let's start with a minimal example for transferring CKB:

const tx = ccc.Transaction.from({
outputs: [{ lock: toLock, capacity: ccc.fixedPointFrom(amount) }],
});

Define the essential outputs of the transaction, and then...

await tx.completeInputsByCapacity(signer);
await tx.completeFeeBy(signer); // Transaction fee rate is calculated automatically
const txHash = await signer.sendTransaction(tx);

That's it! The transaction is sent.

Click here to read the full example of transferring native CKB token.