Giter VIP home page Giter VIP logo

kadenapythonsdk's Introduction

To Use

from kadena_sdk import KadenaSdk, KeyPair

# Create your keypair and setup the SDK with the endpoint you desire in life.
key_pair = KeyPair(type='json',
  priv_key='5e8b125c89ed409f2cfcc6e863e8aafd60b9d80a4d2333a12592f7a961a62bf8',
  pub_key='ad273a54460305767e2e36f41d1a5fe78c48474a6e3bc18624d53fbbbb5974bb')

# base_url will default to https://api.testnet.chainweb.com
# KeyPair isn't required, but no sigs will be included in any local/send calls
kadena = KadenaSdk(base_url='https://api.chainweb.com',
  key_pair=key_pair)

# Very open ended: Work directly with the payload.
payload = kadena.build_exec_payload(
  '(format "{}" [(read-msg "test")])', 
  env_data={'test': 'hello'}
)

# SDK works with whichever chains you choose!
chain_ids = ['0', '1']

# Commands is a dictionary where each key is the chain id and the value
# is the command to be sent
cmds = kadena.build_command(payload, chain_ids)

# You can use local or send to dirty read or commit respectively.
# These are the /local and /send endpoints.
res = kadena.local(cmds)

# Responses are in a dictionary with keys being the chains 
# that were interacted with
print(res['0'].json())

# You can also listen to commands. This is a blocking command.
# Pass in the transaction id and the chain you want to listen on.
kadena.listen('tx_id', '0')

## Lastly, if you want to just run some pact code, you can do so
res = kadena.run_pact(
  '(format "Test {}" [(read-msg "test")])', 
  env_data={'test': 'hello'}
)

To Build and Deploy

python3 -m build
python3 -m twine upload dist/*

To Test

pytest

kadenapythonsdk's People

Stargazers

 avatar Dave Merwin avatar Egeo Minotti avatar

Watchers

Sterling Long avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.