2

I meet the same problem as this question: Passing an array as a parameter from javascrpt (web3) to a Solidity function

If I call my function in the browser-solidity with the parameter [122,44], it works well. But if I use it in my own web UI, it throw out "Error: new BigNumber() not a number". The way I call it is like:

myContract.myFunction([122,44],{from:accounts[0]},function(err,res){...})

or

myContract.myFunction(["122","44"],{from:accounts[0]},function(err,res){...})

I don't know why. It should be the same result as in the browser-solidiy.

1

What types your solidity function expects? If it's uint or int then you must convert your params to BigNumber before you passing it. E.g.:

import BigNumber from 'bignumber.js';
let myParams = [122,44];
let convertedParams = myParams.map( item => { return new BigNumber(item)});
myContract.myFunction(convertedParams,{from:accounts[0]},function(err,res){...})

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.