ebloc / eBloc

http://ebloc.cmpe.boun.edu.tr/
Apache License 2.0
1 stars 2 forks source link

Populus "Hello World" tutorial #4

Open ebloc opened 7 years ago

ebloc commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

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

ebloc commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

pyethapp vs pyethereum: http://ethereum.stackexchange.com/questions/5769/whats-the-difference-between-pyethapp-and-pyethereum @ktasyaran

ebloc commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

Did you just done brew install solidity? @ktasyaran

ebloc commented 7 years ago

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 commented 7 years ago

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

Thanks, I added that to installation guide. @ktasyaran

ebloc commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

What does solc --versionreturns?

ebloc commented 7 years ago

From @ktasyaran on March 12, 2017 0:10

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

ebloc commented 7 years ago

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.