Python SDK

环境准备

Python SDK建议在Ubuntu环境下使用,需要如下软件包:

1.python2.7

2.ecdsa

3.six

4.websocket-client

可通过pip install的方式直接安装如上软件包

下载安装

1、通过以下链接地址下载最新版本SDK: 请点击链接下载sdk包 github下载地址:https://github.com/jingtum/jingtum-python-sdk.git

2、安装方法: 依赖包安装完毕后,井通SDK可通过 pip 直接安装,命令如下:

pip install jingtum-sdk

程序示例

可参见https://github.com/jingtum/jingtum-python-sdk/examples下的test.py示例。

产生新的井通帐号

# init FinGate
fingate = FinGate()
fingate.setMode(FinGate.DEVLOPMENT)


# create my wallet
my_wallet = None
my_wallet = fingate.createWallet()

# Active the new wallet
# Need to setup an account with enough SWT in it.

fingate.setAccount("snqFcH......pQYzxEEbW")
fingate.setActivateAmount(25)
fingate.activateWallet(my_wallet.address, callback)

查询帐号的余额信息

# init FinGate
fingate = FinGate()
fingate.setMode(FinGate.DEVLOPMENT)

my_wallet = Wallet("shVC2gdG......gijqk4EsuqDF")
ret = my_wallet.getBalance()

使用帐号进行支付

# init FinGate
fingate = FinGate()
fingate.setMode(FinGate.DEVLOPMENT)

my_wallet = Wallet("shVC2gdG......gijqk4EsuqDF")
op = PaymentOperation(my_wallet)

op.setDestAddress('jpyyHbEWiuCA......DRrYJQzcXb')

amt = Amount(10, "CNY", test_issuer)
op.setAmount(amt)

op.setClientId("20611171957")
op.setValidate(true)

op.submit(callback)

生成挂单

# init FinGate
fingate = FinGate()
fingate.setMode(FinGate.DEVLOPMENT);

my_wallet = Wallet("shVC2gdG......gijqk4EsuqDF")
co = OrderOperation(my_wallet)
co.setPair("SWT/CNY:janxMdr...GewMMeHa9f");
co.setType(OrderOperation.SELL);
co.setAmount(20.00);
co.setPrice(0.5);
co.submit(callback)

取消挂单

# init FinGate
fingate = FinGate()
fingate.setMode(FinGate.DEVLOPMENT)

my_wallet = Wallet("shVC2gdG......gijqk4EsuqDF")
co = CancelOrderOperation(my_wallet)
co.setOrderNum(54)
co.submit(callback)