You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Web3@1.0.00-beta.50 in a React Web development environment contract type uints are returned from infura and parsed into js ints. When creating a build of the React project and running it on the server numbers are being parsed into BigNumber objects. The jsonrpc response is the same for both local dev and production server.
contract.methods.GetLength().call().then((res)=>{
console.log('Length result',res);
// Length result e {_hex: "0x01", _ethersType: "BigNumber"}
},(err)=>{
});
Steps to reproduce the behavior
1. Import web3
2. Set the provider to infura/v3
3. Create contract instance
4. Call method that returns a uint solidity type
5. Run npm start on local machine
6. Run npm build
7. Compare the result of the promise callback between the two
import Web3React from 'web3';
var web3react = new Web3React("https://rinkeby.infura.io/v3/key");
var contract = new web3react.eth.Contract(_abi, _addr);
contract.methods.GetLength().call().then((res)=>{
console.log('Length result',res);
},(err)=>{
});
Versions
web3.js: web3@1.0.0-beta.50
nodejs:
browser: Chrome
ethereum node:
The text was updated successfully, but these errors were encountered:
I've checked it closer and it should return a BigNumber object instead of the string. I've created an issue for it. It should return a BigNumber object because JS can't handle the returned numbers from the node. The BigNumber objects give you also some additional features you can work with.
Description
When using Web3@1.0.00-beta.50 in a React Web development environment contract type uints are returned from infura and parsed into js ints. When creating a build of the React project and running it on the server numbers are being parsed into BigNumber objects. The jsonrpc response is the same for both local dev and production server.
Local Host React Dev Behavior
Network response:
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000001"}
Production React Build Behavior
Network response:
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000001"}
Steps to reproduce the behavior
Versions
The text was updated successfully, but these errors were encountered: