I'm very new in the smart contract field and just starting to explore this.

I'm using the remix.ethereum.org Solidity IDE and copied the following contract:

pragma solidity ^0.4.9;

    contract Hello  {

        // A string variable
        string public greeting;

        // Events that gets logged on the blockchain
        event GreetingChanged(string _greeting);

        // The function with the same name as the class is a constructor
        function Hello(string _greeting) {

            greeting = _greeting;


        // Change the greeting message
        function setGreeting(string _greeting) {

            greeting = _greeting;

            // Log an event that the greeting message has been updated

        // Get the greeting message
        function greet() constant returns (string _greeting) {

            greeting = _greeting;



When I create the contract I get following error:

Error encoding arguments: SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data

When I run the contract in the wallet it runs just fine.

Both tried execution environment JavaScript VM and Web3.

For Web3 I did not install or run any additional program other than the wallet in testnet mode.

What can I do to get this thing going?


You're right on track, using remix makes a lot of sense for testing and playing around. The constructor of the Hello contract takes a string as a parameter. Make sure you enclose that with quotes, e.g. "Hello World", otherwise you run into that error.

Stay with the Javascript VM, that's ideal for testing. If you want to deploy it to the main chain or some test chain you can simply install the MetaMask Chrome extension which injects a web3 object into every page you open. Then you can choose injected web3 instead of the VM and the contract will be deployed onto the public chain when clicking create - but you need some Ether to pay for the gas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.