kseo / codechain-sdk-python

Python Software Development Kit for CodeChain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

Python Software Development Kit for CodeChain

License:ISC License


Languages

Language:Python 99.9%Language:Makefile 0.1%