Skip to main content

sdk for asimov chain

Project description


This document describes how to develop python script to test and deploy contracts on Asimov using high level Python API.


Install Python Environment

Before running python script, you need to install python and set up your virtual environment. Follow instructions on and pyenv to finish the installation. Asimov Python SDK has been fully tested on Python 3.7+.

Install secp256k1

It is an optimized C library for EC operations on curve secp256k1. Follow instructions on specp256k1 to finish the installation.

You need to install automake on MacOS to run the scripts in secp256k1. Run brew install automake.

Note: If you see the error message like Cannot import secp256k1: cannot open shared object file... when execute pip install py-asimov. You can add LIBDIR to the LD_LIBRARY_PATH environment variable like export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib on Fedora/CentOS/RHEL. (Let's assume LIBDIR is /usr/local/lib in this case).

Install gmp for fastecdsa

Py-Asimov use fastecdsa library for fast elliptic curve crypto. Note that you need to have a C compiler. You also need to have GMP on your system as the underlying C code in this package includes the gmp.h header (and links against gmp via the -lgmp flag). You can install all dependencies as follows:


$ apt-get install python-dev libgmp3-dev


$ yum install python-devel gmp-devel


$ brew install gmp

Install Asimov Python SDK

pip install -i py-asimov

We provide high level Python API through Python SDK. Please visit Python API to read api specifications.

Install Asimov Smart Contract Compiler

Follow instructions on Asimov to finish the installation.


We provide a to cover the most used functions in Python SDK, including submit template, deploy contract, execute/vote on contract methods, read contract states and check transaction status and so on.

The smart contract test against in the above script is tutorial.sol.

Initialize Node Instance

from asimov import Node

node = Node() 

Setup RPC Server and Private Key

# set rpc server

# set private key
node.set_private_key("your private key")

Submit Template

from asimov import Template
from asimov.constant import SUCCESS

# initialize template instance
t = Template(node)

# submit a contract template to Asimov blockchain
tx = t.submit("./contracts/tutorial.sol", "template_name", 'Tutorial')

# make sure the transaction is confirmed on chain before moving on to next step
assert tx.check() is SUCCESS

Deploy Contract

from asimov import Contract

# deploy a contract instance to Asimov blockchain
deploy_tx, contract_address = t.deploy_contract(

# make sure the transaction is confirmed on chain before moving on to next step
assert tx.check() is SUCCESS

# initialize contract instance
contract = Contract(node, contract_address)

Execute Contract Methods

from asimov import constant

# mint asset
tx = contract.execute("mint", [10000 * constant.COIN])

# make sure the transaction is confirmed on chain and the contract execution is successful
assert tx.check() is constant.SUCCESS

# call contract's read only function.We get new asset type and convert to string type.
asset_type = Asset.asset2str("assettype"))

# transfer asset
assert contract.execute("transfer", [node.address, 100 * constant.COIN]).check() is constant.SUCCESS

Vote Contract Methods

# call the vote method to vote using the utxo asset mint in the above step
assert"vote", [88], 1, asset_type).check() is constant.SUCCESS

Developer Setup

If you would like to hack on py-asimov, please follow these steps:

  • Testing
  • Pull Requests
  • Code Style
  • Documentation

Development Environment Setup

You can set up your dev environment with:

git clone
cd pyasimov
pyenv virtualenv 3.7.3 env-asimov
pyenv activate env-asimov
pip install -e .[dev]

# If you're using zsh you need to escape square brackets: 
pip install -e .\[extra\]

Testing Setup

During development, you might like to have tests run on every file save.

# in the project root:
make test

Release setup

To release a new version:

make release bump=$$VERSION_PART_TO_BUMP$$

How to bumpversion

The version format for this repo is {major}.{minor}.{patch} for stable

To issue the next version in line, specify which part to bump, like make release bump=minor or make release bump=patch. This is typically done from the master branch. To include changes made with each release, update "docs/releases.rst" with the changes, and apply commit directly to master before release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for py-asimov, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size py_asimov-0.3.0-py3-none-any.whl (25.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py-asimov-0.3.0.tar.gz (22.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page