Open Ramhubi opened 5 months ago
"import TonWeb from 'tonweb'; import tonwebMnemonic from 'tonweb-mnemonic';
const apiKey = "" || undefined; // WALLET B const mnemonic = "..."; const walletVersion = "v4R2"; // WALLET A const toAddress = "...";
const SendMode = { CARRY_ALL_REMAINING_BALANCE: 128, CARRY_ALL_REMAINING_INCOMING_VALUE: 64, DESTROY_ACCOUNT_IF_ZERO: 32, PAY_GAS_SEPARATELY: 1, IGNORE_ERRORS: 2, NONE: 0 }
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
(async () => { const provider = new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey});
const WalletClass = TonWeb.Wallets.all[walletVersion]; const mnemonicArray = mnemonic.split(" "); let { publicKey, secretKey } = await tonwebMnemonic.mnemonicToKeyPair(mnemonicArray); publicKey = Buffer.from(publicKey); secretKey = Buffer.from(secretKey); console.log(`PUBLIC KEY: ${publicKey.toString('hex')}`); const wallet = new WalletClass(provider, { publicKey }); const seqno = await wallet.methods.seqno().call() || 0; console.log(`SEQNO: ${seqno}`); await sleep(2000); const transferParams = { secretKey, toAddress, amount: 0, seqno, sendMode: SendMode.CARRY_ALL_REMAINING_BALANCE | SendMode.IGNORE_ERRORS | SendMode.DESTROY_ACCOUNT_IF_ZERO, payload: "test bug" }; console.log(JSON.stringify({...transferParams, secretKey: transferParams.secretKey.toString('hex')}, null, 2)); const response = await wallet.methods.transfer(transferParams).send(); console.log(`transfer sent to blockchain: ${JSON.stringify(response, null, 2)}`);
})();" https://stackoverflow.com/questions/78094237/ton-transfer-bug-when-using-32-destroy-account-if-zero-flag#:~:text=causes%20this%20behavior%3A-,import,-TonWeb%20from%20%27tonweb
"import TonWeb from 'tonweb'; import tonwebMnemonic from 'tonweb-mnemonic';
const apiKey = "" || undefined; // WALLET B const mnemonic = "..."; const walletVersion = "v4R2"; // WALLET A const toAddress = "...";
const SendMode = { CARRY_ALL_REMAINING_BALANCE: 128, CARRY_ALL_REMAINING_INCOMING_VALUE: 64, DESTROY_ACCOUNT_IF_ZERO: 32, PAY_GAS_SEPARATELY: 1, IGNORE_ERRORS: 2, NONE: 0 }
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
(async () => { const provider = new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey});
})();" https://stackoverflow.com/questions/78094237/ton-transfer-bug-when-using-32-destroy-account-if-zero-flag#:~:text=causes%20this%20behavior%3A-,import,-TonWeb%20from%20%27tonweb