Skip to content

xuperchain/xuper-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pythonsdk

requirements

python2.7 python3.x

ecdsa
requests

quick start

pip install xuper

start server

1.  启动xchain
nohup ./xchain &
2.  启动http网关
nohup ./xchain-httpgw &

A wallet demo on python sdk

WalletDemo

Demo of python SDK

pysdk = xuper.XuperSDK("http://localhost:8098", "xuper")
pysdk.readkeys("./data/keys")

#1. 普通转账
pysdk.transfer("bob", 88888, desc="hello world")

#2. 创建合约账号
new_account_name = pysdk.new_account()
print("wait acl confirmed....")
time.sleep(3)

#3. 部署合约
pysdk.transfer(new_account_name, 10000000, desc="start funds")
pysdk.set_account(new_account_name)
contract_name = 'counter'+str(random.randint(100,1000000))
print("deploying......")
rsps = pysdk.deploy(new_account_name, contract_name, open('./data/wasm/counter.wasm','rb').read(), {'creator':b'baidu'})
print(rsps)

#4. 预执行合约
rsps = pysdk.preexec(contract_name, "get", {"key":b"counter"})
print(rsps.decode())

#5. 调用合约并生效上链
for i in range(5):
        rsps = pysdk.invoke(contract_name, "increase", {"key":b"counter"})
        print(rsps)

About

Pure python sdk for XuperChain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published