简体   繁体   中英

Solidity error: Unexpected token h in JSON at position

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!";
    }
}
}

My guess would be that you're using Remix IDE .

Don't forget to add double quotes around the arguments you're passing: 在此处输入图片说明

您需要在双引号中传递参数字符串-“ helloWorld ”,而不仅仅是helloWorld

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM