Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
add sender for rpc api (#1130)
Browse files Browse the repository at this point in the history
* add sender for rpc api

* update sendmany

* updated

* Update sendmany.md

Co-authored-by: celiayu <[email protected]>
  • Loading branch information
ProDog and Celia18305 authored Sep 16, 2020
1 parent f1f6c69 commit 3a1b46a
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 80 deletions.
8 changes: 4 additions & 4 deletions docs/en-us/reference/rpc/latest-version/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ For P2P and WebSocket information see [Node Introduction](../../../node/introduc

| Command | Parameter | Description |
| --------------------------------------------------- | -------------------------------------- | ------------------------------------------------------------ |
| [invokefunction](api/invokefunction.md) | \<script_hash> \<operation> \<params> \<signers> | Invokes a smart contract with the specified script hash, passing in the method name and its params. |
| [invokescript](api/invokescript.md) | \<script> \<signers> | Runs a script through the virtual machine and returns the results. |
| [invokefunction](api/invokefunction.md) | \<script_hash> \<operation> \[params] \[sender] \[signers] | Invokes a smart contract with the specified script hash, passing in the method name and its params. |
| [invokescript](api/invokescript.md) | \<script> \[sender] \[signers] | Runs a script through the virtual machine and returns the results. |
| [getunclaimedgas](api/getunclaimedgas.md) | \<address> | Get unclaimed gas of the specified address. |

### Tool
Expand All @@ -71,8 +71,8 @@ For P2P and WebSocket information see [Node Introduction](../../../node/introduc
| [listaddress](api/listaddress.md) | | Lists all the addresses in the current wallet. |
| [openwallet](api/openwallet.md) | \<path> \<password> | Opens the specified wallet. |
| [sendfrom](api/sendfrom.md) | \<asset_id>\<from>\<to>\<value> | Transfers from the specified address to the destination address. |
| [sendmany](api/sendmany.md) | \<outputs_array> | Initiates multiple transfers to multiple addresses in a transaction. |
| [sendtoaddress](api/sendtoaddress.md) | \<asset_id>\<address>\<value> | Transfers to the specified address. |
| [sendmany](api/sendmany.md) | \<outputs_array> \[signers] | Initiates multiple transfers to multiple addresses in a transaction. |
| [sendtoaddress](api/sendtoaddress.md) | \<asset_id>\<address>\<value> \[signers] | Transfers to the specified address. |

### ApplicationLogs plugin

Expand Down
16 changes: 11 additions & 5 deletions docs/en-us/reference/rpc/latest-version/api/invokefunction.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ Invokes a smart contract with its scripthash based on the specified operation an
## Parameter Description

* scripthash: Smart contract scripthash. You need to use the proper byte order of the address passed according to its data type. If the data type is Hash160, use the big endian scripthash; if the data type is ByteArray, use the little endian scripthash.

* operation: The operation name (string)
* params: The parameters to be passed into the smart contract operation
* cosigners: Add signatures when required.

* params: Optional. The parameters to be passed into the smart contract operation

* sender: Optional. The transaction sender and the account paying transaction fee. By default it is the first account in signers.

* signers: Optional. List of contract signature accounts.

> [!Note]
>
> You need to use the proper byte order of the address passed according to its data type. If the data type is Hash160, use the big endian script hash; if the data type is ByteArray, use the little endian scripthash.
* signers: list of contract signature accounts
* account: signature account
* scopes: signature's valid scopes, allowed values: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global
* allowedcontracts: contracts of the signature can take effect, if scopes is CustomContracts
* allowedgroups: pubkeys of the signature can take effect, if scopes is CustomGroups


You need to use the proper byte order of the address passed according to its data type. If the data type is Hash160, use the big endian script hash; if the data type is ByteArray, use the little endian scripthash.

For example:
Expand Down Expand Up @@ -71,12 +76,13 @@ Request body:
"value":"8"
}
],
"0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146",
[
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
"scopes": "CalledByEntry",
"allowedcontracts":["0xde5f57d430d3dece511cf975a8d37848cb9e0525","0x1f177332c467db9ba734d3ca85645fbadd7e13e3"],
"allowedgroups":["0222d8515184c7d62ffa99b829aeb4938c4704ecb0dd7e340e842e9df121826343"]
"allowedcontracts":[],
"allowedgroups":[]
}
]
]
Expand Down
6 changes: 4 additions & 2 deletions docs/en-us/reference/rpc/latest-version/api/invokescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Returns the result after passing a script through the VM.
### Parameter Description

