I am trying call method symbol, of contract DAI
contract.methods.symbol().call()
This contract returns not string, but bytes 32
And due this fact I always get err:
Number can only safely store up to 53 bits
How to do it properly?
As already mentioned over at the ethereum stackexchange web3 has util functions to convert between string
and byte32
:
const val32 = contract.methods.symbol().call();
const valString = web3.toAscii(val32);
if you're on a web3 version 0.x.
Or:
const val32 = contract.methods.symbol().call();
const valString = web3.utils.toAscii(val32);
for a web3 version 1.0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.