web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

get error:"Number can only safely store up to 53 bits"when I used “web3.eth.getBlock()”

Open camusfsx opened this issue 8 years ago • 8 comments

 web3.eth.getBlockNumber().then(e => {
            blockNum = parseInt(e, 10)
             console.log(blockNum)//81642
            web3.eth.getBlock(blockNum)
                .then(e => console.log(e))
            })
>Error: Number can only safely store up to 53 bits

camusfsx avatar Sep 19 '18 07:09 camusfsx

Store it as a BigNumber ;)

Moejoe90 avatar Sep 20 '18 14:09 Moejoe90

Store it as a BigNumber ;)

Store what as a BigNumber ?? trying ti print the result from web3.eth.getBlock() is itself giving this error.

rahuldamodar94 avatar Feb 27 '19 15:02 rahuldamodar94

In many blogs I've found it was a Truffle version problem. Truffle v5 would make problems of this type. They suggest to downgrade to [email protected].

This has not been so for me. I have continue to use truffle v5. I've resolved by checking my gas limit when I sent a transaction. gasLimit: web3.utils.toHex( gas_limit ),//The maximum gas provided for this transaction (gas limit)

Node: v8.11.4 Truffle: 5.0.12 Web3: 1.0.0-beta.52 Truffle-contract: 4.0.11 [email protected] │ └── [email protected] └── [email protected] Ganache-cli: v6.4.3 (ganache-core: 2.5.5) Ethereumjs-tx: 1.3.4

ghost avatar May 21 '19 20:05 ghost

 web3.eth.getBlockNumber().then(e => {
            blockNum = parseInt(e, 10)
             console.log(blockNum)//81642
            web3.eth.getBlock(blockNum)
                .then(e => console.log(e))
            })
>Error: Number can only safely store up to 53 bits

How did you resolve this?

keennay avatar Oct 20 '19 11:10 keennay

@macman18 Having the same issue and I am not using Truffle, just web3 Is there any good solution, yet?

Xychun avatar Nov 04 '19 11:11 Xychun

+1 getting the same error when trying to get a block by the block number. BigNumber doesn't make a difference.

MaxXor avatar May 10 '20 20:05 MaxXor

+1 I think web3 is trying to parse response JSON, but it's include big number that my javascript can't handle.

khaschuluu avatar May 08 '21 08:05 khaschuluu

this is similar to this one https://github.com/ChainSafe/web3.js/issues/3936#issuecomment-797342613

lucaspiressimao avatar Jan 24 '22 06:01 lucaspiressimao