Closed kaharkaboodi closed 3 months ago
const address= new TonWeb.utils.Address('0QD_Hmu0HuudO-_lADdXIxQMLL-5YN1TV7C_B58NIX3lwvq3'); console.log(address.toString(true, true, true)); yourAddress = address.toString(false); //eg. 0:ca6e321c7cce9ecedf0a8ca2492ec8592494aa5fb5ce0387dff96ef6af982a3e you have to put this address format in responseAddress, toAddress
Tell me also if you succeed , I am trying to transfer jettons but no response with no error
Tell me also if you succeed , I am trying to transfer jettons but no response with no error
import TonWeb from "tonweb";
const nacl = TonWeb.utils.nacl;
const {JettonMinter, JettonWallet,} = TonWeb.token.jetton;
import tonMnemonic from "tonweb-mnemonic";
const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC', {apiKey: ''}));
const WalletClass = tonweb.wallet.all['v4R2'];
const mnemonic = '';
const keyPair = await tonMnemonic.mnemonicToKeyPair(mnemonic.split(' '));
console.log(keyPair);
const wallet = new WalletClass(tonweb.provider, {
publicKey: keyPair.publicKey,
wc: 0
});
// const JETTON_WALLET_ADDRESS = 'kQAudtrAfza8zD282wpJF9lLoZnp_GARkHGvmoMDK8f5xCfk';
const JETTON_WALLET_ADDRESS = 'kQAudtrAfza8zD282wpJF9lLoZnp_GARkHGvmoMDK8f5xCfk';
const walletAddress = await wallet.getAddress();
const jettonWallet = new JettonWallet(tonweb.provider, {
address: JETTON_WALLET_ADDRESS
});
console.log(keyPair.secretKey);
const transfer = async () => {
const seqno = (await wallet.methods.seqno().call()) || 0;
console.log({seqno})
const comment = new Uint8Array([... new Uint8Array(4), ... new TextEncoder().encode('text comment')]);
const transfer = wallet.methods.transfer({
secretKey: keyPair.secretKey,
toAddress: 'kQDPUPoPTsdyNqC19iHTfFBayH_Na6Fc0IwSGxDgkGALCZex',
amount: TonWeb.utils.toNano('0.1'), // 0.1 TON
seqno: seqno,
// payload: 'Hello',
payload: await jettonWallet.createTransferBody({
jettonAmount: TonWeb.utils.toNano('50000'), // Jetton amount (in basic indivisible units)
toAddress: new TonWeb.utils.Address('0QD_Hmu0HuudO-_lADdXIxQMLL-5YN1TV7C_B58NIX3lwvq3'), // recepient user's wallet address (not Jetton wallet)
forwardAmount: TonWeb.utils.toNano('0.01'), // some amount of TONs to invoke Transfer notification message
forwardPayload: comment, // text comment for Transfer notification message
responseAddress: walletAddress // return the TONs after deducting commissions back to the sender's wallet address
}),
sendMode: 3,
}).send();
}
transfer();
Solved
i wrote my all code
i just changed apikey and secretkey here this is my jetton info