Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ton Network Blockchain transfer method is not working #2

Open
Shivam-Vatshayan opened this issue May 19, 2023 · 3 comments
Open

Ton Network Blockchain transfer method is not working #2

Shivam-Vatshayan opened this issue May 19, 2023 · 3 comments

Comments

@Shivam-Vatshayan
Copy link

Shivam-Vatshayan commented May 19, 2023

My Code :

const transfer = async () => {
    try {
        const WalletClass = tonweb.wallet.all['v4R2'];
        const wallet = new WalletClass(tonweb.provider, {
            publicKey: HOT_WALLET_ADDRESS,
            wc: 0
        });
        // const seqno = await wallet.methods.seqno().call() || 0;
        let string_private_key = JSON.parse(HOT_WALLET_PRIVATE_KEY)

        const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSecretKey(Buffer.from(string_private_key), "hex");
        let amountsToTransfer = TonWeb.utils.toNano('0.01');
        console.log(amountsToTransfer);
        // Create transfer
        const transfer = await wallet.methods.transfer({
            secretKey: keyPair.secretKey,
            toAddress: 'EQDQfus9g97M88HUtU8JHDPHk_YKGo8u7Zs6yrhOHbqXvImS',
            amount: amountsToTransfer, // 0.01 TON
            seqno: 0,
            payload: 'The aim of this text is to provide a brief',
        });
        // get estimate fee of transfer
        const transferFee = await transfer.estimateFee();
        console.log(transferFee);
        // send transfer query to blockchain
        const transferSended = await transfer.send();
        console.log(transferSended);

        const query = await transfer.getQuery();
        console.log(query);

        // const boc = TonWeb.utils.bytesToBase64(await query.toBoc(false)); // serialized query
        // // await tonweb.provider.sendBoc(boc); // send query to network

        // // Parse query

        // try {
        //     const parsed = WalletClass.parseTransferQuery(TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(boc)));

        //     parsed.value = parsed.value.toString();
        //     parsed.fromAddress = parsed.fromAddress.toString(true, true, true);
        //     parsed.toAddress = parsed.toAddress.toString(true, true, true);
        //     console.log(parsed);
        // } catch (e) {
        //     console.error(e); // not valid wallet transfer query
        // }
    } catch (error) {
        console.log('catch error => ', error)
    }
}
transfer();

Getting Issue after running ton transfer method is :

BN { negative: 0, words: [ 10000000 ], length: 1, red: null }
catch error => Error: Invalid character
at assert (/home/charvik/codes/tests/ton/node_modules/bn.js/lib/bn.js:6:21)
at parseBase (/home/charvik/codes/tests/ton/node_modules/bn.js/lib/bn.js:269:7)
at BN._parseBase (/home/charvik/codes/tests/ton/node_modules/bn.js/lib/bn.js:305:14)
at BN.init [as _init] (/home/charvik/codes/tests/ton/node_modules/bn.js/lib/bn.js:99:12)
at new BN (/home/charvik/codes/tests/ton/node_modules/bn.js/lib/bn.js:39:12)
at BitString.writeUint (/home/charvik/codes/tests/ton/node_modules/tonweb/src/boc/BitString.js:118:18)
at BitString.writeUint8 (/home/charvik/codes/tests/ton/node_modules/tonweb/src/boc/BitString.js:167:14)
at BitString.writeBytes (/home/charvik/codes/tests/ton/node_modules/tonweb/src/boc/BitString.js:176:18)
at WalletV4ContractR2.createDataCell (/home/charvik/codes/tests/ton/node_modules/tonweb/src/contract/wallet/WalletContractV4R2.js:66:19)
at WalletV4ContractR2.createStateInit (/home/charvik/codes/tests/ton/node_modules/tonweb/src/contract/index.js:51:31)

@seshorenkinjutsushi
Copy link

UQA0pnYTNKx6u2XJIEOy31yzmmvDMxMnNPXaedQPXr3XfPIP

@kraken7984
Copy link

****https://github.com/toncenter/examples/issues/2#issue-1717091775[](url)parsed.value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Shivam-Vatshayan @kraken7984 @seshorenkinjutsushi and others