Hi, anyone knows how i can send a BOC in sendTransfer using ton.js. The code below i added BOC but it doesn't go through.


let workchain = 0;
let wallet = WalletContractV4.create({ workchain, publicKey: keyPair.publicKey });

let contract = client.open(wallet);
let seqno = await contract.getSeqno();
const recipient = new TonWeb.utils.Address('0QCgEXBLDbipzYC7fYvIG3W1yq-pa0IHUFV5mt631gyC1AOP');
const nft = new TonWeb.utils.Address('0QAEvMjv7B6JOOwskLMUUmhMoGd0jH48RWTCZUa1Ubmcson-');
const owner = new TonWeb.utils.Address(contract.address.toString());

const cell = new TonWeb.boc.Cell();
cell.bits.writeUint(0x5fcc3d14, 32); // Transfer operation
cell.bits.writeUint(0, 64);
cell.bits.writeAddress(recipient);
cell.bits.writeAddress(owner);
cell.bits.writeBit(false); // Null custom_payload
cell.bits.writeCoins(TonWeb.utils.toNano('0.02')); // Adjust the value as needed
cell.bits.writeBit(false); // Forward_payload in this slice, not a separate cell

const payload = TonWeb.utils.bytesToBase64(await cell.toBoc());

const tx = await contract.sendTransfer({
secretKey: keyPair.secretKey,
seqno: seqno,
messages: [
internal({
to: "0QAEvMjv7B6JOOwskLMUUmhMoGd0jH48RWTCZUa1Ubmcson-",
value: "0.001", // 0.05 TON
body: "Hello", // optional comment
bounce: false,
payload: payload
})
]
});

Jan 12, 2024, 10:05 AM

© 2024 Draquery.com All rights reserved.