账号类交易

创建账号

井通账号是非对称密码学上的公钥和私钥的编码,用户可以随时生成新的账号。但是在井通系统中,账号需要有在井通系统登记后才能使用系统功能。这一过程是通过井通系统内的已有账号支付一定量的井通(SWT)实现新账号的登记,也称之为“激活”。

商户可以通过商户银关进行账号的激活,银关需先配置具有一定数量的SWT来完成多个账号的激活。系统默认的最小激活值是25 SWT, 银关可以设置比这个值大的激活值。

账号是用户在区块链系统的操作对象,用户可以通过静态方法创建一个新的井通账号,也可以通过已有的账号的密钥生成一个账号,又称为钱包。 通过已经激活的井通账号可以直接生成账号对象,从而实现井通系统中一系列相应的操作,如支付数字资产,挂单数组资产,以及查询账号的。生成账号时必需提供账号私钥。公钥则可以省略, 由SDK通过私钥计算生成。如果同时提供私钥和公钥,那么输入时私钥在前,公钥在后。

Java Example

// get fingate instance
FinGate fingate = FinGate.getInstance();
// set fingate account
fingate.setAccount("snqFcH......pQYzxEEbW");
// set development mode(optional)
fingate.setMode(FinGate.DEVLOPMENT);
// set fingate parameters(optional)
fingate.setActiveAmount(25);

// method 1. create account from fingate
Wallet wallet1 = fingate.createWallet();

// activate it
fingate.activateWallet(wallet1.getAddress(), new PaymentListener() {
    @override
    public void onComplete(result) {
    }
});

// method 2. create account from secret
Wallet wallet2 = new Wallet("snqFcH......pQYzxEEbW");

Python Example

# get fingate instance
fingate = FinGate();
# set fingate account
fingate.setAccount("snqFcH......pQYzxEEbW");
# set development mode(optional)
fingate.setMode(FinGate.DEVLOPMENT);
# set fingate parameters(optional)
fingate.setActiveAmount(25);

# method 1. create account from fingate
wallet1 = fingate.createWallet();

// activate it
fingate.activateWallet(wallet1.address, callback);

// method 2. create account from secret
wallet2 = Wallet("snqFcH......pQYzxEEbW");

PHP Example

// get fingate instance
$fingate = FinGate::getInstance();
// set fingate account
$fingate->setAccount("snqFcH......pQYzxEEbW");
// set development mode(optional)
$fingate->setMode($fingate->modes::DEVLOPMENT);
// set fingate parameters(optional)
$fingate->setActiveAmount(25);

// method 1. create account from fingate
$wallet1 = $FinGate->createWallet();

// activate it
$fingate->activateWallet($wallet1->getAddress(), $callback);

// method 2. create account from secret
$wallet2 = new Wallet('snqFcH......pQYzxEEbW');

Node.JS Example

// get fingate instance
var fingate = require('jingtum-sdk').FinGate;
// set fingate account
fingate.setAccount("snqFcH......pQYzxEEbW");
// set development mode(optional)
fingate.setMode(FinGate.DEVLOPMENT);
// set fingate parameters(optional)
fingate.setActiveAmount(25);

// method 1. create account from fingate
var wallet1 = fingate.createWallet();

// activate it
fingate.activeWallet(wallet1.address, function(err, result) {
    // process result
});

// method 2. create account from secret
var Wallet = require('jingtum-sdk').Wallet;
var wallet2 = new Wallet('shNKNNtxg......AKBFy5W5kK');

账号余额

每个账号容纳用户的资产,包括SWT资产和用户通资产。余额是一个资产列表,每个项目包括资产编码、资产数量以及资产对应的发行银关, 同时根据用户的操作每个用户的资产余额里面还有冻结项目,例如用户挂单卖出CNY,则部分的CNY被冻结了。

在井通系统中,SWT还作为用户资源占用的计数,包括账号资源占用,市场单子资源占用,关系资源占用等。例如每个账号占用10个SWT, 每个提交的货币挂单占用1SWT,每个关系资源占用1SWT等。对于初始账号,一般是占用11个SWT。

余额的查询可以使用用户通的符号进行查找,仅返回相应用户通的余额。

Java Example

// construct one wallet
Wallet my_wallet = new Wallet("snqFcH......pQYzxEEbW");

// get all balances
BalanceCollection bc = my_wallet.getBalance();

// get swt balance
BalanceCollection bc = my_wallet.getBalance("SWT");

// get usd balance
BalanceCollection bc = my_wallet.getBalance("USD");

// get specified issuer usd balance
BalanceCollection bc = my_wallet.getBalance("USD", "jMcCACcfG37xHy7.....FCk7tT");

Python Example

# construct one wallet
my_wallet = new Wallet("snqFcH......pQYzxEEbW");

# get all balances
bc = my_wallet.getBalance();

# get swt balance
bc = my_wallet.getBalance('SWT');

# get usd balance
bc = my_wallet.getBalance('USD');

# get specified issuer usd balance
bc = my_wallet.getBalance('USD', 'jMcCACcfG37xHy7.....FCk7tT');

PHP Example

 // construct one wallet
 $my_wallet = new Wallet('snwjtucx9......MbVz8hFiK9');

 // get all balances
 $bc = $my_wallet->getBalance();

 // get swt balance
 $bc = $my_wallet->getBalance("SWT");

 // get usd balance
 $bc = $my_wallet->getBalance("USD");

 // get specified issuer usd balance
$bc = $my_wallet->getBalance('USD','jMcCACcfG37xHy7.....FCk7tT');

Node.JS Example

var Wallet = require('jingtum-sdk').Wallet;
// construct one wallet
var my_wallet = new Wallet('shNKNxg......AKBFy5W5kK');

// get all balances
my_wallet.getBalance(function (err, data) {
    // process balance
});

// get swt balance
my_wallet.getBalance('SWT', function(err, data) {
    // process balance
});

// get usd balance
my_wallet.getBalance('USD', function(err, data) {
    // process balance
});

// get specified issuer usd balance
my_wallet.getBalance('USD', 'jMcCACcfG......vjLM5FCk7tT', function(err, data) {
    // process balance
});