I'm attempting to compile the following contract using geth console attached to a testrpc instance:
contract UnitCounter {
mapping (address => uint256) public UnitsFrom;
uint256 public TotalUnits;
function submitUnits(uint256 Units) {
UnitsFrom[msg.sender] = Units;
TotalUnits += Units;
}
}
After running testrpc and connecting:
testrpc -a 1000
I attached a geth cosole
geth attach rpc:http://localhost:8545
and did the following:
> eth.getCompilers()
["solidity"]
> co=eth.compile.solidity("contract UnitCounter {mapping (address => uint256) public UnitsFrom;uint256 public TotalUnits;function SubmitUnits(uint256 Units) {UnitsFrom[msg.sender] = Units;TotalUnits += Units;}}")
Which gives this error:
Error: Invalid JSON RPC response: {"error":{"code":-32603,"json: cannot unmarshal array into Go value of type string":"json: cannot unmarshal array into Go value of type string"},"id":11,"version":"2.0"}
at web3.js:3119:20
at web3.js:6023:15
at web3.js:4995:36
at <anonymous>:1:4
What does this error mean? What steps should I take to debug?
solc
command line version to compile your contract locally. Here are some examples: tokenmarket.net/blog/…