15

I am trying to follow this example: https://github.com/ethereum/pyethapp/wiki/The_Console

However, at the point where I should compile the code, I get an error:

In [34]: print c
contract NameReg{
    event AddressRegistered(bytes32 indexed name, address indexed account);
    mapping(address => bytes32) toName;

    function register(bytes32 name){
        toName[msg.sender] = name;
        AddressRegistered(name, msg.sender);
    }

    function resolve(address addr) constant returns(bytes32 name){
        return toName[addr];
    }
}


In [35]: solidity.compile(c)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-35-7d9906629614> in <module>()
----> 1 solidity.compile(c)

/home/work/Software/ethereum/pyethapp/.venv/local/lib/python2.7/site-packages/ethereum/_solidity.pyc in compile(cls, code, path, libraries, contract_name)
     51                 sorted_contracts[idx][1]['bin'] = sorted_contracts[idx][1]['bin'].replace(
     52                     "__{}{}".format(lib_name, "_" * (38 - len(lib_name))), lib_address)
---> 53         return sorted_contracts[idx][1]['bin'].decode('hex')
     54 
     55     @classmethod

IndexError: list index out of range

I get that there is an argument missing to the 'compile' call, but which one? What's the class that I should provide?

4
  • Have you explicitly imported the Solidity package? (Using import ethereum._solidity?) Jun 13, 2016 at 17:38
  • What version of pyethapp are you using? Apr 28, 2017 at 14:04
  • Are you using an IDE such as Spyder? If so you may have to install it for the IDE instead of your computer's python environment.
    – Fortune
    Nov 27, 2017 at 6:06
  • 1. where did you complie? 2. could you show the compelete code?
    – david fnck
    Dec 9, 2022 at 10:31

1 Answer 1

0

you need to import the solidity version. example :

pragma solidity ^0.4.18;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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