When I try to us a very large number as an argument to a contract function I get a huge string of text in my console. I can't even see what the error is because there is too much text output.
For example I try to do this:
const id = ethers.BigNumber.from(1).mul(ethers.BigNumber.from(2).pow(240))
console.log(id.toString())
await wearables.transferToParent(accounts[0], aavegotchiDiamond.address, 0, id.toHexString(), 1)
How do I pass a very large number to a contract function using ethers.js?
I am using @nomiclabs/buidler-ethers": "^2.0.0"
Can you try passing the id directly? A BigNumber works with uint256 arg type.
await wearables.transferToParent(accounts[0], aavegotchiDiamond.address, 0, id, 1)
Edit: I assumed that your 4th arg is of type uint256. If it isn't that, what is your arg type in solidity?
Thanks I tried that but I got the same result. The arg type is uint256.
Oh, that is surprising, can you share the error?
Oh nevermind, the problem was disrelated to BigNumber. I was using the wrong type in another argument. It was hard to debug because my output was a huge unreadable mess which was too big for my console to display so I didn't see any error.
So fixed the problem. @zemse Thanks for your help and for looking into this.
Thanks @zemse ! I was just checking in on this and was going to ask for the error too. :)
Glad it鈥檚 all figured out. :)
Most helpful comment
Oh nevermind, the problem was disrelated to BigNumber. I was using the wrong type in another argument. It was hard to debug because my output was a huge unreadable mess which was too big for my console to display so I didn't see any error.
So fixed the problem. @zemse Thanks for your help and for looking into this.