Skip to content
Python Software Development Kit for CodeChain
Python Makefile
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
codechain
examples
tests-e2e
tests
.flake8
.gitignore
.pre-commit-config-ci.yaml
.pre-commit-config.yaml
LICENSE
Makefile
Pipfile
Pipfile.lock
README.md
pyproject.yml
setup.py
tox.ini

README.md

CodeChain SDK for Python

A Python SDK for CodeChain.

API Documentation (For SDK users)

Not prepared

Getting Started (For SDK developers)

Submitting patches

  • Use Black to autoformat your code. This should be done for you as a git pre-commit hook.

First time setup

  • Clone your GitHub fork locally:
  • Add the main repository as a remote to update later:
  • Create a virtualenv using pipenv:
$ make init
  • Install the pre-commit hooks:
$ pre-commit install --install-hooks

Add dependency

  • Install the dependency using pipenv
  1. In the test environment
$ pipenv install [package] --dev
  1. In the production
$ pip3 install [package]

and specify it to the setup.py

  • lock the dependency
$ pipenv lock

Run test cases

$ make test

Usage

#!/usr/bin/python3
from codechain import SDK

sdk = SDK("http://localhost:8080", "tc")

ACCOUNT_SECRET = "ede1d4ccb4ec9a8bbbae9a13db3f4a7b56ea04189be86ac3a6a439d9a0a1addd"
ACCOUNT_ADDRESS = "tccq9h7vnl68frvqapzv3tujrxtxtwqdnxw6yamrrgd"
ACCOUNT_PASSPHRASE = "satoshi"

address = sdk.rpc.account.import_raw(ACCOUNT_SECRET, ACCOUNT_PASSPHRASE)
address = "tcaqyqckq0zgdxgpck6tjdg4qmp52p2vx3qaexqnegylk"

tx = sdk.core.create_mint_asset_transaction(
    address,
    None,
    None,
    None,
    0,
    {"name": "Silver Coin", "description": "...", "icon_url": "..."},
    None,
    None,
    None,
    100000000,
)

tx_hash = sdk.rpc.chain.send_transaction(tx, ACCOUNT_ADDRESS, ACCOUNT_PASSPHRASE)

result = sdk.rpc.chain.contains_transaction(tx_hash)
You can’t perform that action at this time.