Skip to content

Commit

Permalink
doc(tx): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lnkyan committed Aug 24, 2020
1 parent 8fefc14 commit fb8b181
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ API | description | asynchronous | available for remote
[lemo.account.isContractAddress(address)](#submodule-account-isContractAddress) | True if the current address is a contract account | ✖ | ✓
[lemo.account.getVoteFor(addr)](#submodule-account-getVoteFor) | Get voting information for the current account | ✓ | ✓
[lemo.account.getAssetEquity(addr, assetId)](#submodule-account-getAssetEquity) | Get the proceeds from the account | ✓ | ✓
[lemo.tx.send(signedTxInfo, privateKey)](#submodule-tx-send) | Send transaction | ✓ | ✓
[lemo.tx.send(txConfig, privateKey)](#submodule-tx-send) | Send transaction | ✓ | ✓
[lemo.tx.waitConfirm(txHash)](#submodule-tx-waitConfirm) | wait for the transaction to be confirmed | ✓ | ✓
[lemo.tx.watchTx(filterTxConfig, callback)](#submodule-tx-watchTx) | listen and filter for transaction of block | ✖ | ✓ |
[lemo.tx.stopWatchTx(subscribeId)](#submodule-tx-stopWatchTx) | Stop listening transaction | ✖ | ✓ |
Expand Down Expand Up @@ -1219,16 +1219,16 @@ lemo.tx.send(txConfig, privateKey)
Send a transaction

##### Parameters
1. `object|string` - Unsinged [transaction](#data-structure-transaction) information. Or a [LemoTx](https://github.com/LemoFoundationLtd/lemo-tx) object or json string.
1. `LemoTx|object|string` - Signed or unsigned [transaction](#data-structure-transaction) information. Or a [LemoTx](https://github.com/LemoFoundationLtd/lemo-tx) object or json string.
2. `string` - (optional) Account private key, it will be used to sign if exist

##### Returns
`Promise` - Call `then` method to get transaction hash

##### Example
```js
const txInfo = {from: 'Lemo83GN72GYH2NZ8BA729Z9TCT7KQ5FC3CR6DJG', to: 'Lemo83BYKZJ4RN4TKC9C78RFW7YHW6S87TPRSH34', amount: 100}
lemo.tx.send(txInfo, '0xc21b6b2fbf230f665b936194d14da67187732bf9d28768aef1a3cbb26608f8aa').then(function(txHash) {
const txConfig = {from: 'Lemo83GN72GYH2NZ8BA729Z9TCT7KQ5FC3CR6DJG', to: 'Lemo83BYKZJ4RN4TKC9C78RFW7YHW6S87TPRSH34', amount: 100}
lemo.tx.send(txConfig, '0xc21b6b2fbf230f665b936194d14da67187732bf9d28768aef1a3cbb26608f8aa').then(function(txHash) {
console.log(txHash) // 0x03fea27a8d140574dc648e1cb1a198f5ade450a347095cff7f3d961a11dac505
})
```
Expand Down
25 changes: 14 additions & 11 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ lemo.chain.getBlockByNumber(0).then(function(block) {
| [lemo.account.createTempAddress(from, userId)](#submodule-account-createTempAddress) | 创建临时账户 |||
| [lemo.account.isTempAddress(address)](#submodule-account-isTempAddress) | 是否是临时账户 |||
| [lemo.account.isContractAddress(address)](#submodule-account-isContractAddress) | 是否是合约账户 |||
| [lemo.tx.send(signedTxInfo)](#submodule-tx-send) | 发送已签名的交易 |||
| [lemo.tx.send(txConfig)](#submodule-tx-send) | 发送交易 |||
| [lemo.tx.waitConfirm(txHash)](#submodule-tx-waitConfirm) | 等待交易上链 |||
| [lemo.tx.watchTx(filterTxConfig, callback)](#submodule-tx-watchTx) | 监听过滤区块的交易 |||
| [lemo.tx.stopWatchTx(subscribeId)](#submodule-tx-stopWatchTx) | 停止指定交易 |||
Expand Down Expand Up @@ -1408,14 +1408,11 @@ console.log(JSON.stringify(result)) // {"term":0,"value":"1000000000","rewardHei
lemo.tx.send(txConfig)
```

发送已签名的交易
发送交易

##### Parameters

1. `object|string` - 签名后的[交易](#data-structure-transaction)信息,可以是对象形式也可以是[`lemo.tx.sign`](#submodule-tx-sign)返回的字符串形式
相对于[`lemo.tx.sendTx`](#submodule-tx-sendTx)中的交易信息少了`type``version`字段,并多出了以下字段
- `sig` - (string) 交易签名字段
- `gasPayerSig` - (string) 代付gas交易签名字段
1. `LemoTx|object|string` - 签过名或未签名的[交易](#data-structure-transaction)信息,可以是对象形式也可以是[`lemo.tx.sign`](#submodule-tx-sign)返回的字符串形式

##### Returns

Expand All @@ -1424,11 +1421,17 @@ lemo.tx.send(txConfig)
##### Example

```js
const txInfo = {from: 'Lemo83GN72GYH2NZ8BA729Z9TCT7KQ5FC3CR6DJG', to: 'Lemo83BYKZJ4RN4TKC9C78RFW7YHW6S87TPRSH34', amount: 100}
const signedTx = lemo.tx.sign('0xc21b6b2fbf230f665b936194d14da67187732bf9d28768aef1a3cbb26608f8aa', txInfo)
lemo.tx.send(signedTx).then(function(txHash) {
console.log(txHash) //0x03fea27a8d140574dc648e1cb1a198f5ade450a347095cff7f3d961a11dac505
})
const txConfig = {from: 'Lemo83GN72GYH2NZ8BA729Z9TCT7KQ5FC3CR6DJG', to: 'Lemo83BYKZJ4RN4TKC9C78RFW7YHW6S87TPRSH34', amount: 100}
lemo.tx.send(txConfig, '0xc21b6b2fbf230f665b936194d14da67187732bf9d28768aef1a3cbb26608f8aa').then(function(txHash) {
console.log(txHash) // 0x03fea27a8d140574dc648e1cb1a198f5ade450a347095cff7f3d961a11dac505
})
```
```js
const tx = new LemoTx({chainID: 100, from: 'Lemo83GN72GYH2NZ8BA729Z9TCT7KQ5FC3CR6DJG', to: 'Lemo83BYKZJ4RN4TKC9C78RFW7YHW6S87TPRSH34', amount: 100})
tx.signWith('0xc21b6b2fbf230f665b936194d14da67187732bf9d28768aef1a3cbb26608f8aa')
lemo.tx.send(tx).then(function(txHash) {
console.log(txHash) // 0x03fea27a8d140574dc648e1cb1a198f5ade450a347095cff7f3d961a11dac505
})
```

---
Expand Down

0 comments on commit fb8b181

Please sign in to comment.