- script: A script runnable in the VM. This is the same script that is returned in invokefunction
- sender: The transaction sender and the account paying transaction fee. It is the first account in singers.
- signers: list of contract signature accounts
* account: signature account
* scopes: signature's valid scopes, allowed values: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global
Expand All @@ -27,6 +28,7 @@ Request body:
"method": "invokescript",
"params": [
"180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52",
["0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146"],
[
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
Expand All @@ -46,7 +48,7 @@ Response body:
"jsonrpc": "2.0",
"id": 1,
"result": {
"script": "180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52",
"script": "180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52",
"state": "HALT",
"gasconsumed": "9007960",
"stack": [
Expand All @@ -62,7 +64,7 @@ Response body:

- state: `HALT` means the vm executed successfully, and`FAULT` means the vm exited due to an exception.

- gasconsumed: the system fee consumed for invocation. - gasconsumed: the system fee consumed for invocation.
- gasconsumed: the system fee consumed for invocation.

- stack: the contract execution result. If the value is String or ByteArray, it is encoded by Base64.

Expand Down
17 changes: 12 additions & 5 deletions docs/en-us/reference/rpc/latest-version/api/sendfrom.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ Transfer from the specified address to the destination address.

​ GAS is 0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc
* from: transfering address.

* address: destination address.

* value: Transfer amount
* signers: The signature account of transaction

## Example

Expand All @@ -31,7 +30,7 @@ Request body:
"jsonrpc": "2.0",
"id": 1,
"method": "sendfrom",
"params": ["0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","NNU67Fvdy3LEQTM374EJ9iMbCRxVExgM8Y","NZoiUCBHBZ4DquVE5mbdpTQGozvJkWHtE8", 20]
"params": ["0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","NNU67Fvdy3LEQTM374EJ9iMbCRxVExgM8Y","NZoiUCBHBZ4DquVE5mbdpTQGozvJkWHtE8", 20, ["0xf621168b1fce3a89c33a5f6bcf7e774b4657031c","NZttvm9tAhMjyxZATvqN9WFYkHYMNaXD6C"]]
}
```

Expand All @@ -54,14 +53,22 @@ Request body:
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
"scopes": "CalledByEntry"
},
{
"account": "0x1e01f56dbb2a9799422512752b900a5a49ca5d99",
"scopes": "CalledByEntry"
}
],
"attributes": [],
"script": "AgCUNXcMFJhi+vwOIcqnRtK5Br/vfRNBU1GEDBQcA1dGS3d+z2tfOsOJOs4fixYh9hPADAh0cmFuc2ZlcgwUvK9B1oTH1K1u4NmdqXB7nR8MjmZBYn1bUjg=",
"witnesses": [
{
"invocation": "DECnvSyJY/EnXpncenAA8AL9ufUrmskkxE+J+ODbjro7VgLp2sHV2tffyA2fYsqAaZzsqhnZK/Ay8sEUSozOyT+n",
"verification": "DCECIthRUYTH1i/6mbgprrSTjEcE7LDdfjQOhC6d8SGCY0MLQZVEDXg="
"invocation": "DEBIGjD61/KPyUq51sfsgla6MlruIbBG3eYkmI2cWXHrcGYMm6ucO6Va2Dc7v7mzF8XnQvJtrBVjv/caRpqt08OA",
"verification": "DCECIItAHAHzOQfla6fHzYkOv5cXTzazCk9DZ6xRAlIUXH4LQZVEDXg="
},
{
"invocation": "DEC5O1ZFX46Vhdm4H8uY3IfYWHMbMnIkl5QljOYK8lVIfinYfbvyFuHsELDUM1io1RrbShjwkoFiVG1UKfC0nlqC",
"verification": "DCECi9GQLE0UGfACuCHm3mU939U1gGMgjkJnVjmL5v+jqsgLQZVEDXg="
}
]
}
Expand Down
63 changes: 15 additions & 48 deletions docs/en-us/reference/rpc/latest-version/api/sendmany.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ Bulk transfer order, and you can specify a change address.
* `outputs_array`:Array, the data structure of each element in the array is as follows:

```json
{"asset": <asset>,"value": <value>,"address": <address>}
{"asset": <asset>,"value": <value>,"address": <address>, "signers": <signers>}
```

* `asset`Asset ID (asset identifier), the NEP-5 contract scripthash
* `asset`: Asset ID (asset identifier), the NEP-5 contract scripthash

e.g. NEO is 0xde5f57d430d3dece511cf975a8d37848cb9e0525

Gas is 0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc

* `value`Transfer amount
* `value`: Transfer amount

* `address`:destination address.
* `address`: Destination address

* `signers`: The signature account of transaction

## Example

**Example 1 - transferring from a specified address**

Request body:
Request text:

```json
{
Expand All @@ -67,47 +67,13 @@ Request body:
"value": 2,
"address": "Nc2TgT3BTnDZGh21uU14Fudaq9C8GqUKJA"
}
]
],
["0xf621168b1fce3a89c33a5f6bcf7e774b4657031c","NZttvm9tAhMjyxZATvqN9WFYkHYMNaXD6C"]
]
}
```

Response body:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x01ccb37af435f0e7220473ae51334e5f2c2d896968411c14044537e22b8e045e",
"size": 424,
"version": 0,
"nonce": 93138602,
"sender": "NNU67Fvdy3LEQTM374EJ9iMbCRxVExgM8Y",
"sysfee": "27023970",
"netfee": "1424390",
"validuntilblock": 2105183,
"signers": [
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
"scopes": "CalledByEntry"
}
],
"attributes": [],
"script": "AgDh9QUMFLC8S2S+4uI9PTLeAsqsGFP6u7QDDBQcA1dGS3d+z2tfOsOJOs4fixYh9hPADAh0cmFuc2ZlcgwUvK9B1oTH1K1u4NmdqXB7nR8MjmZBYn1bUjgCAMLrCwwUmGL6/A4hyqdG0rkGv+99E0FTUYQMFBwDV0ZLd37Pa186w4k6zh+LFiH2E8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOBIMFLC8S2S+4uI9PTLeAsqsGFP6u7QDDBQcA1dGS3d+z2tfOsOJOs4fixYh9hPADAh0cmFuc2ZlcgwUJQWey0h406h1+RxRzt7TMNRXX95BYn1bUjg=",
"witnesses": [
{
"invocation": "DEB4NucKpf2vnr18txXcHI5hFDWTZNXZsamoxkkOfHPlKNfYgZloDb6v4wsdjkrMoohEXBqW2cc6fVxsgOQEYxOV",
"verification": "DCECIthRUYTH1i/6mbgprrSTjEcE7LDdfjQOhC6d8SGCY0MLQZVEDXg="
}
]
}
}
```

