简体   繁体   English

实体错误:位置JSON中出现意外的令牌h

[英]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? 每次尝试运行setWord函数时,都会出现错误“向HelloWorldContract.setWord交易时出错:编码参数错误: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!";
    }
}
}

My guess would be that you're using Remix IDE . 我的猜测是您正在使用Remix IDE

Don't forget to add double quotes around the arguments you're passing: 不要忘记在传递的参数周围添加双引号: 在此处输入图片说明

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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