I'm trying to read symbol from this contract https://etherscan.io/address/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0#readContract but getting en error The returned value is not a convertible string. Here is my code:

const contractInstance = new Config.web3.eth.Contract(abi, "0x86Fa049857E0209aa7D9e616F7eb3b3B78ECfdb0");

const symbol = contractInstance.methods.symbol().call();

symbol.then((res) => { console.log(res) }).catch((err) => { console.log(err) })

At the same time i'm able to read name, totalSupply, decimals.Is there is any way to read contract symbol ?

  • 1
    Are you perhaps using the wrong ABI? When I use the ABI from etherscan.io/address/…, your code works fine for me. Note that symbol is a bytes32. – user19510 Jan 23 '18 at 3:46
  • As for how to convert it to a string, this works, though I wonder if there's an easier way: web3.utils.hexToAscii('0x454f530000000000000000000000000000000000000000000000000000000000').replace(/\u0000*$/, '') – user19510 Jan 23 '18 at 3:51

Using the correct ABI should fix the issue. Complete working code:

const Web3 = require('web3');

const web3 = new Web3('https://mainnet.infura.io/<REDACTED>');

// Stripped down ABI from https://etherscan.io/address/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0#code,
// with just the function we care about.
const abi = [
    "constant": true,
    "inputs": [],
    "name": "symbol",
    "outputs": [
        "name": "",
        "type": "bytes32"
    "payable": false,
    "type": "function"

new web3.eth.Contract(abi, '0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0')
.then((symbol) => {
  const symbolString = web3.utils.hexToAscii(symbol).replace(/\u0000*$/, '');

// Output:
// EOS
  • You right. I used next ABI: "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "type": "function" }, – Sunny Jan 23 '18 at 3:59
  • Is there is a way to get ABI for a contract without calling etherscan ?. – Sunny Jan 23 '18 at 4:02
  • The ABI can be published anywhere, but Etherscan is the most popular place. You can generate the ABI yourself from source code, but either way you need the source code to be published. – user19510 Jan 23 '18 at 4:14
  • 2
    By the way, the ERC20 standard dictates that symbol returns a string, so it looks like the issue you ran into is largely because this token doesn't follow the standard. – user19510 Jan 23 '18 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.