-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97f6769
commit 5c782c8
Showing
1 changed file
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# Bank模块用户文档 | ||
|
||
## 简介 | ||
该模块主要用于账户之间转账、查询账户余额,同时提供了通用的签名方法,此外,irisnet使用[coin_type](./basic-concepts/coin-type.md)定义了iris-hub系统中代币的可用单位。 | ||
|
||
## 使用场景 | ||
|
||
1. 查询某一代币coin_type | ||
```bash | ||
iriscli bank coin-type [coin-name] | ||
``` | ||
如coin-name为iris,将返回iris的coin_type: | ||
```json | ||
{ | ||
"name": "iris", | ||
"min_unit": { | ||
"denom": "iris-atto", | ||
"decimal": "18" | ||
}, | ||
"units": [ | ||
{ | ||
"denom": "iris", | ||
"decimal": "0" | ||
}, | ||
{ | ||
"denom": "iris-milli", | ||
"decimal": "3" | ||
}, | ||
{ | ||
"denom": "iris-micro", | ||
"decimal": "6" | ||
}, | ||
{ | ||
"denom": "iris-nano", | ||
"decimal": "9" | ||
}, | ||
{ | ||
"denom": "iris-pico", | ||
"decimal": "12" | ||
}, | ||
{ | ||
"denom": "iris-femto", | ||
"decimal": "15" | ||
}, | ||
{ | ||
"denom": "iris-atto", | ||
"decimal": "18" | ||
} | ||
], | ||
"origin": 1, | ||
"desc": "IRIS Network" | ||
} | ||
``` | ||
|
||
2. 账户查询 | ||
|
||
可以通过账户地址查询该账户的信息,包括账户余额、账户公钥、账户编号和交易序号。 | ||
```bash | ||
iriscli bank account [account address] | ||
``` | ||
|
||
3. 账户间转账 | ||
|
||
如从账户A转账给账户B10iris: | ||
```bash | ||
iriscli bank send --to [address of wallet B] --amount=10iris --fee=0.004iris --from=[key name of wallet A] --chain-id=[chain-id] | ||
``` | ||
iris网络支持多种代币流通,在将来iris可以在同一交易个包含多种代币交换——代币种类可以为任意在iris网络中注册过的coin_type。 | ||
4. 交易签名 | ||
为了提高账户安全性,iris提供离线签名保护账户的私钥。在任意交易中,使用参数--generate-only=true可以构建一个未签名的交易。使用转账交易作为示例: | ||
```bash | ||
iriscli bank send --to [address of wallet B] --amount=10iris --fee=0.004iris --from=[key name of wallet A] --generate-only=true | ||
``` | ||
将构建一个signatures为空的交易返回: | ||
```json | ||
{ | ||
"type": "auth/StdTx", | ||
"value": { | ||
"msg": [ | ||
{ | ||
"type": "cosmos-sdk/Send", | ||
"value": { | ||
"inputs": [ | ||
{ | ||
"address": "faa1ydhmma8l4m9dygsh7l08fgrwka6yczs0gkfnvd", | ||
"coins": [ | ||
{ | ||
"denom": "iris-atto", | ||
"amount": "100000000000000000000" | ||
} | ||
] | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"address": "faa1ut8aues05kq0nkcj3lzkyhk7eyfasrdfnf7wph", | ||
"coins": [ | ||
{ | ||
"denom": "iris-atto", | ||
"amount": "100000000000000000000" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"fee": { | ||
"amount": [ | ||
{ | ||
"denom": "iris-atto", | ||
"amount": "40000000000000000" | ||
} | ||
], | ||
"gas": "200000" | ||
}, | ||
"signatures": null, | ||
"memo": "" | ||
} | ||
} | ||
``` | ||
将结果保存到文件。 | ||
|
||
发送签名交易: | ||
```bash | ||
iriscli bank sign [file] --chain-id=[chain-id] --name [key name of from account] | ||
``` | ||
将返回已签名的交易: | ||
```json | ||
{ | ||
"type": "auth/StdTx", | ||
"value": { | ||
"msg": [ | ||
{ | ||
"type": "cosmos-sdk/Send", | ||
"value": { | ||
"inputs": [ | ||
{ | ||
"address": "faa1ydhmma8l4m9dygsh7l08fgrwka6yczs0gkfnvd", | ||
"coins": [ | ||
{ | ||
"denom": "iris-atto", | ||
"amount": "100000000000000000000" | ||
} | ||
] | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"address": "faa1ut8aues05kq0nkcj3lzkyhk7eyfasrdfnf7wph", | ||
"coins": [ | ||
{ | ||
"denom": "iris-atto", | ||
"amount": "100000000000000000000" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"fee": { | ||
"amount": [ | ||
{ | ||
"denom": "iris-atto", | ||
"amount": "40000000000000000" | ||
} | ||
], | ||
"gas": "200000" | ||
}, | ||
"signatures": [ | ||
{ | ||
"pub_key": { | ||
"type": "tendermint/PubKeySecp256k1", | ||
"value": "A+qXW5isQDb7blT/KwEgQHepji8RfpzIstkHpKoZq0kr" | ||
}, | ||
"signature": "5hxk/R81SWmKAGi4kTW2OapezQZpp6zEnaJbVcyDiWRfgBm4Uejq8+CDk6uzk0aFSgAZzz06E014UkgGpelU7w==", | ||
"account_number": "0", | ||
"sequence": "11" | ||
} | ||
], | ||
"memo": "" | ||
} | ||
} | ||
``` | ||
将结果保存到文件。 | ||
|
||
5. 广播交易 | ||
|
||
广播离线产生的已签名的交易,使用步骤4中最终生成的文件提交该交易: | ||
```bash | ||
iriscli bank broadcast [file] | ||
``` | ||
该交易将在iris网络中广播并执行。 | ||
|