Giter Club home page Giter Club logo

xuper-python-sdk's Introduction

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)

xuper-python-sdk's People

Contributors

fxsjy avatar toworld avatar wenjingli729 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xuper-python-sdk's Issues

pysdk.system_status()无法执行

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shikunming/miniconda3/lib/python3.9/site-packages/xuper/client.py", line 290, in system_status
    rsps_obj = json.loads(rsps.content)
  File "/Users/shikunming/miniconda3/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Users/shikunming/miniconda3/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/shikunming/miniconda3/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

远程主机强迫关闭了一个现有的连接

Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "C:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files\Python37\lib\http\client.py", line 1321, in getresponse
response.begin()
File "C:\Program Files\Python37\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "C:\Program Files\Python37\lib\http\client.py", line 257, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Program Files\Python37\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

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.