I keep getting
throw Error(`value is out of range for ${bits} bits. Got ${value}`);

while Im trying to sendTransaction with any value(1 or 0.01 doesn't work). Even when I haven't modified the tutorial codes. Any idea why? Seems like bitbuilder gets undefined variable somehow

Mar 1, 2023, 9:24 AM
did you use toNano('0.01') ?
Mar 1, 2023, 9:29 AM
No, I will try asap
Mar 1, 2023, 9:29 AM
if you can show your code snippet i can try to help
Mar 1, 2023, 9:29 AM
Well the most basic one is from the https://ton-community.github.io/tutorials/01-wallet/

await walletContract.sendTransfer({
secretKey: key.secretKey,
seqno: seqno,
messages: [
internal({
to: "EQDrjaLahLkMB-hMCmkzOyBuHJ139ZUYmPHu6RRBKnbdLIYI",
value: "0.001", // 0.001 TON
body: "Hello", // optional comment
bounce: false,
})
]
});
Tried doing value: value: toNano(1), it turned same
throw Error(`value is out of range for ${bits} bits. Got ${value}`);
^
Error: value is out of range for 8 bits. Got undefined
Mar 1, 2023, 9:35 AM
change value: toNano("0.01") input is string
Mar 1, 2023, 9:36 AM
I think it is sting | number | bigint I changed to value: toNano("0.01") but still same error, tried with value: toNano("1") too same
Weird, does the tutorial code work for you?
Mar 1, 2023, 9:38 AM
check line numbers of error origin , error value does not mean sendtransfer param value. error should be from somewhere i think.
https://github.com/ton-core/ton-core/blob/43472ce33212995584ed0193d0ce31a881a213a1/src/boc/BitBuilder.ts#L96
Mar 1, 2023, 9:42 AM
Yeah exactly, sorry should've provide you the full error, will try something and update it
Oh btw, just checked, Tonweb uses amount: TonWeb.utils.toNano("0.001") in its transfer function
I was rying the tutorial with npm ton
What are people using for SDK? TonWeb or npm ton
Mar 1, 2023, 10:14 AM
I have used both. But ton is widely used i think.
Mar 1, 2023, 10:44 AM
npm ton
Mar 1, 2023, 10:48 AM
Thanks for the answers, tried with new package installs, npm ton keeps giving same undefined error even though im not modifying anything on the packages or code, TonWeb worked for me
I needed to specify sendMode for some reason, maybe npm ton just got updated
Mar 1, 2023, 11:21 AM
/nft/searchItems
https://tonapi.io/v1/nft/searchItems?owner=&collection=&include_on_sale=true&limit=1000&offset=0
Mar 1, 2023, 11:38 AM
It's kind of slow. I can't be sure whether it's because on the test-net.
Mar 1, 2023, 11:41 AM
howmuch slow it is?
blockchain transactions always slow it need to be validated and confirmed in block 🤔
Mar 1, 2023, 11:42 AM
Hello everyone.
Did anyone manage to fix this? I'm following the tutorial and the last two steps worked fine. but this step I get the same error.
Linux / node v18.12.1
throw Error(`value is out of range for ${bits} bits. Got ${value}`);
^
Error: value is out of range for 8 bits. Got undefined
at BitBuilder.writeUint (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton-core/dist/boc/BitBuilder.js:83:23)
at Builder.storeUint (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton-core/dist/boc/Builder.js:110:20)
at createWalletTransferV4 (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton/dist/wallets/signing/createWalletTransfer.js:110:24)
at WalletContractV4.createTransfer (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton/dist/wallets/WalletContractV4.js:79:66)
at WalletContractV4.sendTransfer (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton/dist/wallets/WalletContractV4.js:68:29)
at Proxy. (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton-core/dist/contract/openContract.js:38:47)
at main (/home/mohsen/Work/t25/darix/func_test/ton_tut/step9.ts:26:24)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Update:
Checked my wallet version, it was v3r2, [it was v4r2] changed the code,
const wallet = WalletContractV3R2.create({ publicKey: key.publicKey, workchain: 0 });
now it says "wallet is not deployed".
but it is deployed:
https://testnet.tonscan.org/address/EQCKr49f_7hWoETpzrMLaBkPl-kVdqmsmdnqLLCQ0_sDSvvd
the step before even shows my balance correctly.
Mar 2, 2023, 6:25 AM
check the api endpoint that you use in tonclient
Mar 2, 2023, 6:27 AM
what should it be?
I just copied it from the tutorial
const endpoint = await getHttpEndpoint({ network: "testnet" });
my wallet is on testnet.
Mar 2, 2023, 6:29 AM
It means your endpoint wrong or you accidentally spoiled you wallet’s mnemonic in script.

You can calculate StateInit and Address and print it in console to check.
Mar 2, 2023, 6:29 AM
If my mnemonic was wrong it shouldn't show my correct balance.
Mar 2, 2023, 6:30 AM
are you using ton or tonweb library?
Mar 2, 2023, 6:30 AM
Here it is V4R2 btw. You invokes wallet V3R2. Is it ok?
Mar 2, 2023, 6:32 AM
this is the code (minus the mnemonics) copied from step8 https://ton-community.github.io/tutorials/01-wallet/

import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { TonClient, WalletContractV4, internal, WalletContractV3R2 } from "ton";

async function main() {
// open wallet v4 (notice the correct wallet version here)

// const mnemonic = "unfold sugar water ..."; // your 24 secret words (replace ... with the rest of the words)

const mnemonic = "learn nature..."; // your 24 secret words (replace ... with the rest of the words)

const key = await mnemonicToWalletKey(mnemonic.split(" "));
console.log(key.publicKey)
const wallet = WalletContractV4.create({ publicKey: key.publicKey, workchain: 0 });

// initialize ton rpc client on testnet
const endpoint = await getHttpEndpoint({ network: "testnet" });
const client = new TonClient({ endpoint });

// make sure wallet is deployed
if (!await client.isContractDeployed(wallet.address)) {
return console.log("wallet is not deployed");
}

// send 0.001 TON to EQDrjaLahLkMB-hMCmkzOyBuHJ139ZUYmPHu6RRBKnbdLIYI
const walletContract = client.open(wallet);
const seqno = await walletContract.getSeqno();
await walletContract.sendTransfer({
secretKey: key.secretKey,
seqno: seqno,
messages: [
internal({
to: "EQDrjaLahLkMB-hMCmkzOyBuHJ139ZUYmPHu6RRBKnbdLIYI",
value: "0.001", // 0.001 TON
body: "Hello", // optional comment
bounce: false,
})
]
});

// wait until confirmed
let currentSeqno = seqno;
while (currentSeqno == seqno) {
console.log("waiting for transaction to confirm...");
await sleep(1500);
currentSeqno = await walletContract.getSeqno();
}
console.log("transaction confirmed!");
}

main();

function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
I checked again. my wallet is indeed v4r2. I was looking and the wallet which sent me the 2 TONs.
After I corrected my wallet version, I get the same error I was getting:

throw Error(`value is out of range for ${bits} bits. Got ${value}`);
^
Error: value is out of range for 8 bits. Got undefined
at BitBuilder.writeUint (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton-core/dist/boc/BitBuilder.js:83:23)
at Builder.storeUint (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton-core/dist/boc/Builder.js:110:20)
at createWalletTransferV4 (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton/dist/wallets/signing/createWalletTransfer.js:110:24)
at WalletContractV4.createTransfer (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton/dist/wallets/WalletContractV4.js:79:66)
at WalletContractV4.sendTransfer (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton/dist/wallets/WalletContractV4.js:68:29)
at Proxy. (/home/mohsen/Work/t25/darix/func_test/ton_tut/node_modules/ton-core/dist/contract/openContract.js:38:47)
at main (/home/mohsen/Work/t25/darix/func_test/ton_tut/step9.ts:26:24)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
maybe the reciver is not a wallet???
changed reciver to
to: "EQBYivdc0GAk-nnczaMnYNuSjpeXu2nJS3DZ4KqLjosX5sVC",
still the same error
Mar 2, 2023, 6:38 AM
import { getHttpV4Endpoint } from "@orbs-network/ton-access";
import { TonClient4 } from "ton";
const endpoint = await getHttpV4Endpoint({
network: "testnet",
});
const client = new TonClient4({ endpoint });
try this?
Mar 2, 2023, 6:38 AM
Same exact error.

import { getHttpV4Endpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { TonClient4, WalletContractV4, internal } from "ton";


async function main() {
// open wallet v4 (notice the correct wallet version here)

// const mnemonic = "unfold sugar water ..."; // your 24 secret words (replace ... with the rest of the words)
const mnemonic = "learn nature ... away"; // your 24 secret words (replace ... with the rest of the words)

const key = await mnemonicToWalletKey(mnemonic.split(" "));
console.log(key.publicKey)
const wallet = WalletContractV4.create({ publicKey: key.publicKey, workchain: 0 });

// initialize ton rpc client on testnet
// const endpoint = await getHttpEndpoint({ network: "testnet" });
const endpoint = await getHttpV4Endpoint();
const client = new TonClient4({ endpoint });

// make sure wallet is deployed
// if (!await client.isContractDeployed(wallet.address)) {
// return console.log("wallet is not deployed");
// }

// send 0.001 TON to EQDrjaLahLkMB-hMCmkzOyBuHJ139ZUYmPHu6RRBKnbdLIYI
const walletContract = client.open(wallet);
const seqno = await walletContract.getSeqno();
await walletContract.sendTransfer({
secretKey: key.secretKey,
seqno: seqno,
messages: [
internal({
to: "EQBYivdc0GAk-nnczaMnYNuSjpeXu2nJS3DZ4KqLjosX5sVC",
value: "0.001", // 0.001 TON
body: "Hello", // optional comment
bounce: false,
})
]
});

// wait until confirmed
let currentSeqno = seqno;
while (currentSeqno == seqno) {
console.log("waiting for transaction to confirm...");
await sleep(1500);
currentSeqno = await walletContract.getSeqno();
}
console.log("transaction confirmed!");
}

main();

function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Mar 2, 2023, 6:42 AM
console.log(walletContract.address.toString()) ?
updated
what does it show?
Mar 2, 2023, 6:46 AM
EQCKr49f_7hWoETpzrMLaBkPl-kVdqmsmdnqLLCQ0_sDSvvd

https://testnet.tonscan.org/address/EQCKr49f_7hWoETpzrMLaBkPl-kVdqmsmdnqLLCQ0_sDSvvd

it's the correct wallet
Mar 2, 2023, 6:47 AM
It seems, last version ton, ton-core incompatible with this lesson.

You can drop modules and install previous version, it will work fine with these versions:
{
"dependencies": {
"@orbs-network/ton-access": "2.2.2",
"@ton-community/func-js": "^0.5.0",
"ton": "13.3.0",
"ton-core": "0.47.0",
"ton-crypto": "3.2.0",
"ts-node": "10.9.1"
}
}
Mar 2, 2023, 7:54 AM
Thank you. That's what I thought but didn't know the correct version. I'll try it and get back to you.
Yay! it worked. thanks!
deploy transaction confirmed!
If someone has contact to Tal Kol they should notify him to update the tutorial.
Mar 2, 2023, 8:00 AM
@talkol
now Local validator out of sync: 23228 s
how to make it upto date?
Mar 2, 2023, 8:35 AM
it syncing automatically
you can check the status in a few minutes and "out of sync" will be less and less
Mar 2, 2023, 8:36 AM
😱
now cant i get recent transactions via liteserver?
recent i mean new
Mar 2, 2023, 8:36 AM
check the latest block maybe
Mar 2, 2023, 8:37 AM
yes, thanks for the PR, we are investigating if the issue should be fixed in the tutorial or inside the "ton" library
very cool that the community raises the issues with fixes as soon as they happen!
Mar 2, 2023, 9:21 AM
community need more help and support from senior/legendary ton developers.
it is sometimes disappointing when our question never get a reply.
Local validator out of sync: 6 s

can we keep as low as 1s or 0s ?
Mar 2, 2023, 9:38 AM
it should always be <=6 sec
Mar 2, 2023, 9:39 AM
why? if new block added i will get that after 6 seconds?
Mar 2, 2023, 9:41 AM
Maybe that's when new block is generated, your validator has only previous block, which is 5-6 s behind.
Mar 2, 2023, 9:41 AM
if a new block created it will be broadcasted to which validator/node first?
Mar 2, 2023, 9:43 AM
As far as I remember, along semipermanent overlay connections.
Mar 2, 2023, 9:44 AM
it will be broadcasted to all node same time?
🤔
i want all block quickly come to my node without any delay
how to do that?
Mar 2, 2023, 9:47 AM
Can we track and listen for specific method call IDs at a specific address? For example, during the Collection Minting process.

We need to know how many requests are being made and who is calling the minting functions.
Mar 12, 2023, 2:06 PM
If you want some Tact practice, I am working on a Tact learning tool and will appreciate feedback:

https://tact-by-example.org

Tact is a higher language for ton that compiles to func
Mar 12, 2023, 2:41 PM

© 2024 Draquery.com All rights reserved.