**Example 2 - transferring without specifying an address**

Request body:
Request text (without fromAddress):

```json
{
Expand All @@ -131,12 +97,13 @@ Request body:
"value": 2,
"address": "Nc2TgT3BTnDZGh21uU14Fudaq9C8GqUKJA"
}
]
],
["0xf621168b1fce3a89c33a5f6bcf7e774b4657031c","NZttvm9tAhMjyxZATvqN9WFYkHYMNaXD6C"]
]
}
```

Response body:
Response text:

```json
{
Expand All @@ -153,11 +120,11 @@ Response body:
"validuntilblock": 2105186,
"signers": [
{
"account": "0x84515341137defbf06b9d246a7ca210efcfa6298",
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
"scopes": "CalledByEntry"
},
{
"account": "0xb120f50f804d3a203c43475212894ab1c911ce18",
"account": "0x1e01f56dbb2a9799422512752b900a5a49ca5d99",
"scopes": "CalledByEntry"
}
],
Expand Down
8 changes: 4 additions & 4 deletions docs/zh-cn/reference/rpc/latest-version/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P

| 方法 | 参数 | 说明 |
| --------------------------------------- | --------------------------------------- | ---------------------------------------------- |
| [invokefunction](api/invokefunction.md) | \<script_hash> \<operation> \<params> \<signers> | 用指定的哈希调用智能合约,传入方法名及参数 |
| [invokescript](api/invokescript.md) | \<script> \<signers> | 通过虚拟机运行脚本并返回结果 |
| [invokefunction](api/invokefunction.md) | \<script_hash> \<operation> \[params] \[sender] \[signers] | 用指定的哈希调用智能合约,传入方法名及参数 |
| [invokescript](api/invokescript.md) | \<script> \[sender] \[signers] | 通过虚拟机运行脚本并返回结果 |
| [getunclaimedgas](api/getunclaimedgas.md) | \<address> | 查询指定地址未获取的 gas |

### 工具
Expand All @@ -69,8 +69,8 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P
| [listaddress](api/listaddress.md) | | 列出当前钱包内的所有地址 |
| [openwallet](api/openwallet.md) | \<path> \<password> | 打开指定钱包 |
| [sendfrom](api/sendfrom.md) | \<asset_id>\<from>\<to>\<value> | 从指定地址,向指定地址转账 |
| [sendmany](api/sendmany.md) | \<outputs_array> | 在一笔交易中向多个地址发起多笔转账 |
| [sendtoaddress](api/sendtoaddress.md) | \<asset_id>\<address>\<value> | 向指定地址转账 |
| [sendmany](api/sendmany.md) | \<outputs_array> \[signers] | 在一笔交易中向多个地址发起多笔转账 |
| [sendtoaddress](api/sendtoaddress.md) | \<asset_id>\<address>\<value> \[signers]| 向指定地址转账 |

### ApplicationLogs 插件

Expand Down
7 changes: 4 additions & 3 deletions docs/zh-cn/reference/rpc/latest-version/api/invokefunction.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

- operation:操作名称(字符串)。

- params:传递给智能合约操作的参数。
- params:传递给智能合约操作的参数,可选

- cosigners:需要添加的签名列表,如不需要签名,无需传递此参数
- sender:交易发送者,支付交易费的账户,默认是 singers 中第一个账户,可选

- signers: 签名账户列表
- signers: 签名账户列表,可选。
* account: 签名账户
* scopes: 签名的作用域,允许的值: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global
* allowedcontracts: 如果 scopes 是 CustomContracts,该字段是签名生效的合约 Hash 列表
Expand Down Expand Up @@ -70,6 +70,7 @@
"value":"8"
}
],
"0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146",
[
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
Expand Down
4 changes: 3 additions & 1 deletion docs/zh-cn/reference/rpc/latest-version/api/invokescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
## 参数说明

- script:一个由虚拟机运行的脚本,与 invokefunction 返回的 script 相同;
- signers:签名账户列表
- sender:交易发送者,支付交易费的账户,默认是 singers 中第一个账户,可选。
- signers:签名账户列表,可选
* account: 签名账户
* scopes: 签名的作用域,允许的值: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global
* allowedcontracts: 如果 scopes 是 CustomContracts,该字段是签名生效的合约 Hash 列表
Expand All @@ -27,6 +28,7 @@
"method": "invokescript",
"params": [
"180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52",
["0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146"],
[
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
Expand Down
16 changes: 13 additions & 3 deletions docs/zh-cn/reference/rpc/latest-version/api/sendfrom.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

- value:转账金额。

- signers:交易签名账户。


## 调用示例

Expand All @@ -31,7 +33,7 @@
"jsonrpc": "2.0",
"id": 1,
"method": "sendfrom",
"params": ["0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","NNU67Fvdy3LEQTM374EJ9iMbCRxVExgM8Y","NZoiUCBHBZ4DquVE5mbdpTQGozvJkWHtE8", 20]
"params": ["0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","NNU67Fvdy3LEQTM374EJ9iMbCRxVExgM8Y","NZoiUCBHBZ4DquVE5mbdpTQGozvJkWHtE8", 20, ["0xf621168b1fce3a89c33a5f6bcf7e774b4657031c","NZttvm9tAhMjyxZATvqN9WFYkHYMNaXD6C"]]
}
```

