I'm trying to write a contract that has a string that can be modified/updated by the owner later on. I tested it in Remix and it works perfectly. But when I deploy it to my private blockchain, I get errors. Any ideas? Or is there at least a reasonable way to debug the code? These errors seem to be useless!
pragma solidity ^0.4.13;
contract c5 {
uint currentVersion;
string command;
address owner;
//Constructor is automatically executed upon creation:
function c5(){
currentVersion = 1;
command = "test1";
owner = msg.sender;
}
function update(uint input){
if(msg.sender != owner) return;
currentVersion = input;
}
function query() constant returns (string){
return command;
}
function version() constant returns (uint){
return currentVersion;
}
}
This is the error I get in the geth console:
> c5.query()
"test1"
> c5.version()
1
> c5.update("4")
Error: invalid address
at web3.js:3879:15
at web3.js:3705:20
at web3.js:4948:28
at map (<native code>)
at web3.js:4947:12
at web3.js:4973:18
at web3.js:4998:23
at web3.js:4061:16
at apply (<native code>)
at web3.js:4147:16
Are these strings indeed editable? or do I need to submit a new contract with the new string and direct queries to it via an updated address via DELEGATECALL:
Thanks in advance for any ideas!
> c5.update("4"{from:"0x6dd4530a254de371110f88322a67c7d77dc60790"})I tried several variants of that with quotes and commas added as well but always got errors like this:(anonymous): Line 1:14 Unexpected token { (and 2 more errors)– Jonny Sweeny Jul 28 '17 at 06:54> c5.updateV(44321,{from: eth.accounts[0]}) "0x46e2ad3a25b00aa12624093492c1b84ee28b9f4aee6c632cca363d4d756c72cc"Note to future persons, that you won't notice the updated value via the query command until after a block has been mined. `> miner.start(1) null
true
44321`
– Jonny Sweeny Jul 28 '17 at 08:29web3.eth.defaultAccount = web3.eth.accounts[0]by itself first in the console is the cleanest and easiest. – Jonny Sweeny Jul 29 '17 at 02:20web3command? it has to be part of.solfile? Can we do something witheris-contracts– Varun Aug 14 '17 at 07:35