Skip to main content

Taraxa blockchain RPC client.

Project description

taraxa-py

Taraxa RPC client in python.

taraxa-py pypi address: taraxa-py

Taraxa official website: taraxa.io

install

install from source code.

git clone https://github.com/Taraxa-project/taraxa-py
cd taraxa-py
python setup.py install

or install from pypi pytaraxa.

pip install taraxa-py

config

default parameters:

config={
    "host":"127.0.0.1",  
    "port":7777,  
    "jsonrpc":2.0,  
    "id":1
}

for all methods, if no parameter given, default will be used.

  1. package level config set and reset.
    any of below config will influence the whole packge.
    import pytaraxa.jsonrpc as rpc
    import pytaraxa.eth as eth
    import pytaraxa.taraxa as taraxa
    import pytaraxaa.net as net
    
    rpc.set({
        "host":"127.0.0.1",  
        "port":7777,  
        "jsonrpc":2.0,  
        "id":1 
    })
    
    eth.set({
        "host":"35.224.183.106",  
    })
    taraxa.set({
        "host":"35.224.183.106",  
    })
    net.set({
        "host":"35.224.183.106",  
    })
    
    rpc.reset()
    eth.reset()
    taraxa.reset()
    net.reset()
    
  2. function level config set
    function level config set only influence the function it self once.
    import pytaraxa.eth as eth
    r=eth.blockNumber(host='127.0.0.1' ,port=7777)
    print(r)
    

usage

  • 1.low level use
    input data can be json string or dict.
    response is json string.

    import pytaraxa.jsonrpc as rpc
    data = '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
    r = rpc.send(data)
    print(r)
    
    data = {"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}
    r = rpc.send(data)
    print(r)
    
  • 2.middle level use
    response is json string.

    from pytaraxa.jsonrpc  import *
    r = eth_blockNumber()
    print(r)
    
  • 3.high level use
    response is parsed to python types.

    import pytaraxa.eth as eth
    r = eth.blockNumber()
    print(r)
    
  • 4.ethereum web3.py like use

    import pytaraxa import web3
    
    w3 = web3.Web3(host="127.0.0.0" ,port=7777)
    r = w3.eth.blockNumber()
    print(r)
    
    w3.host = "35.224.183.106"
    w3.port = 7778
    r = w3.eth.blockNumber()
    print(r)
    

    object w3 of class Web3 will hold the host and port once you set until you reset it to default.

sub packages

  • jsonrpc
  • eth
  • web3
  • net
    TODO
  • admin
    TODO
  • admmin_net
    TODO
  • debug
    TODO
  • test
    TODO

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 taraxa-py, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size taraxa_py-0.0.6-py3-none-any.whl (23.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size taraxa-py-0.0.6.tar.gz (15.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page