Expand All @@ -54,14 +56,22 @@
{
"account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c",
"scopes": "CalledByEntry"
},
{
"account": "0x1e01f56dbb2a9799422512752b900a5a49ca5d99",
"scopes": "CalledByEntry"
}
],
"attributes": [],
"script": "AgCUNXcMFJhi+vwOIcqnRtK5Br/vfRNBU1GEDBQcA1dGS3d+z2tfOsOJOs4fixYh9hPADAh0cmFuc2ZlcgwUvK9B1oTH1K1u4NmdqXB7nR8MjmZBYn1bUjg=",
"witnesses": [
{
"invocation": "DECnvSyJY/EnXpncenAA8AL9ufUrmskkxE+J+ODbjro7VgLp2sHV2tffyA2fYsqAaZzsqhnZK/Ay8sEUSozOyT+n",
"verification": "DCECIthRUYTH1i/6mbgprrSTjEcE7LDdfjQOhC6d8SGCY0MLQZVEDXg="
"invocation": "DEBIGjD61/KPyUq51sfsgla6MlruIbBG3eYkmI2cWXHrcGYMm6ucO6Va2Dc7v7mzF8XnQvJtrBVjv/caRpqt08OA",
"verification": "DCECIItAHAHzOQfla6fHzYkOv5cXTzazCk9DZ6xRAlIUXH4LQZVEDXg="
},
{
"invocation": "DEC5O1ZFX46Vhdm4H8uY3IfYWHMbMnIkl5QljOYK8lVIfinYfbvyFuHsELDUM1io1RrbShjwkoFiVG1UKfC0nlqC",
"verification": "DCECi9GQLE0UGfACuCHm3mU939U1gGMgjkJnVjmL5v+jqsgLQZVEDXg="
}
]
}
Expand Down
Loading

0 comments on commit 3a1b46a

Please sign in to comment.