Hey I'm developing a simple smart contract on solidity and I crashed into a problem. Everytime I try to run setWord function I get an error "transact to HelloWorldContract.setWord errored: Error encoding arguments: SyntaxError: Unexpected token h in JSON at position 2" What could be the problem?
pragma solidity ^0.4.0;
contract HelloWorldContract{
string word = "Hello World";
address issuer;
function HelloWorldContract(){
issuer = msg.sender;
}
function getWord() constant returns(string) {
return word;
}
function setWord(string newWord) returns(string) {
if(issuer != msg.sender){
return "this is not the creator!";
}
else{
word = newWord;
return "this is the creator!";
}
}
}
Hey I'm developing a simple smart contract on solidity and I crashed into a problem. Everytime I try to run setWord function I get an error "transact to HelloWorldContract.setWord errored: Error encoding arguments: SyntaxError: Unexpected token h in JSON at position 2" What could be the problem?
pragma solidity ^0.4.0;
contract HelloWorldContract{
string word = "Hello World";
address issuer;
function HelloWorldContract(){
issuer = msg.sender;
}
function getWord() constant returns(string) {
return word;
}
function setWord(string newWord) returns(string) {
if(issuer != msg.sender){
return "this is not the creator!";
}
else{
word = newWord;
return "this is the creator!";
}
}
}
Share
Improve this question
asked Feb 28, 2018 at 23:20
Rokas SimkusRokas Simkus
631 silver badge9 bronze badges
2 Answers
Reset to default 6My guess would be that you're using Remix IDE.
Don't forget to add double quotes around the arguments you're passing:
You need to pass argument string in double quotes - "helloWorld" instead of just helloWorld.