-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R4R: user guide for bank #648
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# Bank User Guide | ||
|
||
## Introduction | ||
This module is mainly used to transfer coins between accounts、query account balances, and provide a common offline transaction signing and broadcasting method. In addition, the available units of tokens in the IRIShub system are defined using [coin_type](./basic-concepts/coin-type.md). | ||
|
||
## Usage Scenario | ||
|
||
1. Query the coin_type configuration of a certain token: | ||
```bash | ||
iriscli bank coin-type [coin-name] | ||
``` | ||
For example, coin_type of iris will be returned if the coin-name is iris: | ||
```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. Query account | ||
|
||
Query the account information of a certain account address, including the balance, the public key, the account number and the transaction number. | ||
```bash | ||
iriscli bank account [account address] | ||
``` | ||
|
||
3. Transfer between accounts | ||
|
||
For example, transfer 10iris from account A to account B: | ||
```bash | ||
iriscli bank send --to [address of wallet B] --amount=10iris --fee=0.004iris --from=[key name of wallet A] --chain-id=[chain-id] | ||
``` | ||
IRISnet supports multiple tokens in circulation, and in the future IRISnet will be able to include multiple tokens in one transaction -- tokens can be any coin_type registered in IRISnet. | ||
|
||
4. Sign transactions generated offline | ||
|
||
To improve account security, IRISnet supports offline signing of transactions to protect the account's private key. In any transaction, you can build an unsigned transaction using the flag --generate-only=true. Use transfer transactions as an example: | ||
```bash | ||
iriscli bank send --to [address of wallet B] --amount=10iris --fee=0.004iris --from=[key name of wallet A] --generate-only=true | ||
``` | ||
Return the built transaction with empty 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": "" | ||
} | ||
} | ||
``` | ||
Save the result to a file. | ||
|
||
Send signature transaction: | ||
```bash | ||
iriscli bank sign [file] --chain-id=[chain-id] --name [key name] | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
Return signed transactions: | ||
```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": "" | ||
} | ||
} | ||
``` | ||
Save the result to a file. | ||
|
||
5. Broadcast transactions | ||
|
||
Broadcast offline signed transactions. Here you can just use the transaction generated by above sign command. Of course, you can generate your signed transaction by any methods, eg. [irisnet-crypto](https://github.com/irisnet/irisnet-crypto). | ||
```bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! |
||
iriscli bank broadcast [file] | ||
``` | ||
The transaction will be broadcast and executed in IRISnet. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# Bank模块用户文档 | ||
|
||
## 简介 | ||
该模块主要用于账户之间转账、查询账户余额,同时提供了通用的离线签名与交易广播方法,此外,使用[coin_type](./basic-concepts/coin-type.md)定义了IRIShub系统中代币的可用单位。 | ||
|
||
## 使用场景 | ||
|
||
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] | ||
``` | ||
IRISnet支持多种代币流通,将来IRISnet可以在一个交易中包含多种代币交换——代币种类可以为任意在IRISnet中注册过的coin_type。 | ||
|
||
4. 交易签名 | ||
|
||
为了提高账户安全性,IRISnet支持交易离线签名保护账户的私钥。在任意交易中,使用参数--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] | ||
``` | ||
将返回已签名的交易: | ||
```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. 广播交易 | ||
|
||
广播离线产生的已签名的交易,在这里,你可以使用上面的sign命令生成的交易。当然,您可以通过任何方法生成已签名的交易,例如:[irisnet-crypto](https://github.com/irisnet/irisnet-crypto)。 | ||
```bash | ||
iriscli bank broadcast [file] | ||
``` | ||
该交易将在IRISnet中广播并执行。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add signature to this transaction