Web3.js: Incorrect encoding of BigNumber for uint256[]

Created on 19 Jun 2020  路  1Comment  路  Source: ChainSafe/web3.js

Expected behavior

abi.encodeParameter should process BigNumbers in the same way for uint256 and uint256[]

Actual behavior

ABI coder encodes arrays of BigNumbers incorrectly

Steps to reproduce the behavior

const Web3 = require('web3')
const web3 = new Web3()

web3.eth.abi.encodeParameter('uint256', '123') // 0x00...007b
web3.eth.abi.encodeParameter('uint256', web3.utils.toBN('123')) // same as above

web3.eth.abi.encodeParameter('uint256[]', ['123']) // 0x00..007b
web3.eth.abi.encodeParameter('uint256[]', [web3.utils.toBN('123')]) // should be the same as above, gives 0x00..0000 instead

Environment

1.x bug

>All comments

Thanks for catching this @k1rill-fedoseev!

Was this page helpful?
0 / 5 - 0 ratings