最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Solidity error: Unexpected token h in JSON at position - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 6

My 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.

发布评论

评论列表(0)

  1. 暂无评论