This script demonstrates a simple flow:
- Investor approves a delegate (third party) to spend tokens from their token account.
- Third party performs a transfer using the transfer hook instruction.
Setup
- Copy
.env.exampleto.envand fill the values (mint address, program ids, RPC_URL, token account addresses or leave blank to derive associated addresses). - Place JSON keypair files in the same directory:
investor-keypair.jsonandthird-party-keypair.json(each file contains the secret key array produced byKeypair.toSecretKey()/fs.writeFileSync(..., JSON.stringify([...secretKey]))). - Install dependencies:
npm installRun
npm startNotes
- This script assumes holder/group/holdergroup/security-associated accounts and transfer rule exist on-chain for the token. It only performs approve + delegated transfer.
- Replace placeholder key files with real secret key arrays. Do not commit real secrets to source control.