Im trying to run my first HelloWorld smart contract on the Enthereum network. This is my HelloWorld.sol contract.
pragma solidity ^0.5.0;
contract HelloWorld {
bytes32 message;
constructor (bytes32 myMessage) public {
message = myMessage;
}
function getMessage() public returns(bytes32) {
return message;
}
}
When I try to build this using solcjs HelloWorld.sol --bin
, there is just one Warning and no errors. I have installed web3 and solc using npm. When I run this on a node
var solc = require('solc');
var x = fs.readFileSync('./HelloWorld.sol').toString();
var compiledContract = solc.compile(x);
the compiledContract
contains this:
'{"errors":[{"component":"general","formattedMessage":"* Line 1, Column 1\\n Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n Extra non-whitespace after JSON value.\\n","message":"* Line 1, Column 1\\n Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n Extra non-whitespace after JSON value.\\n","severity":"error","type":"JSONError"}]}'
Where is the problem?