Solidity错误:JSON位置的意外令牌h

问题描述 投票:1回答:2

嘿,我正在制定一份关于稳固性的简单智能合约,我遇到了一个问题。每次我尝试运行setWord函数时都会收到错误“transact to HelloWorldContract.setWord errored:Error encoding arguments:SyntaxError:JSON中位置2的意外标记h”可能是什么问题?

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!";
    }
}
}
javascript json ethereum solidity
2个回答
3
投票

我的猜测是你正在使用Remix IDE

不要忘记在你传递的参数周围添加双引号:enter image description here


2
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.