Contract names prepended with `<stdin>:` #1695

Closed
ericsaupe opened this Issue Feb 14, 2017 · 1 comment

Projects

None yet

2 participants

@ericsaupe

I'm compiling this source code and everytime I call compile solidity it is returning the name of the contract prepended with <stdin>:. It also seems like I'm unable to interact with the contract once it's been mined. My guess is it's compiling it incorrectly meaning I can't do anything with it.

Here is the source code for the contract:

pragma solidity ^0.4.9;

contract ContractWithParams {

  address setting;

  event MyEvent(address indexed _a, uint indexed _b);

  function ContractWithParams(address _setting) {
    setting = _setting;
  }

  function getSetting() public constant returns (address) {
    return setting;
  }

  function genEvent() {
    MyEvent(msg.sender, block.timestamp);
  }

  function getSetting(uint _a) public constant returns (uint) {
    return _a * _a;
  }
}

Here is the geth command I'm running:
geth --testnet --rpc --rpcapi web3,eth,debug,net

Here is the curl command I'm running:
curl localhost:8545 -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["pragma solidity ^0.4.9;\n\ncontract ContractWithParams {\n\n address setting;\n\n event MyEvent(address indexed _a, uint indexed _b);\n\n function ContractWithParams(address _setting) {\n setting = _setting;\n }\n\n function getSetting() public constant returns (address) {\n return setting;\n }\n\n function genEvent() {\n MyEvent(msg.sender, block.timestamp);\n }\n\n function getSetting(uint _a) public constant returns (uint) {\n return _a * _a;\n }\n}\n"],"id":1}'

Here is the output of that:

{  
   "jsonrpc":"2.0",
   "id":1,
   "result":{  
      "\u003cstdin\u003e:ContractWithParams":{  
         "code":"0x6060604052341561000c57fe5b60405160208061015783398101604052515b60008054600160a060020a031916600160a060020a0383161790555b505b61010c8061004b6000396000f300606060405263ffffffff60e060020a60003504166340b43701811460345780635056b309146056578063dd0f080814607f575bfe5b3415603b57fe5b6044600435608e565b60408051918252519081900360200190f35b3415605d57fe5b60636097565b60408051600160a060020a039092168252519081900360200190f35b3415608657fe5b608c60a7565b005b8080025b919050565b600054600160a060020a03165b90565b6040514290600160a060020a033316907fdf50c7bb3b25f812aedef81bc334454040e7b27e27de95a79451d663013b7e1790600090a35b5600a165627a7a723058208e29507e7cb73a845108b5a5c6c8a1652293049c729463a1191ccec5619feab00029",
         "info":{  
            "source":"pragma solidity ^0.4.9;\n\ncontract ContractWithParams {\n\n  address setting;\n\n  event MyEvent(address indexed _a, uint indexed _b);\n\n  function ContractWithParams(address _setting) {\n    setting = _setting;\n  }\n\n  function getSetting() public constant returns (address) {\n    return setting;\n  }\n\n  function genEvent() {\n    MyEvent(msg.sender, block.timestamp);\n  }\n\n  function getSetting(uint _a) public constant returns (uint) {\n    return _a * _a;\n  }\n}\n",
            "language":"Solidity",
            "languageVersion":"0.4.9",
            "compilerVersion":"0.4.9",
            "compilerOptions":"--combined-json bin,abi,userdoc,devdoc --add-std --optimize",
            "abiDefinition":[  
               {  
                  "constant":true,
                  "inputs":[  
                     {  
                        "name":"_a",
                        "type":"uint256"
                     }
                  ],
                  "name":"getSetting",
                  "outputs":[  
                     {  
                        "name":"",
                        "type":"uint256"
                     }
                  ],
                  "payable":false,
                  "type":"function"
               },
               {  
                  "constant":true,
                  "inputs":[  

                  ],
                  "name":"getSetting",
                  "outputs":[  
                     {  
                        "name":"",
                        "type":"address"
                     }
                  ],
                  "payable":false,
                  "type":"function"
               },
               {  
                  "constant":false,
                  "inputs":[  

                  ],
                  "name":"genEvent",
                  "outputs":[  

                  ],
                  "payable":false,
                  "type":"function"
               },
               {  
                  "inputs":[  
                     {  
                        "name":"_setting",
                        "type":"address"
                     }
                  ],
                  "payable":false,
                  "type":"constructor"
               },
               {  
                  "anonymous":false,
                  "inputs":[  
                     {  
                        "indexed":true,
                        "name":"_a",
                        "type":"address"
                     },
                     {  
                        "indexed":true,
                        "name":"_b",
                        "type":"uint256"
                     }
                  ],
                  "name":"MyEvent",
                  "type":"event"
               }
            ],
            "userDoc":{  
               "methods":{  

               }
            },
            "developerDoc":{  
               "methods":{  

               }
            }
         }
      }
   }
}

You can see the <stdin>: in the result key. Anything obvious I'm doing wrong? Running on macOS Sierra.

@axic
Member
axic commented Feb 14, 2017

You'll need to use a new version of geth, see this issue #1656.

However, I would suggest to use solc or solcjs natively and not via geth. Hopefully the compile RPC method will also be removed in the future. You can also give try to https://remix.ethereum.org/

@ericsaupe ericsaupe closed this Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment