代码之家  ›  专栏  ›  技术社区  ›  Rokas Simkus

Solidity错误:JSON中的意外标记h位于

  •  2
  • Rokas Simkus  · 技术社区  · 7 年前

    嘿,我正在开发一个简单的关于solidity的智能合约,我遇到了一个问题。每次尝试运行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!";
        }
    }
    }
    
    2 回复  |  直到 7 年前
        1
  •  6
  •   YinYang16    7 年前

    我猜你在用 Remix IDE .

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

        2
  •  2
  •   trntga    7 年前

    您需要以双引号传递参数字符串— 你好世界 “而不仅仅是 你好世界 .