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

Error while decode transaction with Web3 #44

Closed
fonov opened this issue Oct 16, 2020 · 7 comments
Closed

Error while decode transaction with Web3 #44

fonov opened this issue Oct 16, 2020 · 7 comments

Comments

@fonov
Copy link

fonov commented Oct 16, 2020

I tried decode transaction from block but got a error

Number can only safely store up to 53 bits
	at assert ./node_modules/number-to-bn/node_modules/bn.js/lib/bn.js:6
	at BN.toNumber ./node_modules/number-to-bn/node_modules/bn.js/lib/bn.js:506
	at Object.hexToNumber ./node_modules/web3-core-helpers/node_modules/web3-utils/lib/utils.js:208
	at Method.outputTransactionFormatter [as outputFormatter] ./node_modules/web3-core-helpers/lib/formatters.js:204
	at Method.formatOutput ./node_modules/web3-core-method/lib/index.js:147
	at sendTxCallback ./node_modules/web3-core-method/lib/index.js:523
	at ./node_modules/web3-core-requestmanager/lib/index.js:293
	at XMLHttpRequest.request.onreadystatechange ./node_modules/web3-providers-http/lib/index.js:98
	at XMLHttpRequestEventTarget.dispatchEvent ./node_modules/xhr2-cookies/xml-http-request-event-target.ts:44
	at XMLHttpRequest._setReadyState ./node_modules/xhr2-cookies/xml-http-request.ts:219
	at XMLHttpRequest._onHttpResponseEnd ./node_modules/xhr2-cookies/xml-http-request.ts:345
	at IncomingMessage.<anonymous> ./node_modules/xhr2-cookies/xml-http-request.ts:311
	at IncomingMessage.emit events.js:326
	at endReadableNT _stream_readable.js:1252
	at processTicksAndRejections internal/process/task_queues.js:80

error occur with tx id 0xe0db32759810271eec05326a4c96fbb42a185139134e16b4581f77456df226a9

if look closely on https://bscscan.com/tx/0xe0db32759810271eec05326a4c96fbb42a185139134e16b4581f77456df226a9

we can see that gas equal 9,223,372,036,854,775,807, so web3 js can't convert this string to number

Anyone has idea how resolve this problem?

import Web3 from 'web3';

async function main() {
  const web3 = new Web3('https://bsc-dataseed1.binance.org:443');

  const res = await web3.eth.getBlock(1365710);

  await Promise.all(
    res.transactions.map(async (txId) => {
      try {
        const tx = await web3.eth.getTransaction(txId);

        console.log(`decode ${txId}`);
      } catch (error) {
        console.error(`error decode ${txId}`);
      }
    }),
  );
}

main();
@unclezoro
Copy link
Collaborator

What's the version are you using of web3.js? Upgrade to latest version may works.
As I have tried, it works on latest version:
image

@fonov
Copy link
Author

fonov commented Nov 24, 2020

i use latest version

"web3": "1.3.0",
    "web3-core": "1.3.0",
    "web3-core-helpers": "1.3.0",
    "web3-eth": "1.3.0",
    "web3-eth-contract": "1.3.0",
    "web3-utils": "1.3.0",

And i still get a error

Screenshot 2020-11-24 at 11 30 09

@fonov
Copy link
Author

fonov commented Nov 24, 2020

but i found a how fixed issue and already created pull request in web3 repo https://github.com/ethereum/web3.js/pull/3789/files

@v0ld-dev
Copy link

Hello everyone ! I have too this problem ! Try to combine versions of web3js, not helped.

@unclezoro
Copy link
Collaborator

It is the problem that BSC have system tx like this one: https://bscscan.com/tx/0xc35fed5ba462e2ec9c1131ea80ba30a5b82312ca37c6c75d3b990bc4a86eae96
The gas limit of system tx is 9,223,372,036,854,775,807, which beyond what the BN lib of node js can handle.

@fonov
Copy link
Author

fonov commented Feb 14, 2021

Why it close? Problem still exist

yutianwu pushed a commit that referenced this issue May 6, 2021
…#22668)

* eth/protocols/snap: generate storage trie from full dirty snap data

* eth/protocols/snap: get rid of some more dead code

* eth/protocols/snap: less frequent logs, also log during trie generation

* eth/protocols/snap: implement dirty account range stack-hashing

* eth/protocols/snap: don't loop on account trie generation

* eth/protocols/snap: fix account format in trie

* core, eth, ethdb: glue snap packets together, but not chunks

* eth/protocols/snap: print completion log for snap phase

* eth/protocols/snap: extended tests

* eth/protocols/snap: make testcase pass

* eth/protocols/snap: fix account stacktrie commit without defer

* ethdb: fix key counts on reset

* eth/protocols: fix typos

* eth/protocols/snap: make better use of delivered data (#44)

* eth/protocols/snap: make better use of delivered data

* squashme

* eth/protocols/snap: reduce chunking

* squashme

* eth/protocols/snap: reduce chunking further

* eth/protocols/snap: break out hash range calculations

* eth/protocols/snap: use sort.Search instead of looping

* eth/protocols/snap: prevent crash on storage response with no keys

* eth/protocols/snap: nitpicks all around

* eth/protocols/snap: clear heal need on 1-chunk storage completion

* eth/protocols/snap: fix range chunker, add tests

Co-authored-by: Péter Szilágyi <peterke@gmail.com>

* trie: fix test API error

* eth/protocols/snap: fix some further liter issues

* eth/protocols/snap: fix accidental batch reuse

Co-authored-by: Martin Holst Swende <martin@swende.se>
keefel pushed a commit to keefel/bsc that referenced this issue Mar 6, 2023
@BuyOwnEx
Copy link

For those who cannot decode transaction with Web3

Use web3 with version >= 1.9.0

And use optional hexFormat param to getTransaction and getBlock that accepts the value 'hex'

Example:

let transactions = await web3.eth.getBlock(block_number, true, 'hex')

Yasminmelo1003 referenced this issue Nov 1, 2023
…#412)

* add extension for eth protocol handshake

* fix comments
galaio pushed a commit to galaio/bsc that referenced this issue Jul 31, 2024
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