I have a question when I use solidity to compile a simple contract. It like that:
> web3.eth.getCompilers()
["Solidity"]
> source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
"contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
> source
"contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
> clientContract = eth.compile.solidity(source).test
undefined
I don't know why the result is "undefined", what is wrong? I'm using it on the mac os.
Solidity programming language doesn't have the nullability feature, which is common in many languages like Swift and JavaScript. Instead, types have the default values, like zero 0 for uint .
Integers help in storing numbers in contracts. Solidity provides the following two types of integer: Signed integers: Signed integers can hold both negative and positive values. Unsigned integers: Unsigned integers can hold only positive values along with zero.
private variables / members are not inherited.
variable_name − This is the name of variable given by user. value − Any value to initialize the variable. By default, it is zero.
According to Greeter variables are all undefined and contract doesn't run undefined
in JavaScript isn't a bad thing. Variable declarations always return undefined
, its nothing to worry about.
So to answer your question, nothing is wrong, just proceed with your compiled clientContract
and ignore the undefined
return message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With