New answers tagged

0

Arrays are encoded with a 32 bytes denoting a position (offset) from the beginning of the data. Then at that offset you will find another 32 bytes showing the length. After that you will have all the array elements. In your case the first 32 bytes show an offset of 0x20 = 32, then at position 32 we have another 32 bytes showing the length of 1, and then 1 ...


2

In web3.js v0.x: The expression contractInstance.totalSupply.getData() would get you the encoded ABI data (byte-code) of a call to function totalSupply. In order to actually call the function and retrieve the return-value asynchronously, you should use: contractInstance.totalSupply.call().then(total_supply => { console.log(total_supply); }); In ...


4

The output you receive is in hex format. You need to conver hex to an int. Here is the full code you need to use: const contractInstance = web3.eth.contract(contractAbi).at(contractAddress); const total_supply = parseInt(contractInstance.totalSupply.getData()); console.log(total_supply); I added parseInt() to convert your hex number into a human readable ...


1

Change it to this: async function run() { const decimals = await contract.methods.decimals().call(); for (var i = 0; i < 8444182; i++) { const balance = await contract.methods.balanceOf(address).call(null, i); const actual = new BigNumber(balance + "e-" + decimals); console.log(actual.toFixed()); } } run();


Top 50 recent answers are included