0

I am working on truffle (solc 0.5) and trying to fetch amount in wei from user and send it to another account. Following is my code:

contract pay {

  uint amount;
  function payment(uint _amount, address payable _ID) external payable {
        
        amount = _amount;
        _ID.transfer(msg.value);
    }
}

I typed in the following command in truffle console:

var contract = await name.deployed() then await contract.pay(10000000000000000, accounts[1], {value: amount})

I received an error after executing payment function as:

reason: 'overflow', code: 'NUMERIC_FAULT', fault: 'overflow', operation: 'BigNumber.from', value: 10000000000000000,

What should I do in order to send fetched amount from the account calling the function to another account? What should I change in order for it to work properly? A code for reference would be helpful

0

Try to pass the value as a string, example - "10000000000000000". Or if it's dynamic value you could use .toString() method.

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.