While I managed to get started using
But that is the nature of the language.
I have always been more comfortable with python than JS. I liked and have used
py.test in my previous projects. So when I had an option to test my smart contracts using
py.test, I definitely was gonna give it a try.
That is when I came across
populus. Turns out it aims to be “truffle for pythonistas” (my words, not the “official” tagline, but they can use it.)
Initially it was a personal project — which was officially adopted by ethereum organization (on github) adding credibility to the excellent work done so far.
You can read the official documentation here
As I mentioned earlier, I came for the chance to use
py.test for testing the smart contracts.
Writing the tests (along with
web3.py) was quite easy.
Running the tests in not
populus test (like
truffle test). As I mentioned earlier, it is via
py.test. So it is
.. and this is where I ran into a “glitch”.
One thing I liked about using
py.test was that I did not require to explicitly start
truffle test testrpc or
geth is required to be run explicitly. Else you get the following error:
$ truffle test
Could not connect to your Ethereum client. Please check that your Ethereum client:
- is running
- is accepting RPC connections (i.e., "--rpc" option is used in geth)
- is accessible over the network
- is properly configured in your Truffle configuration file (truffle.js)
I’m not saying that there is anything is wrong in that, just that it is nice to omit a step.
One more nice feature
populus has over
truffle is the ability to create local
This can be done easily with
populus chain new <chain_name>
This does several of the following things :
genesis.json(Usually one needs to create this by hand, or copy an existing one from “somewhere” and modify)
init_chain.sh) and other to start the “node” (
Benefit of this is that a new developer does not need to understand the complexities of various options in both
genesis.json and the long list of command line options to
It just works.
This is useful to semi-experienced developer as well. She can modify the
genesis.json and the scripts as required.
Since there is no “change password” concept, one can not create a “better” password without removing the existing account and recreating a new one. This means you need to modify the
run_chain.sh script, since it mentions an account for the
--unlock parameter. One also needs to modify
genesis.json since the “pre-populated” account is mentioned there under
But that is OK, since
populus is meant for the development anyway.
Read the detailed tutorial about using populus to create local chains here
There is also
populus chain reset <chain_name> but it doesn’t work. I’ve filed an issue here
For simple, one-off contracts, there is a command line version :
For a slightly complex deployments, especially when one needs to pass arguments to the Contract constructor, one needs to write their own python code.
This is no different than writing migrations scripts in
truffle land, except there one gets “default” scripts on
truffle init, here we don’t.
Read details here
populus had this feature in older version, but it was removed. when asked on gitter, I was told that there is a plan to “bring them back” See this
While I wanted to use
populus as the only option, I think it is behind the “maturity” compared to
For now, I use
truffle for the project I share with others (since
truffle seems to be more “well known”) but for my “personal” project, I will continue to use
populus (and report issues, discuss on gitter and send in the PR if/where I can)
Note : You can view my (work-in-progress) code here. It has both
truffle as well as
populus config files. The tests are only in python. I do have a deployment script in python.
Originally published at mandarvaze.bitbucket.io on March 20, 2018.
Create your free account to unlock your custom reading experience.