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)
May 19, 2023, 12:33 PM
Ton Network Blockchain transfer method is not working #2
https://github.com/toncenter/examples/issues/2
Hello Team please help
May 19, 2023, 12:33 PM
publicKey: HOT_WALLET_ADDRESS,
wc: 0
});
i don't have laptop to run the code now , but looking at this code i can see that publicKey is not the HOT_WALLET_ADDRESS is not a public Key. Don't know if there is anything else worng in code or no.
I send you a working example why you are not using it ?
wc: 0
});
i don't have laptop to run the code now , but looking at this code i can see that publicKey is not the HOT_WALLET_ADDRESS is not a public Key. Don't know if there is anything else worng in code or no.
I send you a working example why you are not using it ?
Use mnemonic string to generate a keypair, instead of keeping hex private key.
May 19, 2023, 1:07 PM
written new code for this
but again same errors
const words = await tonMnemonic.generateMnemonic();
const seed = await tonMnemonic.mnemonicToSeed(words);
const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed);
const WalletClass = tonweb.wallet.all["v4R2"];
const wallet = new WalletClass(tonweb.provider, { publicKey: keyPair.publicKey });
const seqno = await wallet.methods.seqno().call() 0;
const to = "EQDQfus9g97M88HUtU8JHDPHk_YKGo8u7Zs6yrhOHbqXvImS";
await wallet.methods.transfer({
secretKey: keyPair.secretKey,
toAddress: to,
amount: TonWeb.utils.toNano('0.01'), //string amount in nanos
seqno: seqno,
payload: "message",
sendMode: 3,
}).send();
let currentSeqno = seqno;
while (currentSeqno == seqno) {
//checks if transaction is finalized
await sleep(500);
currentSeqno = await wallet.methods.seqno().call() 0;
}
but again same errors
const words = await tonMnemonic.generateMnemonic();
const seed = await tonMnemonic.mnemonicToSeed(words);
const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed);
const WalletClass = tonweb.wallet.all["v4R2"];
const wallet = new WalletClass(tonweb.provider, { publicKey: keyPair.publicKey });
const seqno = await wallet.methods.seqno().call() 0;
const to = "EQDQfus9g97M88HUtU8JHDPHk_YKGo8u7Zs6yrhOHbqXvImS";
await wallet.methods.transfer({
secretKey: keyPair.secretKey,
toAddress: to,
amount: TonWeb.utils.toNano('0.01'), //string amount in nanos
seqno: seqno,
payload: "message",
sendMode: 3,
}).send();
let currentSeqno = seqno;
while (currentSeqno == seqno) {
//checks if transaction is finalized
await sleep(500);
currentSeqno = await wallet.methods.seqno().call() 0;
}
All other methods are working but transfer is not working
May 19, 2023, 1:22 PM
now you are generating a new address; and want to send ton coin from it. It has no contract deployed and it has no ton coin on it. so method MUST give an error.
let me send full example with comments
May 19, 2023, 1:38 PM
ya please
we want to integrate ton thats why need ton deposit as transfer method working
its important
May 19, 2023, 1:38 PM
https://gist.github.com/sench93/09b127901e4bdd455f08886d7b46b4d1
of course error handling is not included in this gist, because various logical and node error can happen which you have to handle yourself.
May 19, 2023, 2:02 PM
Hi This is not working
Can you please provide this code in js
Can you please provide this code in js
https://github.com/toncenter/examples/issues/2
we are getting errors as :
BN { negative: 0, words: [ 10000000 ], length: 1, red: null }
BN { negative: 0, words: [ 10000000 ], length: 1, red: null }
Please check
May 22, 2023, 11:24 AM
Do you provide this 3 constants ?
const MNEMONIC_OF_EXISTING_WALLET = ""
const DESTINATION_ADDRESS = ""
const API_KEY = "";
const MNEMONIC_OF_EXISTING_WALLET = ""
const DESTINATION_ADDRESS = ""
const API_KEY = "";
May 22, 2023, 11:30 AM
Do you actually need to pass tonweb.provider into new WalletClass? As far as I remember, it's provided automatically.
May 22, 2023, 11:31 AM
The gist i provided is TypeScript and it works as it should, i ran with my own mnemonic and it works. Moreover this code with error handling works on live product i own. So kinldy check what are you doing wrong.
May 22, 2023, 11:32 AM
const key = await mnemonicToKeyPair(mnemonic.split(" "));
This is not working !!
Even after declaring mnemonic too its not working
This is not working !!
Even after declaring mnemonic too its not working
please check once in js
const mnemonicPhrase = mnemonicArray.join(' ');
^
TypeError: mnemonicArray.join is not a function
^
TypeError: mnemonicArray.join is not a function
Getting error from this Code
Please check once
waiting for replyt
?
We need to integrate ton coin asap
All methods and functions are working only transfer is not working
Please check and guide
All methods and functions are working only transfer is not working
Please check and guide
May 23, 2023, 9:53 AM
this is the basics of JS. mnemonicsArray must be an Array
May 23, 2023, 9:55 AM
besides, where do you find mnemonicArray in the gist i provided ? @Vatshayan1
May 23, 2023, 9:58 AM
exactly
May 23, 2023, 9:58 AM
/ton/node_modules/tonweb-mnemonic/dist/node/index.js:99
const mnemonicPhrase = mnemonicArray.join(' ');
^
TypeError: mnemonicArray.join is not a function
const mnemonicPhrase = mnemonicArray.join(' ');
^
TypeError: mnemonicArray.join is not a function
this we are getting from node modules
May 23, 2023, 10:40 AM
Then give from which line of code error happens from the gist.
or at least paste whole stack trace
May 23, 2023, 12:07 PM
Hi Now I have
Created wallet
Deploy wallet
and then trying sendTon
but I am getting errors
Created wallet
Deploy wallet
and then trying sendTon
but I am getting errors
'LITE_SERVER_UNKNOWN: cannot apply external message to current state : External message was not accepted\nCannot run message on account: inbound external message rejected by transaction 5A7F0851CB1FC0F48916319B53B709D37FF724ED399B453DE9E7AC574D517A4C:\nexitcode=33, steps=23, gas_used=0\nVM Log (truncated):\n...te NOW\nexecute LEQ\nexecute THROWIF 36\nexecute PUSH c4\nexecute CTOS\nexecute LDU 32\nexecute LDU 32\nexecute LDU 256\nexecute LDDICT\nexecute ENDS\nexecute XCPU s4,s3\nexecute EQUAL\nexecute THROWIFNOT 33\ndefault exception handler, terminating vm with exit code 33\n'
I am using testnet api rpc and testnet ton faucat for the address
for testing as of now
May 23, 2023, 12:54 PM
It seems that seqno is wrong.
May 23, 2023, 12:56 PM
can you share the account from which you are trying to send TON ?
as it's testnet sharing mnemonic will be good too if test coins on it are not much .
May 23, 2023, 12:59 PM
Actually, that won't help, as failed external messages are not recorded as transactions.
May 23, 2023, 12:59 PM
I want to check at least if deployemnt and funding are really done
May 23, 2023, 1:00 PM
EQBafwhRyx_A9IkWMZtTtwnTf_ck7TmbRT3p56xXTVF6TMGg
I have checked on testnet ton scan
There is 2 ton on it as of now
There is 2 ton on it as of now
EQBafwhRyx_A9IkWMZtTtwnTf_ck7TmbRT3p56xXTVF6TMGg
I have checked on testnet ton scan
There is 2 ton on it as of now
There is 2 ton on it as of now
May 24, 2023, 10:58 AM
tell me your mainnet addres i will send you 1 ton. do your testings on mainnet. I don't count testnet reliable to work on ! And don't have time to check testnet results. I can donate you 1 ton , which is more than enough for testing purposes.
May 24, 2023, 11:04 AM
Getting Method not found error
Trying Mainnet API and ton coin for deposit but now getting in catch error as
"Method not found"
I think getBalance method is not fetching
Trying Mainnet API and ton coin for deposit but now getting in catch error as
"Method not found"
I think getBalance method is not fetching
May 26, 2023, 1:16 PM
It works for me at TonWeb 0.0.58.
May 26, 2023, 1:36 PM