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

Commit

Permalink
update rpc and sc (#1142)
Browse files Browse the repository at this point in the history
* update rpc api

* fix

* update sc api

* update sc framework

* update fee

* some updates in develop

* update opcode fee

Co-authored-by: Celia18305 <[email protected]>
  • Loading branch information
bettybao1209 and Celia18305 authored Nov 18, 2020
1 parent a994e37 commit bf28560
Show file tree
Hide file tree
Showing 47 changed files with 1,318 additions and 215 deletions.
44 changes: 25 additions & 19 deletions docs/zh-cn/develop/deploy/Parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,42 @@
/// </summary>
public enum ContractParameterType : byte
{
Any = 0x00,

Boolean = 0x10,
/// <summary>
/// 签名
/// 整数
/// </summary>
Signature = 0,
Boolean = 1,
Integer = 0x11,
/// <summary>
/// 整数
/// 字节数组
/// </summary>
Integer = 2,
ByteArray = 0x12,
String = 0x13,
/// <summary>
/// 160位散列值
/// </summary>
Hash160 = 3,
Hash160 = 0x14,
/// <summary>
/// 256 位散列值
/// </summary>
Hash256 = 4,
Hash256 = 0x15,
PublicKey = 0x16,
/// <summary>
/// 字节数组
/// 签名
/// </summary>
ByteArray = 5,
PublicKey = 6,
String = 7,

/// <summary>
/// 对象数组
/// </summary>
Array = 10,
InteropInterface = 0xf0,
Signature = 0x17,

/// <summary>
/// 对象数组
/// </summary>
Array = 0x20,
Map = 0x22,

InteropInterface = 0x30,

Void = 0xff

}
```

Expand All @@ -53,6 +59,6 @@ public class Lock : SmartContract
}
```

通过上表可查到,int 为 2,bool 为 1,公钥字节数组为 6,签名字节数组为 0
通过上表可查到,int 为 0x11,bool 为 0x10,公钥字节数组为 0x16,签名字节数组为 0x17

在 NEO-GUI 客户端发布智能合约填写参数时,每个参数用两位 16 进制字符表示,所以上面的智能合约的形参列表表示为:02010600,返回值为:01
在 NEO-GUI 客户端发布智能合约填写参数时,每个参数用两位 16 进制字符表示,所以上面的智能合约的形参列表表示为:11101617,返回值为:10
6 changes: 3 additions & 3 deletions docs/zh-cn/develop/deploy/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

## 为什么需要部署?

当一个智能合约需要在区块链上存储数据或被其它智能合约调用(称为 appcall)时,需要部署。而仅由合约账户鉴权触发的合约,如锁仓合约、多方签名合约,不会被其它合约调用,所以无需部署。像 `return 1+1` 这样的合约,因为没有任何需要输入的参数,也无需部署。
当一个智能合约需要在区块链上存储数据或被其它智能合约调用(通过syscall `System.Contract.Call`)时,需要部署。而仅由合约账户鉴权触发的合约,如锁仓合约、多方签名合约,不会被其它合约调用,所以无需部署。像 `return 1+1` 这样的合约,因为没有任何需要输入的参数,也无需部署。

从编程语言的角度来说,当智能合约要作为一个类库使用时,才需要被部署。比如以下情况:

- 当一个智能合约有可变的传入参数,此时它必须作为一个类库,由调用者(Invocation 交易)或者其它的智能合约提供参数
- 当一个智能合约有可变的传入参数,此时它必须作为一个类库,由调用者或者其它的智能合约提供参数
- 当一个智能合约使用存储区(Storage)时,必须作为一个类库。
- 当一个智能合约实现了 NEP-5(合约资产)时,需要将该合约部署到区块链上。

智能合约的部署是通过 Invocation 交易调用 API 来部署。通常的做法是通过 Neo-CLI 或 Neo-GUI 的智能合约发布功能来部署合约。
智能合约的部署是通过交易调用 API 来部署。通常的做法是通过 Neo-CLI 或 Neo-GUI 的智能合约发布功能来部署合约。

部署智能合约以及调用智能合约均会产生费用,详情请参见 [系统手续费](../../reference/fees.md)

Expand Down
6 changes: 3 additions & 3 deletions docs/zh-cn/develop/deploy/invoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 合约详情查询

使用 Neo-CLI 或 Neo-GUI 可以查询合约的详细信息,如合约的基本信息、入口点、方法、通知等。
使用 Neo-CLI 或 Neo-GUI 可以查询合约的详细信息,如合约的基本信息、方法、通知等。

### 使用 Neo-CLI 查询

Expand All @@ -26,7 +26,7 @@ Neo-GUI 中会更直观地显示合约信息,也能查看 manifest 和 nef 文
- 使用 invoke 命令调用智能合约,命令如下:

```
invoke <scriptHash> <operation> [contractParameters=null] [witnessAddress=null]
invoke <scriptHash> <operation> [contractParameters=null] [sender=null] [signerAccounts=null]
```

详情请参考 [invoke](../../node/cli/cli.md#invoke) 命令。
Expand Down Expand Up @@ -58,7 +58,7 @@ Neo-GUI 中会更直观地显示合约信息,也能查看 manifest 和 nef 文
在 Neo-CLI 中,我们可以通过 `invoke` 命令附加签名。

```
invoke <scriptHash> <operation> [contractParameters=null] [witnessAddress=null]
invoke <scriptHash> <operation> [contractParameters=null] [sender=null] [signerAccounts=null]
```

在 Neo-GUI 中,在调用合约时,可以点击下方的 `附加签名`,选择 `公钥` 然后点击 `签名` 来进行附加签名。
Expand Down
138 changes: 94 additions & 44 deletions docs/zh-cn/reference/fees.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@
|--|--|
| System.Binary.Serialize | 0.00100000 |
| System.Binary.Deserialize| 0.00500000 |
| System.Binary.Base64Encode| 0.00100000 |
| System.Binary.Base64Decode| 0.00100000 |
| System.Binary.Base58Encode| 0.00100000 |
| System.Binary.Base58Decode| 0.00100000 |
| System.Blockchain.GetHeight | 0.00000400 |
| System.Blockchain.GetBlock | 0.02500000 |
| System.Blockchain.GetTransaction | 0.01000000 |
| System.Blockchain.GetTransactionHeight | 0.01000000 |
| System.Blockchain.GetTransactionFromBlock | 0.01000000 |
| System.Blockchain.GetContract | 0.01000000 |
| System.Contract.Create | (Script.Size + Manifest.Size) * GasPerByte |
| System.Contract.Update | (Script.Size + Manifest.Size) * GasPerByte |
| System.Callback.Create | 0.00000400 |
| System.Callback.CreateFromMethod | 0.01000000 |
| System.Callback.CreateFromSyscall | 0.00000400 |
| System.Callback.Invoke | 0.01000000 |
| System.Contract.Create | 0 |
| System.Contract.Update | 0 |
| System.Contract.Destroy | 0.01000000 |
| System.Contract.Call | 0.01000000 |
| System.Contract.CallEx | 0.01000000 |
| System.Contract.IsStandard | 0.00030000 |
| System.Contract.GetCallFlags | 0.00030000 |
| System.Enumerator.Create | 0.00000400 |
| System.Enumerator.Next | 0.01000000 |
| System.Enumerator.Value | 0.00000400 |
Expand Down Expand Up @@ -55,20 +64,17 @@
| System.StorageContext.AsReadOnly| 0.00000400 |
| System.Storage.Get| 0.01000000 |
| System.Storage.Find| 0.01000000 |
| System.Storage.Put| 参见 [1] |
| System.Storage.PutEx| 参见 [1] |
| System.Storage.Delete| 1 * GasPerByte |
| System.Storage.Put| 0 |
| System.Storage.PutEx| 0 |
| System.Storage.Delete| 1 * StoragePrice |
| Neo.Native.Deploy| 0 |
| Neo.Crypto.ECDsaVerify| 0.01000000 |
| Neo.Crypto.ECDsaCheckMultiSig| 0.01000000 * n |

> [!Note]
>
> [1] 向数据库中写入Key和Value时,
>
> - 如果新的键值对字节数大于旧的键值对,则 fee = [(newKey.Size +newValue.Size) - (oldKey.Size + oldValue.Size)] * GasPerByte
> - 如果新的键值对字节数小于等于旧的键值对,则 fee = 1 * GasPerByte
> - 如果数据库中不存在旧的键值对,则 fee = (key.Size + value.Size) * GasPerByte
| Neo.Native.Call| 0 |
| Neo.Crypto.RIPEMD160| 0.01000000 |
| Neo.Crypto.SHA256| 0.01000000 |
| Neo.Crypto.VerifyWithECDsaSecp256r1| 0.01000000 |
| Neo.Crypto.VerifyWithECDsaSecp256k1| 0.01000000 |
| Neo.Crypto.CheckMultisigWithECDsaSecp256r1| 0 |
| Neo.Crypto.CheckMultisigWithECDsaSecp256k1| 0 |

<table class="table table-hover">
<tr>
Expand All @@ -77,7 +83,7 @@
<th>费用 (GAS)</th>
</tr >
<tr >
<td rowspan="11">Neo.Native.Tokens.NEO</td>
<td rowspan="15">Neo.Native.Tokens.NEO</td>
<td>name</td>
<td>0</td>
</tr>
Expand All @@ -101,24 +107,41 @@
<td>transfer</td>
<td>0.08000000</td>
</tr>
<tr>
<td>registerValidator</td>
<tr>
<td>setGasPerBlock</td>
<td>0.05000000</td>
</tr>
<tr>
<tr>
<td>getGasPerBlock</td>
<td>0.05000000</td>
</tr>
<tr>
<td>unclaimedGas</td>
<td>0.03000000</td>
</tr>
<tr>
<td>registerCandidate</td>
<td>0.05000000</td>
</tr>
<tr>
<td>unregisterCandidate</td>
<td>0.05000000</td>
</tr>
<tr>
<td>vote</td>
<td>5.00000000</td>
<td>0.08000000</td>
</tr>
<tr>
<td>getRegisteredValidators</td>
<tr>
<td>GetCandidates</td>
<td>1.00000000</td>
</tr>
<tr>
<td>getValidators</td>
<tr>
<td>getCommittee</td>
<td>1.00000000</td>
</tr>
<tr><td>unclaimedGas</td>
<td>0.03000000</td>
<tr>
<td>getNextBlockValidators</td>
<td>1.00000000</td>
</tr>
</table>

Expand Down Expand Up @@ -166,7 +189,7 @@
<th>费用 (GAS)</th>
</tr >
<tr >
<td rowspan="9">Neo.Native.Policy</td>
<td rowspan="11">Neo.Native.Policy</td>
<td>getMaxTransactionsPerBlock</td>
<td>0.01000000</td>
</tr>
Expand All @@ -175,31 +198,58 @@
<td>0.01000000</td>
</tr>
<tr>
<td>getFeePerByte</td>
<td>GetMaxBlockSystemFee</td>
<td>0.01000000</td>
</tr>
<tr>
<td>setMaxBlockSize</td>
<td>0.03000000</td>
<td>GetFeePerByte</td>
<td>0.01000000</td>
</tr>
<tr><td>getBlockedAccounts</td>
<tr><td>IsBlocked</td>
<td>0.01000000</td>
</tr>
<tr><td>setMaxTransactionsPerBlock</td>
<tr><td>SetMaxBlockSize</td>
<td>0.03000000</td>
</tr>
<tr><td>SetMaxTransactionsPerBlock</td>
<td>0.03000000</td>
</tr>
<tr><td>SetMaxBlockSystemFee</td>
<td>0.03000000</td>
</tr>
<tr><td>setFeePerByte</td>
<tr><td>SetFeePerByte</td>
<td>0.03000000</td>
</tr>
<tr><td>blockAccount</td>
<tr><td>BlockAccount</td>
<td>0.03000000</td>
</tr>
<tr><td>unblockAccount</td>
<tr><td>UnblockAccount</td>
<td>0.03000000</td>
</tr>
</table>

关于表格中API的含义,请参见 [Neo命名空间](../reference/scapi/api/neo.md)
<table class="table table-hover">
<tr>
<th>互操作服务</th>
<th>方法名</th>
<th>费用 (GAS)</th>
</tr >
<tr >
<td rowspan="3">Neo.Native.Oracle</td>
<td>finish</td>
<td>0</td>
</tr>
<tr>
<td>request</td>
<td>0.50000000</td>
</tr>
<tr>
<td>verify</td>
<td>0.01000000</td>
</tr>
</table>

关于表格中API的含义,请参见 [NEO命名空间](../reference/scapi/api/neo.md)

### 指令费用

Expand Down Expand Up @@ -261,7 +311,7 @@
|REVERSE4|0.00000060|
|REVERSEN|0.00000400|
|INITSSLOT|0.00000400|
|INITSLOT|0.00000800|
|INITSLOT|0.00001600|
|LDSFLD0\~LDSFLD6|0.00000060|
|LDSFLD|0.00000060|
|STSFLD0\~STSFLD6|0.0000006|
Expand All @@ -284,8 +334,8 @@
|AND|0.00000200|
|OR|0.00000200|
|XOR|0.00000200|
|EQUAL|0.00000200|
|NOTEQUAL|0.00000200|
|EQUAL|0.00001000|
|NOTEQUAL|0.00001000|
|SIGN|0.00000100|
|ABS|0.00000100|
|NEGATE|0.00000100|
Expand All @@ -311,8 +361,8 @@
|MIN|0.00000200|
|MAX|0.00000200|
|WITHIN|0.00000200|
|PACK|0.00007000|
|UNPACK|0.00007000|
|PACK|0.00015000|
|UNPACK|0.00015000|
|NEWARRAY0|0.00000400|
|NEWARRAY|0.00015000|
|NEWARRAY_T|0.00015000|
Expand All @@ -322,11 +372,11 @@
|SIZE|0.00000150|
|HASKEY|0.00270000|
|KEYS|0.00000500|
|VALUES|0.00007000|
|VALUES|0.00270000|
|PICKITEM|0.00270000|
|APPEND|0.00015000|
|APPEND|0.00270000|
|SETITEM|0.00270000|
|REVERSEITEMS|0.00000500|
|REVERSEITEMS|0.00270000|
|REMOVE|0.00000500|
|CLEARITEMS|0.00000400|
|ISNULL|0.00000060|
Expand Down
3 changes: 2 additions & 1 deletion docs/zh-cn/reference/rpc/latest-version/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P
| [getrawtransaction](api/getrawtransaction.md) | \<txid> [verbose=0] | 根据指定的散列值,返回对应的交易信息 |
| [getstorage](api/getstorage.md) | \<script_hash> \<key> | 根据合约脚本散列和存储的 key,返回存储的 value |
| [gettransactionheight](api/gettransactionheight.md) | \<txid> | 根据交易哈希获取交易所在的区块高度 |
| [getvalidators](api/getvalidators.md) | | 查看当前共识节点的信息 |
| [getcommittee](api/getcommittee.md) | | 获取委员会成员公钥列表 |

### 节点

Expand Down Expand Up @@ -66,6 +66,7 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P
| [getnewaddress](api/getnewaddress.md) | | 创建一个新的地址 |
| [getwalletunclaimedgas](api/getwalletunclaimedgas.md) | | 显示钱包中未提取的 GAS 数量 |
| [importprivkey](api/importprivkey.md) | \<key> | 导入私钥到钱包 |
| [calculatenetworkfee](api/calculatenetworkfee.md) | \<key> | 计算指定交易的网络费GAS |
| [listaddress](api/listaddress.md) | | 列出当前钱包内的所有地址 |
| [openwallet](api/openwallet.md) | \<path> \<password> | 打开指定钱包 |
| [sendfrom](api/sendfrom.md) | \<asset_id>\<from>\<to>\<value> | 从指定地址,向指定地址转账 |
Expand Down
Loading

0 comments on commit bf28560

Please sign in to comment.