Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Populus "Hello World" tutorial #4

Open
ebloc opened this issue Apr 27, 2017 · 16 comments
Open

Populus "Hello World" tutorial #4

ebloc opened this issue Apr 27, 2017 · 16 comments

Comments

@ebloc
Copy link
Collaborator

ebloc commented Apr 27, 2017

Populus is a smart contract development framework for the Ethereum blockchain. (http://populus.readthedocs.io/en/latest/quickstart.html#installation)

Debian, Ubuntu:

sudo apt-get install libssl-dev python-pip

OSX

brew install pkg-config libffi autoconf automake libtool openssl

Then:

sudo pip install populus

Initializing a new project:

[~] mkdir populus_workspace && cd populus_workspace

[~/populus_workspace] populus init
Created Directory: ./contracts
Created Example Contract: ./contracts/Greeter.sol
Created Directory: ./tests
Created Example Tests: ./tests/test_greeter.py

[~/populus_workspace] cat contracts/Greeter.sol
contract Greeter {
    string public greeting;

    function Greeter() {
        greeting = 'Hello';
    }

    function setGreeting(string _greeting) public {
        greeting = _greeting;
    }

    function greet() constant returns (string) {
        return greeting;
    }
}

[~/populus_workspace] cat tests/test_greeter.py
def test_greeter(chain, accounts):
    greeter = chain.get_contract('Greeter')

    account = accounts[0];
    print(account);

    greeting = greeter.call().greet()
    assert greeting == 'Hello'


def test_custom_greeting(chain):
    greeter = chain.get_contract('Greeter')

    set_txn_hash = greeter.transact().setGreeting('Guten Tag')
    chain.wait.for_receipt(set_txn_hash)

    greeting = greeter.call().greet()
    assert greeting == 'Guten Tag'
    print(greeting);  #added later.

[~/populus_workspace] py.test --capture=fd tests/test_greeter.py -s
===================================== test session starts =====================================
platform darwin -- Python 2.7.13, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /Users/alper/den, inifile:
plugins: populus-1.4.2
collected 2 items
.Guten Tag
.
================================== 2 passed in 1.52 seconds ===================================

_Copied from original issue: avatar-lavventura/ethereum#4_
@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @ktasyaran on March 9, 2017 10:10

I installed populus but it gives that when I write populus init in populus_workspace:

AttributeError: module 'anyconfig' has no attribute 'to_container'

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 9, 2017 14:3

python -V ne donduruyor? (?=) Python 2.7.13 @ktasyaran

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 9, 2017 14:24

I have updated the installation on the guide I guess you were using mac, can you try this: brew install pkg-config libffi autoconf automake libtool openssl @ktasyaran

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @ktasyaran on March 9, 2017 20:2

python -V returns python 2.7.10 @avatar-lavventura. Does it make a difference?
And I realized that it won't work on solidity 0.4.9. And finally, what is a difference between pyethapp and pyethereum?

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 9, 2017 20:21

I am working on the revert solc 0.4.9 to 0.4.8 but having some problems to fix it. https://github.com/pipermerriam/populus/issues/266 @ktasyaran

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 11, 2017 18:37

@ktasyaran I fixed the installation and update the guided. Could you try again to install from beginning.

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @ktasyaran on March 11, 2017 20:2

I tried now. I realized that you do not have to install solidity via downloading tar for mac users who use Homebrew. It holds both 0.4.8 and 0.4.9 for now. Also populus did not accept with web3 3.5.2 after writing populus init. It wanted 3.7.1. I tried with 3.7.1 and it passed tests. @avatar-lavventura

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 11, 2017 22:28

Did you just done brew install solidity? @ktasyaran

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @ktasyaran on March 11, 2017 23:49

brew install solidity gives latest which is 0.4.9.

For 0.4.8, you need to do this:
brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/77cce03da9f289e5a3ffe579840d3c5dc0a62717/solidity.rb
@avatar-lavventura

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 11, 2017 23:59

Thanks, I added that to installation guide. @ktasyaran

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 12, 2017 0:4

Did you updated the SOLC_BINARY, LD_LIBRARY_PATH and $PATH? Yapmana gerek yok galiba solc 0.4.8, solc 0.4.9 un ustune yazmis olmasi gerekiyor. @ktasyaran

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @ktasyaran on March 12, 2017 0:8

No. Just installed with command written above. Still I can run solidity anywhere in my computer. Therefore, I didn't update paths. I think this path adjustments are for running solidity globally instead of running only in build folder. Am I wrong?

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 12, 2017 0:10

What does solc --version returns?

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @ktasyaran on March 12, 2017 0:10

Version: 0.4.8+commit.60cc1668.Darwin.appleclang

@ebloc
Copy link
Collaborator Author

ebloc commented Apr 27, 2017

From @avatar-lavventura on March 12, 2017 0:14

Great, your system overwritten 04.8 onto 0.4.9 that's why you didn't have to update the paths. On ubuntu it require some additional work to do in order to target build folder for 0.4.8.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants