2

I'm building a simple fund raising smart contract and having problems deploying this through Remix. I'm wanting to set the "goal" and "minimum contribution" values (in wei) during the contract deployment and so have the following code:

pragma solidity ^0.5.0;

contract FundRaiser {
  // Initial storage variables
  uint256 public goal;
  uint256 public minimumContribution;
  address public owner;

  constructor(uint256 _goal, uint256 _minimumContribution) public {
    goal = _goal;
    minimumContribution = _minimumContribution;
    owner = msg.sender;
  }
}

This compiles fine in Remix and then I try to deploy and have the following prompt: enter image description here

However, if I enter two large values here (1000000000000000000, 10000000000000000 - which equates to a goal of 1ETH with a minimum contribution of 0.01ETH) then I get the error:

creation of FundRaiser errored: Error encoding arguments: Error: invalid number value (arg="", coderType="uint256", value=10000000000000000, version=4.0.32)

If I then click the drop-down arrow next to the Deploy option it then shows the following: enter image description here

Strangely Remix seems to have converted the first value into a string (surrounded by quotes) but not the second value. If I now update the values so that either both are strings or both are numbers and click "transact" then it deploys fine.

Is this an error on my part in using Remix or a bug??

1
  • Update Feb-2020 - Now appears fixed - see post below..
    – MKen212
    Feb 7, 2020 at 16:09

3 Answers 3

3

This seems to be a remix bug.

When you deploy it using web3 or so it should work properly.

Everything should be fine. As the other answer stated you can bypass this problem.

1
  • Thanks for the confirmation. As you say, only a minor issue and works fine with alternate deployment options. Will post on the Remix Glitter channel for info...
    – MKen212
    Aug 23, 2019 at 13:48
1

Update Feb-2020 - Tried this again using the new Remix IDE and appears to deploy correctly even with large numbers not enclosed in quotes:

enter image description here

Appears to be sending the Constructor arguments in hex rather than strings: enter image description here

0

I tried the same and my code worked perfectly. There was no such error as well. I cannot say about bug or something, just make sure that you are passing the values properly.enter image description here

enter image description here

Edited answer:

I did the same as yours and its giving error

creation of FundRaiser errored: Error encoding arguments: Error: invalid number value (arg="", type="number", value=10000000000000000)

What Remix does it whenever you provide numbers, it process it as string(by putting quotes around them) and gives the answer back in numbers. The same is happening here. The error is coming because that time only first value was converted to string and not the second one(as you saw by click on drop-down arrow). Remix couldn't process the second value since it doesn't have double quotes around it and thus giving error.
But again click on arrow and then again. Now both the values with be having quotes around them and deployment will be successful.

This is strange that Remix cannot convert both the values to string together and is doing it one-by-one. But no worries. It's not an error or anything wrong from your side.

2
  • Looks like you clicked on the drop-down arrow and entered the numbers (in quotes) which I agree does work. The error comes if you enter the numbers (without quotes) in the deploy option when it is in the collapsed view (don't click the drop down arrow) and you will see the error... This "should" work according to the remix docs: remix-ide.readthedocs.io/en/latest/…
    – MKen212
    Aug 18, 2019 at 8:25
  • Okay. Now I get it what you are trying to say. I did the same you asked. Yes Remix is converting first value to string and another as it is. Check my edited answer. Aug 20, 2019 at 18:04

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.