Search code examples
javascriptblockchainethereumsoliditysmartcontracts

I Call SmartContract Token ERC20, Why Show Hashing Output?


I do not know why with this, even though in the previous version (web3 + Metamask) can issue real data. But now used as hashing (output). I took the example in the code and output below (to get the TotalSupply on the ERC20 Token):

Output : 0x18160ddd

const contractInstance = web3.eth.contract(contractAbi).at(contractAddress);
const total_supply = contractInstance.totalSupply.getData();
console.log(total_supply);

How to showing real data? In a sense it doesn't come out hashing. Thanks


Solution

  • .getData() returns the ABI-encoded input you would have to send to the smart contract to invoke that method.

    If you want to actually call the smart contract, use .call() instead.