2
let result = await instance.joinQuiz({
    from: accounts[1],
    value: web3.utils.toWei(10, "wei")
});

1 Answer 1

5

The signature of the toWei method is (can be found in the docs.

web3.utils.toWei(number [, unit])

number - String|BN: The value.
unit - String (optional, defaults to "ether"): The ether to convert from.

So you should provide the number as either a String or a BigNumber (Web3 0.2x) / BN (Web3 1.x).

Your code should then be:

let result = await instance.joinQuiz({
    from: accounts[1], 
    value: web3.utils.toWei("10", "wei")
});

However, in your code you're converting from wei to wei, which might not be what you want, so keep in mind that the second parameter is the unit you're converting from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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