In this step you send 100 EXF, the asset from step 3, to a new holder. It’s the
same instruction as sending dollars in step 2, for a different mint.
Send the asset
Save this assend-asset.ts next to client.ts and run
npx tsx send-asset.ts. It reads the asset’s address from asset.json (the
CLI tab uses exf.json).
TypeScript
Output of npx tsx send-asset.tsLocal test network (Surfpool)
npx tsx send-asset.ts
Sent 100 EXF to GtU8gbvgsAfARGxXTDnCaQPPRg2KHcVxiRF8ZxmLSstk
Signature: 27EnUyCoCpAxDBtdz8uD9YKCLwuy7Ps3RUNvN8FcgFB3LsE9ZbKpiPyqp4QSSGCwFBZBSvVfmmiWr8YoeVquCibK
Explorer:
https://explorer.solana.com/tx/27EnUyCoCpAxDBtdz8uD9YKCLwuy7Ps3RUNvN8FcgFB3LsE9ZbKpiPyqp4QSSGCwFBZBSvVfmmiWr8YoeVquCibK?cluster=devnetHolder balance: 100 EXF
Confirmed
generateKeyPairSigner(true)creates the holder: a second wallet.writeKeyPairSignersaves it inholder.json, so step 5 can sign for it. In a real app, each holder keeps their own key.client.token2022.instructions.transferToATA(...)builds two instructions:- Open the holder’s EXF token account, which they don’t have yet. Your wallet pays its small deposit.
- Move 100 EXF: 10,000 base units, because EXF has 2 decimals. Like the
USDC transfer, it’s a
TransferCheckedinstruction.
.sendTransaction()sends both in one transaction, paid and signed by your wallet, and waits until it’s confirmed.
Holder balance: 100 EXF. You now hold 900.