Welcome to pyetheroll’s documentation!

Readme

pyetheroll

Build Status Coverage Status PyPI version Documentation Status

Python library to Etheroll smart contract

Usage

Simply set bet size, chances and wallet settings before rolling:

from pyetheroll.etheroll import Etheroll

etheroll = Etheroll()
bet_size_ether = 0.1
bet_size_wei = int(bet_size_ether * 1e18)
chances = 50
wallet_path = 'wallet.json'
wallet_password = 'password'

transaction = etheroll.player_roll_dice(
    bet_size_wei, chances, wallet_path, wallet_password)

It’s also possible to set different contract address and chain ID:

from pyetheroll.constants import ChainID
from pyetheroll.etheroll import Etheroll

chain_id = ChainID.ROPSTEN
contract_address = '0xe12c6dEb59f37011d2D9FdeC77A6f1A8f3B8B1e8'
etheroll = Etheroll(chain_id, contract_address)

Find out more in docs/Examples.md.

API keys

Both Etherscan and Infura require API keys which are retrieved from the following environment variables:

  • ETHERSCAN_API_KEY (consumed by pyetheroll directly)
  • WEB3_INFURA_PROJECT_ID (consumed by web3.py)

Install

Latest stable release:

pip install pyetheroll

Development branch:

pip install --process-dependency-links \
https://github.com/AndreMiras/pyetheroll/archive/develop.zip

Examples

Here is a list of common things the library can help with.

Get address last rolls

Basically what you need is the Etheroll.get_last_bets_transactions() method. See example rolls2csv.py for a detailed example.

Read contract

Access the web3 contract directly from the Etheroll instance:

etheroll = Etheroll()
min_bet = etheroll.contract.functions.minBet().call()

How to release

This is documenting the release process.

Git flow & CHANGELOG.md

Make sure the CHANGELOG.md is up to date and follows the http://keepachangelog.com guidelines. Start the release with git flow:

git flow release start YYYYMMDD

Now update the CHANGELOG.md [Unreleased] section to match the new release version. Also update the version string in the setup.py file. Then commit and finish release.

git commit -a -m "YYYYMMDD"
git flow release finish

Push everything, make sure tags are also pushed:

git push
git push origin master:master
git push --tags

Publish to PyPI

This process is handled automatically by Travis. If needed below are the instructions to perform it manually. Build it:

make release/build

Check archive content:

tar -tvf dist/pyetheroll-*.tar.gz

Upload:

make release/upload

This will also publish the alias meta package setup_meta.py.

Check Read the Docs

Make sure https://readthedocs.org/projects/pyetheroll/ is up to date.

GitHub

Got to GitHub Release/Tags, click “Add release notes” for the tag just created. Add the tag name in the “Release title” field and the relevant CHANGELOG.md section in the “Describe this release” textarea field. Finally, attach the generated APK release file and click “Publish release”.

CHANGELOG

Change Log

[20200322]

  • Automate PyPI deployment, refs #10
  • Add Python3.8 support, refs #11

[20200320]

  • Move API keys to env var, refs #9

[20191108]

  • Fix Ropsten 403 errors

[20191107]

  • API key refactoring

[20191018]

  • Change units to WEI
  • Add transaction() helper
  • Add Python3.7 support
  • Introduce Makefile, refs #4 and #5
  • Fix timestamp conversion bug, refs #6
  • Setup coverage testing, refs #7
  • Migrate to web3 v5, refs #8

[20190321]

  • Add readthedocs Sphinx documentation, refs #2
  • Improve setup, refs #3
  • Condigurable API key

[20181031]

  • Remove legacy pyetherapp & pyethereum dependencies
  • Migrate to pipenv, refs #1
  • Improve install from setup.py

[20181030]

  • Add tox testing
  • Enable Travis CI
  • Installable module

[v20181029]

  • Initial release import from EtherollApp v20181028

Indices and tables