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:
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_
Populusis a smart contract development framework for the Ethereum blockchain. (http://populus.readthedocs.io/en/latest/quickstart.html#installation)Debian, Ubuntu:
OSX
Then:
Initializing a new project: