Getting this Big Number error when trying to update my token price.Seems like a Javascript issue with the number size being passed.Anyone know a fix for this?

App.contracts.DappTokenSale.deployed().then(function(instance) {
  let newPrice = document.getElementById('updatePrice');
  newPrice = web3.toWei(newPrice, 'ether');


 // Solidity 
function setTokenPrice(uint256 _newPrice) public{
  tokenPrice = _newPrice;

This is actually just a plain old Javascript problem.

This line:

let newPrice = document.getElementById('updatePrice'); is referring to the updatePrice DOM element, not the contents of that element.

But this function:

web3.toWei, takes a number as its first argument. You're passing a DOM element.

You need to change the former so that newPrice is a number and not an element. If you're unsure how to do this, you're best off asking in regular old Stack Overflow.

  • Ah I feel stupid, sorry I was overlooking the problem and thought it was something else. Just forgot to add .value to the end. Thanks for that.
    – James F
    Apr 30 '19 at 6:37

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.