From bd820047c545b742a6c4f7d8bd2e2d4d5b76aad3 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 5 Nov 2020 14:34:48 +0800 Subject: [PATCH 01/15] update rpc api --- .../zh-cn/reference/rpc/latest-version/api.md | 2 + .../latest-version/api/calculatenetworkfee.md | 38 ++++++++++++++ .../rpc/latest-version/api/getcommittee.md | 51 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md create mode 100644 docs/zh-cn/reference/rpc/latest-version/api/getcommittee.md diff --git a/docs/zh-cn/reference/rpc/latest-version/api.md b/docs/zh-cn/reference/rpc/latest-version/api.md index d538bb1b2..5009159ca 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api.md +++ b/docs/zh-cn/reference/rpc/latest-version/api.md @@ -30,6 +30,7 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P | [getstorage](api/getstorage.md) | \ \ | 根据合约脚本散列和存储的 key,返回存储的 value | | [gettransactionheight](api/gettransactionheight.md) | \ | 根据交易哈希获取交易所在的区块高度 | | [getvalidators](api/getvalidators.md) | | 查看当前共识节点的信息 | +| [getcommittee](api/getcommittee.md) | | 获取委员会成员公钥列表 | ### 节点 @@ -66,6 +67,7 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P | [getnewaddress](api/getnewaddress.md) | | 创建一个新的地址 | | [getwalletunclaimedgas](api/getwalletunclaimedgas.md) | | 显示钱包中未提取的 GAS 数量 | | [importprivkey](api/importprivkey.md) | \ | 导入私钥到钱包 | +| [calculatenetworkfee](api/calculatenetworkfee.md) | \ | 计算指定交易的网络费GAS | | [listaddress](api/listaddress.md) | | 列出当前钱包内的所有地址 | | [openwallet](api/openwallet.md) | \ \ | 打开指定钱包 | | [sendfrom](api/sendfrom.md) | \\\\ | 从指定地址,向指定地址转账 | diff --git a/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md b/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md new file mode 100644 index 000000000..e353fb9f5 --- /dev/null +++ b/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md @@ -0,0 +1,38 @@ +# calculatenetworkfee 方法 + +计算指定交易的网络费GAS。 + +> [!Note] +> +> - 执行此命令前需要 RPC 调用 openwallet 方法来打开钱包。 +> - 此方法由插件提供,需要安装 [RpcServer](https://github.com/neo-project/neo-modules/releases) 插件才可以调用。 + +## 参数说明 + +tx :交易信息Base64编码的字符串。 + +## 调用示例 + +请求正文: + +```json +{ + "jsonrpc": "2.0", + "method": "calculatenetworkfee", + "params": ["AAzUzgl2c4kAAAAAAMhjJAAAAAAAmRQgAAKDHlc9J/rM4KzhpixYX/fRkt2q8ACBubhEJKzaXrq9mt5PesW40qC01AEAXQMA6HZIFwAAAAwUgx5XPSf6zOCs4aYsWF/30ZLdqvAMFIG5uEQkrNpeur2a3k96xbjSoLTUE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAJCDED0lByRy1/NfBDdKCFLA3RKAY+LLVeXAvut42izfO6PPsKX0JeaL959L0aucqcxBJfWNF3b+93mt9ItCxRoDnChKQwhAuj/F8Vn1i8nT+JHzIhKKmzTuP0Nd5qMWFYomlYKzKy0C0GVRA14QgxAMbiEtF4zjCUjGAzanxLckFiCY3DeREMGIxyerx5GCG/Ki0LGvNzbvPUAWeVGvbL5TVGlK55VfZECmy8voO1LsisRDCEC6P8XxWfWLydP4kfMiEoqbNO4/Q13moxYViiaVgrMrLQRC0ETje+v"], + "id": 1 +} +``` + +响应正文: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "networkfee": 2384840 + } +} + +``` diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getcommittee.md b/docs/zh-cn/reference/rpc/latest-version/api/getcommittee.md new file mode 100644 index 000000000..3264ec82c --- /dev/null +++ b/docs/zh-cn/reference/rpc/latest-version/api/getcommittee.md @@ -0,0 +1,51 @@ +# getcommittee 方法 + +获取当前 NEO 委员会成员公钥列表。 +> [!Note] +> +> 此方法由插件提供,需要安装 [RpcServer](https://github.com/neo-project/neo-modules/releases) 插件才可以调用。 + +## 调用示例 + +请求正文: + +```json +{ + "jsonrpc": "2.0", + "method": "getcommittee", + "params": [], + "id": 1 +} +``` + +响应正文: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": [ + "020f2887f41474cfeb11fd262e982051c1541418137c02a0f4961af911045de639", + "03204223f8c86b8cd5c89ef12e4f0dbb314172e9241e30c9ef2293790793537cf0", + "0222038884bbd1d8ff109ed3bdef3542e768eef76c1247aea8bc8171f532928c30", + "0226933336f1b75baa42d42b71d9091508b638046d19abd67f4e119bf64a7cfb4d", + "023a36c72844610b4d34d1968662424011bf783ca9d984efa19a20babf5582f3fe", + "03409f31f0d66bdc2f70a9730b66fe186658f84a8018204db01c106edc36553cd0", + "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70", + "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d", + "02504acbc1f4b3bdad1d86d6e1a08603771db135a73e61c9d565ae06a1938cd2ad", + "03708b860c1de5d87f5b151a12c2a99feebd2e8b315ee8e7cf8aa19692a9e18379", + "0288342b141c30dc8ffcde0204929bb46aed5756b41ef4a56778d15ada8f0c6654", + "02a62c915cf19c7f19a50ec217e79fac2439bbaad658493de0c7d8ffa92ab0aa62", + "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e", + "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", + "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", + "03c6aa6e12638b36e88adc1ccdceac4db9929575c3e03576c617c49cce7114a050", + "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554", + "02cd5a5547119e24feaa7c2a0f37b8c9366216bab7054de0065c9be42084003c8a", + "03cdcea66032b82f5c30450e381e5295cae85c5e6943af716cc6b646352a6067dc", + "03d281b42002647f0113f36c7b8efb30db66078dfaaa9ab3ff76d043a98d512fde", + "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093" + ] +} +``` \ No newline at end of file From 906eef7165707dce4ad0e1b35d2bc13ea740d60c Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 5 Nov 2020 14:48:28 +0800 Subject: [PATCH 02/15] fix --- .../reference/rpc/latest-version/api/calculatenetworkfee.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md b/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md index e353fb9f5..669b66c6d 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md @@ -4,7 +4,6 @@ > [!Note] > -> - 执行此命令前需要 RPC 调用 openwallet 方法来打开钱包。 > - 此方法由插件提供,需要安装 [RpcServer](https://github.com/neo-project/neo-modules/releases) 插件才可以调用。 ## 参数说明 From 92f5d4332fb4f8093b67bf546c5b9bcf15c3cf0f Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 5 Nov 2020 17:37:44 +0800 Subject: [PATCH 03/15] update sc api --- docs/zh-cn/reference/scapi/api/System.md | 32 ++++++++++- docs/zh-cn/reference/scapi/api/neo.md | 71 +++++++++++++++++++----- 2 files changed, 89 insertions(+), 14 deletions(-) diff --git a/docs/zh-cn/reference/scapi/api/System.md b/docs/zh-cn/reference/scapi/api/System.md index b7afce9e6..8e71f279f 100644 --- a/docs/zh-cn/reference/scapi/api/System.md +++ b/docs/zh-cn/reference/scapi/api/System.md @@ -6,8 +6,12 @@ | API | 说明 | |--|--| -| System.Binary.Base64Decode| 将栈元素解码为字节数组 | +| System.Binary.Base64Decode| 将Base64编码的字符串解码为字节数组 | | System.Binary.Base64Encode | 将字节数组编码为Base64字符串 | +| System.Binary.Serialize| 将栈元素序列化为字节数组 | +| System.Binary.Deserialize | 将字节数组反序列化为栈元素 | +| System.Binary.Base58Decode | 将Base58编码的字符串解码为字节数组 | +| System.Binary.Base58Encode| 将字节数组编码为Base58字符串 | **BlockChain API**: @@ -20,6 +24,15 @@ |System.Blockchain.GetTransactionFromBlock|根据区块中交易ID获取交易| |System.Blockchain.GetContract|根据合约哈希获取合约| +**Callback API**: + +| API | 说明 | +|--|--| +|System.Callback.Create|根据栈指针创建回调服务| +|System.Callback.CreateFromMethod|创建指定合约指定方法的回调服务| +|System.Callback.CreateFromSyscall|创建系统调用的回调服务| +|System.Callback.Invoke|调用回调方法| + **Contract API**: | API | 说明 | @@ -30,6 +43,18 @@ |System.Contract.Call|调用合约| |System.Contract.CallEx|根据Flag调用合约| |System.Contract.IsStandard|判断合约是否为标准的单签或多签合约| +|System.Contract.GetCallFlags|获取当前上下文的执行权限| + +**Crypto API**: + +| API | 说明 | +|--|--| +|System.Crypto.RIPEMD160|计算栈元素的RIPEMD160哈希值| +|System.Crypto.SHA256|计算栈元素的Sha256哈希值| +|System.Crypto.VerifyWithECDsaSecp256r1|使用Secp256r1曲线验证单签| +|System.Crypto.VerifyWithECDsaSecp256k1|使用Secp256k1曲线验证单签| +|System.Crypto.CheckMultisigWithECDsaSecp256r1|使用Secp256r1曲线验证多签| +|System.Crypto.CheckMultisigWithECDsaSecp256k1|使用Secp256k1曲线验证多签| **Enumerator API**: @@ -64,9 +89,14 @@ |System.Runtime.Platform|获取当前执行智能合约的平台信息| |System.Runtime.GetTrigger|获取该智能合约的触发条件| |System.Runtime.GetTime|获取当前区块的时间戳| +|System.Runtime.GetScriptContainer|获得该智能合约的脚本容器(最开始的触发者)| +|System.Runtime.GetExecutingScriptHash|获得该智能合约执行的脚本散列| +|System.Runtime.GetCallingScriptHash|获得该智能合约的调用者的脚本散列| +|System.Runtime.GetEntryScriptHash|获得该智能合约的入口点(合约调用链的起点)的脚本散列| |System.Runtime.CheckWitness|验证调用该合约的容器是否被指定账户脚本哈希签名| |System.Runtime.GetInvocationCounter|获取当前合约的调用次数| |System.Runtime.Log|记录合约日志信息| +|System.Runtime.Notify|记录合约通知信息| |System.Runtime.GetNotifications|获取某合约执行的所有通知| |System.Runtime.GasLeft|获取剩余未消耗的GAS数| diff --git a/docs/zh-cn/reference/scapi/api/neo.md b/docs/zh-cn/reference/scapi/api/neo.md index 077beb45d..6180c9366 100644 --- a/docs/zh-cn/reference/scapi/api/neo.md +++ b/docs/zh-cn/reference/scapi/api/neo.md @@ -7,6 +7,7 @@ NEO命名空间提供了原生合约操作以及数字签名验证的API。 | API | 说明 | | -- | --| |Neo.Native.Deploy|部署并初始化所有原生合约| +|Neo.Native.Call|调用原生合约|
@@ -17,7 +18,7 @@ NEO命名空间提供了原生合约操作以及数字签名验证的API。 说明 - Neo.Native.Tokens.NEO + Neo.Native.Tokens.NEO name 获取名称, 即:NEO @@ -41,21 +42,33 @@ NEO命名空间提供了原生合约操作以及数字签名验证的API。 Transfer 转账 + + SetGasPerBlock + 设置每出一个区块所产生的GAS数 + + + GetGasPerBlock + 获取当前每个区块可产生的GAS数 + - RegisterValidator - 注册为验证人 + RegisterCandidate + 注册为候选人 + + + UnregisterCandidate + 取消注册为候选人 Vote 投票 - GetRegisteredValidators - 获取已注册的验证人列表 + GetCandidates + 获取候选人列表 - GetValidators - 获取验证人列表 + GetCommittee + 获取委员会成员列表 UnclaimedGas @@ -111,7 +124,7 @@ NEO命名空间提供了原生合约操作以及数字签名验证的API。 说明 - Neo.Native.Policy + Neo.Native.Policy GetMaxTransactionsPerBlock 获取每区块最大交易数 @@ -119,16 +132,25 @@ NEO命名空间提供了原生合约操作以及数字签名验证的API。 GetMaxBlockSize 获取最大的区块大小 + + GetMaxBlockSystemFee + 获取区块最大的系统费 + GetFeePerByte 获取每字节手续费 + + IsBlocked + 验证是否为黑名单账户 + setMaxBlockSize 设置最大的区块大小 - GetBlockedAccounts - 获取黑名单账户 + + SetMaxBlockSystemFee + 设置区块最大的系统费 SetMaxTransactionsPerBlock 设置每区块最大交易数 @@ -136,16 +158,39 @@ NEO命名空间提供了原生合约操作以及数字签名验证的API。 SetFeePerByte 设置每字节手续费 - BlockAccount + + BlockAccount 设置黑名单账户 - UnblockAccount + + UnblockAccount 解除黑名单账户 + + + + + + + + + + + + + + + + + + + +
API方法名说明
Neo.Native.OracleFinish在获取Oracle响应后调用回调函数
Request发起Oracle请求
Verify验证Oracle响应交易的合法性
+ > [!Note] -> 以上 API 部分用于给Validator调用, 普通用户会在验签过程中失败 +> 以上 API 部分用于给Committee调用, 普通用户会在验签过程中失败 > 以上 API 的源码位于 NEO 项目中的 (https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/PolicyContract.cs) 文件。 **Crypto API**: From b5e8d20afda8cc0d896e6ce96929be3e28b3c403 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Fri, 6 Nov 2020 17:09:50 +0800 Subject: [PATCH 04/15] update sc framework --- .../zh-cn/reference/rpc/latest-version/api.md | 1 - docs/zh-cn/reference/scapi/fw/dotnet/neo.md | 6 ++- .../reference/scapi/fw/dotnet/neo/Contract.md | 8 +-- .../reference/scapi/fw/dotnet/neo/Gas.md | 29 +++++++++++ .../scapi/fw/dotnet/neo/Gas/BalanceOf.md | 34 +++++++++++++ .../scapi/fw/dotnet/neo/Gas/TotalSupply.md | 28 ++++++++++ .../scapi/fw/dotnet/neo/Gas/Transfer.md | 38 ++++++++++++++ .../reference/scapi/fw/dotnet/neo/Json.md | 2 +- .../reference/scapi/fw/dotnet/neo/Native.md | 21 -------- .../scapi/fw/dotnet/neo/Native/GAS.md | 36 ------------- .../scapi/fw/dotnet/neo/Native/NEO.md | 36 ------------- .../scapi/fw/dotnet/neo/Native/Policy.md | 32 ------------ .../reference/scapi/fw/dotnet/neo/Neo.md | 38 ++++++++++++++ .../scapi/fw/dotnet/neo/Neo/BalanceOf.md | 34 +++++++++++++ .../scapi/fw/dotnet/neo/Neo/GetCandidates.md | 28 ++++++++++ .../scapi/fw/dotnet/neo/Neo/GetCommittee.md | 28 ++++++++++ .../scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md | 28 ++++++++++ .../dotnet/neo/Neo/GetNextBlockValidators.md | 28 ++++++++++ .../fw/dotnet/neo/Neo/RegisterCandidate.md | 35 +++++++++++++ .../scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md | 33 ++++++++++++ .../scapi/fw/dotnet/neo/Neo/TotalSupply.md | 28 ++++++++++ .../scapi/fw/dotnet/neo/Neo/Transfer.md | 38 ++++++++++++++ .../fw/dotnet/neo/Neo/UnRegisterCandidate.md | 35 +++++++++++++ .../scapi/fw/dotnet/neo/Neo/UnclaimedGas.md | 35 +++++++++++++ .../reference/scapi/fw/dotnet/neo/Neo/Vote.md | 37 ++++++++++++++ .../reference/scapi/fw/dotnet/neo/Oracle.md | 25 +++++++++ .../scapi/fw/dotnet/neo/Oracle/Request.md | 51 +++++++++++++++++++ .../reference/scapi/fw/dotnet/neo/Policy.md | 30 +++++++++++ .../fw/dotnet/neo/Policy/BlockAccount.md | 34 +++++++++++++ .../fw/dotnet/neo/Policy/GetFeePerByte.md | 28 ++++++++++ .../fw/dotnet/neo/Policy/GetMaxBlockSize.md | 28 ++++++++++ .../dotnet/neo/Policy/GetMaxBlockSystemFee.md | 28 ++++++++++ .../neo/Policy/GetMaxTransactionsPerBlock.md | 28 ++++++++++ .../scapi/fw/dotnet/neo/Policy/IsBlocked.md | 34 +++++++++++++ .../fw/dotnet/neo/Policy/SetFeePerByte.md | 32 ++++++++++++ .../fw/dotnet/neo/Policy/SetMaxBlockSize.md | 32 ++++++++++++ .../dotnet/neo/Policy/SetMaxBlockSystemFee.md | 34 +++++++++++++ .../neo/Policy/SetMaxTransactionsPerBlock.md | 32 ++++++++++++ .../fw/dotnet/neo/Policy/UnblockAccount.md | 34 +++++++++++++ 39 files changed, 1014 insertions(+), 132 deletions(-) create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/TotalSupply.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md delete mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Native.md delete mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/GAS.md delete mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/NEO.md delete mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/Policy.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle/Request.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md diff --git a/docs/zh-cn/reference/rpc/latest-version/api.md b/docs/zh-cn/reference/rpc/latest-version/api.md index 5009159ca..cbd397914 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api.md +++ b/docs/zh-cn/reference/rpc/latest-version/api.md @@ -29,7 +29,6 @@ JSON-RPC 服务器启动后,会监听 TCP 端口,默认端口如下。P2P | [getrawtransaction](api/getrawtransaction.md) | \ [verbose=0] | 根据指定的散列值,返回对应的交易信息 | | [getstorage](api/getstorage.md) | \ \ | 根据合约脚本散列和存储的 key,返回存储的 value | | [gettransactionheight](api/gettransactionheight.md) | \ | 根据交易哈希获取交易所在的区块高度 | -| [getvalidators](api/getvalidators.md) | | 查看当前共识节点的信息 | | [getcommittee](api/getcommittee.md) | | 获取委员会成员公钥列表 | ### 节点 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo.md index 85d1fbe7c..075f73987 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo.md @@ -25,14 +25,18 @@ NEO 命名空间是 NEO 区块链所提供的 API,提供了访问区块链账 | [Runtime](neo/Runtime.md) | 提供智能合约运行时的一些方法 | | [Storage](neo/Storage.md) | 提供了持久化存储区的插入、查询、删除的方法 | | [StorageContext](neo/StorageContext.md) | 用来表示私有存储区存储上下文的类 | -| [StorageFlags](neo/StorageFlags.md) | 表明了写入数据的属性 | | [StorageMap](neo/StorageMap.md) | 表示给定存储上下文中指定前缀的key-value存储区 | | [Transaction](neo/Transaction.md) | 用来表示交易的基类 | +| [NEO](neo/Neo.md) | | +| [GAS](neo/Gas.md) | 用来表示交易的基类 | +| [Policy](neo/Policy.md) | | +| [Oracle](neo/Oracle.md) | | ## 枚举 | 枚举 | 说明 | | ---------------------------------------- | ------------------------- | | [CallFlags](neo/CallFlags.md) | 定义调用合约方法时的模式| +| [StorageFlags](neo/StorageFlags.md) | 表明了写入数据的属性 | | [TriggerType](neo/TriggerType.md) | 定义了触发器类型 | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Contract.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Contract.md index a8be78212..fe7749a1f 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Contract.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Contract.md @@ -26,10 +26,10 @@ public class Contract | 名称 | 说明 | | ---------------------------------------- | --------------- | -| [Call(byte[] scriptHash, string method, object[] arguments)](Contract/Call.md) | 调用智能合约 | -| [CallEx(byte[] scriptHash, string method, object[] arguments, CallFlags flag)](Contract/CallEx.md) | 根据调用权限 Flag 调用合约 | -| [Create(byte[] script, string manifest)](Contract/Create.md) | 新建智能合约 | -| [Update(byte[] script, string manifest)](Contract/Update.md) | 更新智能合约 | +| [Call(byte\[\] scriptHash, string method, object\[\] arguments)](Contract/Call.md) | 调用智能合约 | +| [CallEx(byte\[\] scriptHash, string method, object\[\] arguments, CallFlags flag)](Contract/CallEx.md) | 根据调用权限 Flag 调用合约 | +| [Create(byte\[\] script, string manifest)](Contract/Create.md) | 新建智能合约 | +| [Update(byte\[\] script, string manifest)](Contract/Update.md) | 更新智能合约 | | [Destroy()](Contract/Destroy.md) | 销毁智能合约 | | [GetCallFlags()](Contract/GetCallFlags.md) | 获取合约的调用权限 Flag | | [CreateStandardAccount()](Contract/CreateStandardAccount.md) | 根据公钥创建标准账户 | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md new file mode 100644 index 000000000..c21c668aa --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md @@ -0,0 +1,29 @@ +# GAS 类 + +提供了原生合约GasToken的一系列属性与方法。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public class GAS +``` + +## 属性 + +| 名称 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Name | 获取名称, GAS | +| Symbol | 获取符号, 即: gas | +| Decimals | 获取精度 | + +## 方法 + +| 名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [TotalSupply()](Gas/TotalSupply.md) | 获取GAS总发行量 | +| [BalanceOf(byte\[\] account)](Gas/BalanceOf.md) | 获取余额 | +| [Transfer(byte\[\] from, byte\[\] to, BigInteger amount)](Gas/Transfer.md) | 转账 | \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md new file mode 100644 index 000000000..9df0d95e8 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md @@ -0,0 +1,34 @@ +# BalanceOf 方法 (byte[]) + +获取账户的GAS余额。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger BalanceOf(byte[] account); +``` + +参数: + +- account: 所查询账户的脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = GAS.BalanceOf(account); + return result; + } +} +``` + +[返回上级](../Gas.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/TotalSupply.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/TotalSupply.md new file mode 100644 index 000000000..fa3760589 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/TotalSupply.md @@ -0,0 +1,28 @@ +# TotalSupply 方法 () + +获取GAS总发行量。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger TotalSupply(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = GAS.TotalSupply(); + return result; + } +} +``` + +[返回上级](../Gas.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md new file mode 100644 index 000000000..041708acb --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md @@ -0,0 +1,38 @@ +# Transfer 方法 (byte[], byte[], BigInteger) + +GAS转账。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); +``` + +参数: + +- from: 转出账户的脚本哈希; +- to: 转入账户的脚本哈希; +- amount: 要转账的金额。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + + public static object Main() + { + BigInterger value = 1000; + bool result = GAS.Transfer(from, to, value); + return result; + } +} +``` + +[返回上级](../Gas.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Json.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Json.md index fe42be50d..7026f8c7e 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Json.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Json.md @@ -12,7 +12,7 @@ public static class Json ``` -## 属性 +## 方法 | 名称 | 说明 | | ---------------------------------------- | -------------------------- | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native.md deleted file mode 100644 index e2849000e..000000000 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native.md +++ /dev/null @@ -1,21 +0,0 @@ -# Native 类 - -表示Neo区块链中的原生合约类。 - -命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) - -程序集:Neo.SmartContract.Framework - -## 语法 - -```c# -public class Native -``` - -## 属性 - -| 名称 | 说明 | -| ---------------------------------------- | -------------------------- | -| [NEO(string method, object\[\] arguments)](Native/NEO.md) | 原生合约NeoToken | -| [GAS(string method, object\[\] arguments)](Native/GAS.md) | 原生合约GasToken | -| [Policy(string method, object\[\] arguments)](Native/Policy.md) | 原生合约PolicyContract | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/GAS.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/GAS.md deleted file mode 100644 index 76319bfe6..000000000 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/GAS.md +++ /dev/null @@ -1,36 +0,0 @@ -# Native.GAS 方法 (string, object[]) - -根据方法名与方法参数调用GAS合约中的方法。 - -命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) - -程序集:Neo.SmartContract.Framework - -## 语法 - -```c# -public static extern object GAS(string method, object[] arguments); -``` - -参数: - -- method: 方法名称; -- arguments: 方法参数。 - -## 示例 - -```c# -public class Contract1 : SmartContract.Framework.SmartContract -{ - public static object Main() - { - byte[] from = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW".ToScriptHash(); - byte[] to = "NUo4WsPRJCrSLriRhKwduWvoG2CxHwsdfi".ToScriptHash(); - BigInterger value = new BigInteger(1000); - bool result = Native.GAS("transfer", new Object[]{from, to, value.AsByteArray()}); - return result; - } -} -``` - -[返回上级](../Native.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/NEO.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/NEO.md deleted file mode 100644 index a5a853c39..000000000 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/NEO.md +++ /dev/null @@ -1,36 +0,0 @@ -# Native.NEO 方法 (string, object[]) - -根据方法名与方法参数调用NEO合约中的方法。 - -命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) - -程序集:Neo.SmartContract.Framework - -## 语法 - -```c# -public static extern object NEO(string method, object[] arguments); -``` - -参数: - -- method: 方法名称; -- arguments: 方法参数。 - -## 示例 - -```c# -public class Contract1 : SmartContract.Framework.SmartContract -{ - public static object Main() - { - byte[] from = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW".ToScriptHash(); - byte[] to = "NUo4WsPRJCrSLriRhKwduWvoG2CxHwsdfi".ToScriptHash(); - BigInterger value = new BigInteger(1000); - bool result = Native.NEO("transfer", new Object[]{from, to, value.AsByteArray()}); - return result; - } -} -``` - -[返回上级](../Native.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/Policy.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/Policy.md deleted file mode 100644 index a97a7227b..000000000 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native/Policy.md +++ /dev/null @@ -1,32 +0,0 @@ -# Native.Policy 方法 (string, object[]) - -根据方法名与方法参数调用Policy合约中的方法。 - -命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) - -程序集:Neo.SmartContract.Framework - -## 语法 - -```c# -public static extern object Policy(string method, object[] arguments); -``` - -参数: - -- method: 方法名称; -- arguments: 方法参数。 - -## 示例 - -```c# -public class Contract1 : SmartContract.Framework.SmartContract -{ - public static object Main() - { - BigInteger feeByte = (BigInteger)Native.Policy("getFeePerByte", new object[]{}); - } -} -``` - -[返回上级](../Native.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md new file mode 100644 index 000000000..9d62ac763 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md @@ -0,0 +1,38 @@ +# Neo 类 + +提供了原生合约NeoToken的一系列属性与方法。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public class NEO +``` + +## 属性 + +| 名称 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Name | 获取名称, 即:NEO | +| Symbol | 获取符号, 即: neo | +| Decimals | 获取精度 | + +## 方法 + +| 名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [TotalSupply()](Neo/TotalSupply.md) | 获取NEO总发行量 | +| [BalanceOf(byte\[\] account)](Neo/BalanceOf.md) | 获取余额 | +| [Transfer(byte\[\] from, byte\[\] to, BigInteger amount)](Neo/Transfer.md) | 转账 | +| [SetGasPerBlock(BigInteger gasPerBlock)](Neo/SetGasPerBlock.md) | 设置每出一个区块所产生的GAS数 | +| [GetGasPerBlock()](Neo/GetGasPerBlock.md) | 获取当前每个区块可产生的GAS数 | +| [UnclaimedGas(byte\[\] account, uint end)](Neo/UnclaimedGas.md) | 获取未领取的Gas数 | +| [RegisterCandidate(byte\[\] pubkey)](Neo/RegisterCandidate.md) | 注册为候选人 | +| [UnRegisterCandidate(byte\[\] pubkey)](Neo/UnRegisterCandidate.md) | 取消注册为候选人 | +| [Vote(byte\[\] account, byte\[\] voteTo)](Neo/Vote.md) | 投票 | +| [GetCandidates()](Neo/GetCandidates.md) | 获取候选人列表 | +| [GetCommittee()](Neo/GetCommittee.md) | 获取委员会成员列表 | +| [GetNextBlockValidators()](Neo/GetNextBlockValidators.md) | 获取下个区块的验证人列表 | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md new file mode 100644 index 000000000..5ae27daa6 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md @@ -0,0 +1,34 @@ +# BalanceOf 方法 (byte[]) + +获取账户的NEO余额。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger BalanceOf(byte[] account); +``` + +参数: + +- account: 所查询账户的脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = NEO.BalanceOf(account); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md new file mode 100644 index 000000000..574a15705 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -0,0 +1,28 @@ +# GetCandidates 方法 () + +获取候选人列表。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern (string, BigInteger)[] GetCandidates(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + (string, BigInteger)[] result = NEO.GetCandidates(); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md new file mode 100644 index 000000000..e8ad43f97 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -0,0 +1,28 @@ +# GetCommittee 方法 () + +获取委员会成员列表。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern string[] GetCommittee(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + string[] result = NEO.GetCommittee(); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md new file mode 100644 index 000000000..b24dbf780 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md @@ -0,0 +1,28 @@ +# GetGasPerBlock 方法 () + +获取当前每个区块可产生的GAS数。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger GetGasPerBlock(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = NEO.GetGasPerBlock(); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md new file mode 100644 index 000000000..c28ead9ed --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -0,0 +1,28 @@ +# GetNextBlockValidators 方法 () + +获取下个区块的验证人列表。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern string[] GetNextBlockValidators(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + string[] result = NEO.GetNextBlockValidators(); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md new file mode 100644 index 000000000..092146815 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md @@ -0,0 +1,35 @@ +# RegisterCandidate 方法 (byte[]) + +注册成为候选人。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool RegisterCandidate(byte[] pubkey); +``` + +参数: + +- pubkey: 要注册账户的公钥。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] pubkey = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, + 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + + public static object Main() + { + bool result = NEO.RegisterCandidate(pubkey); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md new file mode 100644 index 000000000..6d68b13f9 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md @@ -0,0 +1,33 @@ +# SetGasPerBlock 方法 (BigInteger) + +设置每出一个区块所产生的GAS数。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool SetGasPerBlock(BigInteger gasPerBlock); +``` + +参数: + +- gasPerBlock: 每区块所产生的GAS数 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger gasPerBlock = 10; + bool result = NEO.SetGasPerBlock(gasPerBlock); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md new file mode 100644 index 000000000..4e4c976d8 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md @@ -0,0 +1,28 @@ +# TotalSupply 方法 () + +获取NEO总发行量。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger TotalSupply(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = NEO.TotalSupply(); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md new file mode 100644 index 000000000..3cddd1ca8 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -0,0 +1,38 @@ +# Transfer 方法 (byte[], byte[], BigInteger) + +NEO转账。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); +``` + +参数: + +- from: 转出账户的脚本哈希; +- to: 转入账户的脚本哈希; +- amount: 要转账的金额。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + + public static object Main() + { + BigInterger value = 1000; + bool result = NEO.Transfer(from, to, value); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md new file mode 100644 index 000000000..c709137b4 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md @@ -0,0 +1,35 @@ +# UnRegisterCandidate 方法 (byte[]) + +取消注册为候选人。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool UnRegisterCandidate(byte[] pubkey); +``` + +参数: + +- pubkey: 要取消账户的公钥。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] pubkey = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, + 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + + public static object Main() + { + bool result = NEO.UnRegisterCandidate(pubkey); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md new file mode 100644 index 000000000..6833f9bd6 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md @@ -0,0 +1,35 @@ +# UnclaimedGas 方法 (byte[], uint) + +获取未领取的Gas数. + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger UnclaimedGas(byte[] account, uint end); +``` + +参数: + +- account: 所查询账户的脚本哈希; +- end:截止到的区块高度 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = NEO.UnclaimedGas(account, 100); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md new file mode 100644 index 000000000..ff15ba21b --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md @@ -0,0 +1,37 @@ +# Vote 方法 (byte[], byte[]) + +投票。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool Vote(byte[] account, byte[] voteTo); +``` + +参数: + +- account: 投票账户的脚本哈希; +- voteTo: 目标账户的公钥。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] voteTo = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, + 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + + public static object Main() + { + bool result = NEO.Vote(account, voteTo); + return result; + } +} +``` + +[返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md new file mode 100644 index 000000000..ee734b033 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md @@ -0,0 +1,25 @@ +# Oracle 类 + +提供了原生合约Oracle的一系列方法。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public class Oracle +``` + +## 属性 + +| 名称 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Name | 合约名称 | + +## 方法 + +| 名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [Request(string url, string filter, string callback, object userData, long gasForResponse)](Oracle/Request.md) | 发起Oracle请求 | \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle/Request.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle/Request.md new file mode 100644 index 000000000..1f81315ae --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle/Request.md @@ -0,0 +1,51 @@ +# Request 方法 (string, string, string, object, long) + +发起Oracle请求。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern void Request(string url, string filter, string callback, object userData, long gasForResponse); +``` + +参数: + +- url: 请求的Url; +- filter: 过滤器,可用于过滤无用数据; +- callback:回调函数; +- userData: 用户提供的额外数据; +- long: 获取响应所需的费用 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static void Main() + { + string url = "http://127.0.0.1:8080/test"; + string filter = "$.value"; // JSONPath, { "value": "hello world" } + string callback = "callback"; + object userdata = "userdata"; // arbitrary type + long gasForResponse = 10000000; // minimum fee + + Oracle.Request(url, filter, callback, userdata, gasForResponse); + } + + public static void Callback(string url, string userdata, int code, string result) + { + object ret = Json.Deserialize(result); // [ "hello world" ] + object[] arr = (object[])ret; + string value = (string)arr[0]; + + Runtime.Log("userdata: " + userdata); + Runtime.Log("response value: " + value); + } +} +``` + +[返回上级](../Oracle.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md new file mode 100644 index 000000000..72887e047 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md @@ -0,0 +1,30 @@ +# Policy 类 + +提供了原生合约Policy的一系列方法。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public class Policy +``` + +## 方法 + +| 名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| Name() | 合约名称 | +| [GetMaxTransactionsPerBlock()](Policy/GetMaxTransactionsPerBlock.md) | 获取每区块最大交易数 | +| [GetMaxBlockSize()](Policy/GetMaxBlockSize.md) | 获取区块最大大小 | +| [GetMaxBlockSystemFee()](Policy/GetMaxBlockSystemFee.md) | 获取区块最大的系统费 | +| [GetFeePerByte()](Policy/GetFeePerByte.md) | 获取每字节手续费 | +| [IsBlocked(byte\[\] account)](Policy/IsBlocked.md) | 验证是否为黑名单账户 | +| [SetMaxBlockSize(uint value)](Policy/SetMaxBlockSize.md) | 设置最大区块大小 | +| [SetMaxTransactionsPerBlock(uint value)](Policy/SetMaxTransactionsPerBlock.md) | 设置每区块最大交易数 | +| [SetMaxBlockSystemFee(long value)](Policy/SetMaxBlockSystemFee.md) | 设置区块最大系统手续费 | +| [SetFeePerByte(long value)](Policy/SetFeePerByte.md) | 设置每字节手续费 | +| [BlockAccount(byte\[\] account)](Policy/BlockAccount.md) | 将指定账户加入黑名单 | +| [UnblockAccount(byte\[\] account)](Policy/UnblockAccount.md) | 将指定账户解除黑名单 | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md new file mode 100644 index 000000000..aa6db0ac6 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md @@ -0,0 +1,34 @@ +# BlockAccount 方法 (byte[]) + +将指定账户加入黑名单。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool BlockAccount(byte[] account); +``` + +参数: + +- account: 待加入黑名单的账户脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + + public static object Main() + { + bool result = Policy.BlockAccount(account); + return result; + } +} +``` + +[返回上级](../Policy.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md new file mode 100644 index 000000000..855041fa5 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md @@ -0,0 +1,28 @@ +# GetFeePerByte 方法 () + +获取每字节手续费。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger GetFeePerByte(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = Policy.GetFeePerByte(); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md new file mode 100644 index 000000000..dd1e05e73 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md @@ -0,0 +1,28 @@ +# GetMaxBlockSize 方法 () + +获取区块最大大小。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern uint GetMaxBlockSize(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + uint result = Policy.GetMaxBlockSize(); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md new file mode 100644 index 000000000..adfb80a55 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md @@ -0,0 +1,28 @@ +# GetMaxBlockSystemFee 方法 () + +获取区块最大的系统费。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern long GetMaxBlockSystemFee(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + long result = Policy.GetMaxBlockSystemFee(); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md new file mode 100644 index 000000000..57b2d8218 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md @@ -0,0 +1,28 @@ +# GetMaxTransactionsPerBlock 方法 () + +获取每区块最大交易数。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern uint GetMaxTransactionsPerBlock(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + uint result = Policy.GetMaxTransactionsPerBlock(); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md new file mode 100644 index 000000000..697b0b1d8 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md @@ -0,0 +1,34 @@ +# IsBlocked 方法 (byte[]) + +验证是否为黑名单账户。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern string[] IsBlocked(byte[] account); +``` + +参数: + +- account: 待验证账户的脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + string[] result = Policy.IsBlocked(account); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md new file mode 100644 index 000000000..dff670f66 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md @@ -0,0 +1,32 @@ +# SetFeePerByte 方法 (long) + +设置每字节手续费。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool SetFeePerByte(long value); +``` + +参数: + +- value: 待设置的每字节手续费 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetFeePerByte(1200); + return result; + } +} +``` + +[返回上级](../Policy.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md new file mode 100644 index 000000000..4c9777676 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md @@ -0,0 +1,32 @@ +# SetMaxBlockSize 方法 (uint) + +设置最大区块大小。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool SetMaxBlockSize(uint value); +``` + +参数: + +- value: 待设置的区块大小值 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetMaxBlockSize(1024); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md new file mode 100644 index 000000000..50e65db4f --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md @@ -0,0 +1,34 @@ +# SetMaxBlockSystemFee 方法 (uint) + +设置区块最大系统手续费。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool SetMaxBlockSystemFee(long value); +``` + +参数: + +- value: 待设置的区块最大系统手续费 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetMaxBlockSystemFee(4007800L); + return result; + } +} +``` + +[返回上级](../Policy.md) + +>注:设置的手续费值应不小于4007600。 \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md new file mode 100644 index 000000000..7af61ea71 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md @@ -0,0 +1,32 @@ +# SetMaxTransactionsPerBlock 方法 (uint) + +设置每区块最大交易数。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool SetMaxTransactionsPerBlock(uint value); +``` + +参数: + +- value: 待设置的最大交易数 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetMaxTransactionsPerBlock(1024); + return result; + } +} +``` + +[返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md new file mode 100644 index 000000000..25b3756fc --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md @@ -0,0 +1,34 @@ +# UnblockAccount 方法 (byte[]) + +将指定账户解除黑名单。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool UnblockAccount(byte[] account); +``` + +参数: + +- account: 待解除黑名单的账户脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + + public static object Main() + { + bool result = Policy.UnblockAccount(account); + return result; + } +} +``` + +[返回上级](../Policy.md) From 2b0d9ab19fa5b0528ed2aea852cb991bddc0789b Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Mon, 9 Nov 2020 10:41:08 +0800 Subject: [PATCH 05/15] update fee --- docs/zh-cn/reference/fees.md | 120 +++++++++++++++++++++++++---------- 1 file changed, 85 insertions(+), 35 deletions(-) diff --git a/docs/zh-cn/reference/fees.md b/docs/zh-cn/reference/fees.md index 546dc8b0f..14e3ab579 100644 --- a/docs/zh-cn/reference/fees.md +++ b/docs/zh-cn/reference/fees.md @@ -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 | @@ -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 | @@ -77,7 +83,7 @@ - + @@ -101,24 +107,41 @@ - - + + - + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + +
费用 (GAS)
Neo.Native.Tokens.NEONeo.Native.Tokens.NEO name 0
transfer 0.08000000
registerValidator
setGasPerBlock 0.05000000
getGasPerBlock0.05000000
unclaimedGas0.03000000
registerCandidate0.05000000
unregisterCandidate0.05000000
vote5.000000000.08000000
getRegisteredValidators
GetCandidates 1.00000000
getValidators
getCommittee 1.00000000
unclaimedGas0.03000000
getNextBlockValidators1.00000000
@@ -166,7 +189,7 @@ 费用 (GAS) - Neo.Native.Policy + Neo.Native.Policy getMaxTransactionsPerBlock 0.01000000 @@ -175,30 +198,57 @@ 0.01000000 - getFeePerByte + GetMaxBlockSystemFee 0.01000000 - setMaxBlockSize - 0.03000000 + GetFeePerByte + 0.01000000 - getBlockedAccounts + IsBlocked 0.01000000 - setMaxTransactionsPerBlock + SetMaxBlockSize + 0.03000000 + + SetMaxTransactionsPerBlock + 0.03000000 + + SetMaxBlockSystemFee 0.03000000 - setFeePerByte + SetFeePerByte 0.03000000 - blockAccount + BlockAccount 0.03000000 - unblockAccount + UnblockAccount 0.03000000 + + + + + + + + + + + + + + + + + + + +
互操作服务方法名费用 (GAS)
Neo.Native.Oraclefinish0
request0.50000000
verify0.01000000
+ 关于表格中API的含义,请参见 [NEO命名空间](../reference/scapi/api/neo.md)。 ### 指令费用 From e73616478eb2e0ce3fa4dbb5eaee5a09571a03fb Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 12 Nov 2020 14:34:54 +0800 Subject: [PATCH 06/15] some updates in develop --- docs/zh-cn/develop/deploy/Parameter.md | 44 +++++++++++++++----------- docs/zh-cn/develop/deploy/deploy.md | 6 ++-- docs/zh-cn/develop/deploy/invoke.md | 6 ++-- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/docs/zh-cn/develop/deploy/Parameter.md b/docs/zh-cn/develop/deploy/Parameter.md index ab2ff3e7f..4446be4da 100644 --- a/docs/zh-cn/develop/deploy/Parameter.md +++ b/docs/zh-cn/develop/deploy/Parameter.md @@ -8,36 +8,42 @@ /// public enum ContractParameterType : byte { + Any = 0x00, + + Boolean = 0x10, /// - /// 签名 + /// 整数 /// - Signature = 0, - Boolean = 1, + Integer = 0x11, /// - /// 整数 + /// 字节数组 /// - Integer = 2, + ByteArray = 0x12, + String = 0x13, /// /// 160位散列值 /// - Hash160 = 3, + Hash160 = 0x14, /// /// 256 位散列值 /// - Hash256 = 4, + Hash256 = 0x15, + PublicKey = 0x16, /// - /// 字节数组 + /// 签名 /// - ByteArray = 5, - PublicKey = 6, - String = 7, - - /// - /// 对象数组 - /// - Array = 10, - InteropInterface = 0xf0, + Signature = 0x17, + + /// + /// 对象数组 + /// + Array = 0x20, + Map = 0x22, + + InteropInterface = 0x30, + Void = 0xff + } ``` @@ -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。 \ No newline at end of file +在 NEO-GUI 客户端发布智能合约填写参数时,每个参数用两位 16 进制字符表示,所以上面的智能合约的形参列表表示为:11101617,返回值为:10。 \ No newline at end of file diff --git a/docs/zh-cn/develop/deploy/deploy.md b/docs/zh-cn/develop/deploy/deploy.md index 081ec33d7..0f4ab975a 100644 --- a/docs/zh-cn/develop/deploy/deploy.md +++ b/docs/zh-cn/develop/deploy/deploy.md @@ -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)。 diff --git a/docs/zh-cn/develop/deploy/invoke.md b/docs/zh-cn/develop/deploy/invoke.md index 8c3df6615..aa4816e1b 100644 --- a/docs/zh-cn/develop/deploy/invoke.md +++ b/docs/zh-cn/develop/deploy/invoke.md @@ -4,7 +4,7 @@ ## 合约详情查询 -使用 Neo-CLI 或 Neo-GUI 可以查询合约的详细信息,如合约的基本信息、入口点、方法、通知等。 +使用 Neo-CLI 或 Neo-GUI 可以查询合约的详细信息,如合约的基本信息、方法、通知等。 ### 使用 Neo-CLI 查询 @@ -26,7 +26,7 @@ Neo-GUI 中会更直观地显示合约信息,也能查看 manifest 和 nef 文 - 使用 invoke 命令调用智能合约,命令如下: ``` - invoke [contractParameters=null] [witnessAddress=null] + invoke [contractParameters=null] [sender=null] [signerAccounts=null] ``` 详情请参考 [invoke](../../node/cli/cli.md#invoke) 命令。 @@ -58,7 +58,7 @@ Neo-GUI 中会更直观地显示合约信息,也能查看 manifest 和 nef 文 在 Neo-CLI 中,我们可以通过 `invoke` 命令附加签名。 ``` -invoke [contractParameters=null] [witnessAddress=null] +invoke [contractParameters=null] [sender=null] [signerAccounts=null] ``` 在 Neo-GUI 中,在调用合约时,可以点击下方的 `附加签名`,选择 `公钥` 然后点击 `签名` 来进行附加签名。 From 8ebe60276435e4179fd9e0179b41d9221ddd162a Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 12 Nov 2020 14:40:53 +0800 Subject: [PATCH 07/15] update opcode fee --- docs/zh-cn/reference/fees.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/zh-cn/reference/fees.md b/docs/zh-cn/reference/fees.md index 14e3ab579..fa730fd68 100644 --- a/docs/zh-cn/reference/fees.md +++ b/docs/zh-cn/reference/fees.md @@ -311,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| @@ -334,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| @@ -361,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| @@ -372,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| From 5f1e108c66a6f5274fee20d684d7828546a0a658 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Mon, 23 Nov 2020 12:07:16 +0800 Subject: [PATCH 08/15] update intro --- docs/zh-cn/intro/glossary.md | 8 ++++---- docs/zh-cn/intro/introduction.md | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/zh-cn/intro/glossary.md b/docs/zh-cn/intro/glossary.md index 87b0e2840..b58990f07 100644 --- a/docs/zh-cn/intro/glossary.md +++ b/docs/zh-cn/intro/glossary.md @@ -26,7 +26,7 @@ Neo 交易是一个带有网络操作指令的签名数据包,例如,将资 ``` PUSHDATA1 03ac765294075da6f7927c96bfe3d3f64ae3680c5eb50f82f55170a9f1bea59dad -SYSCALL Neo.Crypto.ECDsaVerify +SYSCALL Neo.Crypto.VerifyWithECDsaSecp256r1 ``` #### 脚本哈希 @@ -51,15 +51,15 @@ NEP5 协议是 Neo 补充协议中的第5号协议。其目的是为 Neo 建立 #### 系统调用(SysCall) -系统调用是一种特殊的操作码。通过 SycCall 可以调用互操作服务层接口。 SycCall 打通了 NeoVM 与外部世界的通道。通过调用互操作服务层接口, NeoVM 可以访问智能合约执行时所需要的区块、交易、合约、资产信息等数据。请参考 [Neo 智能合约模块](https://github.com/neo-project/neo/tree/master/src/neo/SmartContract) 中里面以 `InteropService.` 开头的文件,如 `InteropService.Binary.cs`、`InteropService.Blockchain.cs` +系统调用是一种特殊的操作码。通过 SycCall 可以调用互操作服务层接口。 SycCall 打通了 NeoVM 与外部世界的通道。通过调用互操作服务层接口, NeoVM 可以访问智能合约执行时所需要的区块、交易、合约、资产信息等数据。请参考 [Neo 智能合约模块](https://github.com/neo-project/neo/tree/master/src/neo/SmartContract) 中里面以 `ApplicationEngine.` 开头的文件,如 `ApplicationEngine.Contract.cs`、`ApplicationEngine.Blockchain.cs` #### 动态调用 -动态调用是一种特殊的系统调用,是指在合约中调用另一个合约。其写法为 `Contract.Call(scriptHash, method, params)`。详情请参见 [调用合约](sc/deploy/invoke)。 +动态调用是一种特殊的系统调用,是指在合约中调用另一个合约。其写法为 `Contract.Call(scriptHash, method, params)`。详情请参见 [调用合约](../reference/scapi/fw/dotnet/neo/Contract/Call.md)。 #### 存储区 -每个被部署到 Neo 区块链上的智能合约程序,都拥有一个私有存储区用于存放应用程序的数据。当创建一个智能合约或者交易使用这个合约时,合约的代码需要读写它的存储空间。每个合约都可以声明一块存储区,声名方式为在合约的类上添加一段自定义特性。详情请参见 [存储区操作](sc/sample/storage.md) +每个被部署到 Neo 区块链上的智能合约程序,都拥有一个私有存储区用于存放应用程序的数据。当创建一个智能合约或者交易使用这个合约时,合约的代码需要读写它的存储空间。每个合约都可以声明一块存储区,声名方式为在合约的类上添加一段自定义特性。详情请参见 [存储区操作](../reference/scapi/fw/dotnet/neo/storage.md) #### NEF diff --git a/docs/zh-cn/intro/introduction.md b/docs/zh-cn/intro/introduction.md index 490926692..bbca62107 100644 --- a/docs/zh-cn/intro/introduction.md +++ b/docs/zh-cn/intro/introduction.md @@ -6,15 +6,15 @@ ## Neo 智能合约有哪些特点? -Neo 智能合约 2.0 包括以下特性:确定性、高性能、拓展性。 +Neo 智能合约包括以下特性:确定性、高性能、拓展性。 -从性能角度来说,Neo 采用了轻量级的 NeoVM(Neo Virtual Machine)作为其智能合约的执行环境,其启动速度非常快,占用资源也很小,适合像智能合约这样短小的程序。通过 JIT(即时编译器)技术对热点智能合约进行静态编译和缓存可以显著提升性能。Neo 虚拟机的指令集中内建了一系列的密码学指令,以优化智能合约中用到密码学算法时的执行效率。此外,数据操作指令直接对数组及复杂数据结构提供支持。这些都会提升 Neo 智能合约 2.0 的运行性能。 +从性能角度来说,Neo 采用了轻量级的 NeoVM(Neo Virtual Machine)作为其智能合约的执行环境,其启动速度非常快,占用资源也很小,适合像智能合约这样短小的程序。通过 JIT(即时编译器)技术对热点智能合约进行静态编译和缓存可以显著提升性能。Neo 虚拟机的指令集中内建了一系列的密码学指令,以优化智能合约中用到密码学算法时的执行效率。此外,数据操作指令直接对数组及复杂数据结构提供支持。这些都会提升 Neo 智能合约的运行性能。 -Neo 智能合约 2.0 实现可拓展性的方法是通过高并发和动态分区的形式,结合其低耦合的设计完成的。低耦合合约程序在一个虚拟机(Neo 虚拟机)中执行,并通过交互服务层与外部通信。因此,对智能合约功能的绝大部分升级,都可以通过增加交互服务层的 API 来实现。 +Neo 智能合约实现可拓展性的方法是通过高并发和动态分区的形式,结合其低耦合的设计完成的。低耦合合约程序在一个虚拟机(Neo 虚拟机)中执行,并通过交互服务层与外部通信。因此,对智能合约功能的绝大部分升级,都可以通过增加交互服务层的 API 来实现。 ## 用什么语言编写智能合约? -从语言角度看 Neo 智能合约 2.0 与以太坊的区别更为直观:与以太坊原创的 Solidity 语言不同,Neo 智能合约开发者可以直接使用几乎任何他们擅长的高级语言来进行 Neo 智能合约的开发工作。Neo 提供了这些语言的编译器和插件,用于将高级语言编译成 Neo 虚拟机所支持的指令集。由于编译器会针对 MSIL(微软中间语言)来进行编译,所以理论上任何.Net 中的语言或者可被转译成 MSIL 的语言都可以直接支持。 +从语言角度看 Neo 智能合约与以太坊的区别更为直观:与以太坊原创的 Solidity 语言不同,Neo 智能合约开发者可以直接使用几乎任何他们擅长的高级语言来进行 Neo 智能合约的开发工作。Neo 提供了这些语言的编译器和插件,用于将高级语言编译成 Neo 虚拟机所支持的指令集。由于编译器会针对 MSIL(微软中间语言)来进行编译,所以理论上任何.Net 中的语言或者可被转译成 MSIL 的语言都可以直接支持。 当前已经支持的语言有: @@ -30,11 +30,11 @@ Neo 智能合约 2.0 实现可拓展性的方法是通过高并发和动态分 多种高级语言的支持,使得 90% 以上的开发者无需学习新的语言即可参与到 Neo 智能合约的开发中来,甚至可将现有业务系统中的代码直接移植到区块链上。这将大大增加未来区块链的全面普及。 -最后从调试角度看,通常智能合约的开发过程是非常困难的,重要的原因之一是此前的智能合约缺乏良好的调试和测试方法。Neo 在 NeoVM 层面提供了程序调试功能的支持,使得开发 Neo 智能合约 2.0变得更方便快捷。 +最后从调试角度看,通常智能合约的开发过程是非常困难的,重要的原因之一是此前的智能合约缺乏良好的调试和测试方法。Neo 在 NeoVM 层面提供了程序调试功能的支持,使得开发 Neo 智能合约变得更方便快捷。 ## 智能合约的触发 -Neo 智能合约 2.0 包括四种触发器类型:系统触发器,验证触发器,应用触发器和全面触发器(包含前面三种)。常用的是验证触发器和应用触发器。 +Neo 智能合约包括六种触发器类型:OnPersist, PostPersist, Verification, Application, System(包含OnPersist和PostPersist)和 All(包含前面五种)。智能合约常用的是Verification(验证)触发器和Application(应用)触发器。 以上两种常用的触发器类型决定了 Neo 智能合约的两种触发方式: @@ -47,13 +47,13 @@ Neo 智能合约 2.0 包括四种触发器类型:系统触发器,验证触 NeoVM 是执行 Neo 智能合约代码的虚拟机。这里所讲述的虚拟机概念比较狭义,并非是借助于操作系统对物理机器的一种模拟,这里的虚拟机与 vmware 或者 Hyper-V 不同,是针对具体语言所实现的虚拟机。 -例如在 java 的 JVM 或者 .Net 的 CLR 中,java 或者 .Net 源码会被编译成相关字节码,然后在对应虚拟机上运行, JVM 或 CLR 会对这些字节码进行取指令,译码,执行,结果回写等操作,这些步骤和真实物理机器上的概念都很相似。相对应的二进制指令仍然是在物理机器上运行,物理机器从内存中取指令,通过总线传输到 CPU,然后译码、执行、存储结果。更多关于 NeoVM 的信息,请参阅 [NeoVM 指令集](../../reference/neo_vm.md)。 +例如在 java 的 JVM 或者 .Net 的 CLR 中,java 或者 .Net 源码会被编译成相关字节码,然后在对应虚拟机上运行, JVM 或 CLR 会对这些字节码进行取指令,译码,执行,结果回写等操作,这些步骤和真实物理机器上的概念都很相似。相对应的二进制指令仍然是在物理机器上运行,物理机器从内存中取指令,通过总线传输到 CPU,然后译码、执行、存储结果。更多关于 NeoVM 的信息,请参阅 [NeoVM 指令集](../reference/neo_vm.md)。 ## 收费模式 Neo 智能合约在部署或者执行的时候都要缴纳一定的手续费,分为部署费用和执行费用。 -部署费用是指开发者将一个智能合约部署到区块链上需要向区块链系统支付一定的费用,根据合约所需功能,系统将收取100~ 1000 GAS 的费用,并作为系统收益。执行费用是指每执行一条智能合约的指令都会向 Neo 系统支付一定的执行费用。所有的操作都有费用,且大部分的操作默认为 0.001 GAS。每个智能合约都有 10 GAS 的免费额度。人为的提高执行费用可以让合约优先执行。更多关于收费的信息,请参阅 [智能合约费用](../fees.md)。 +部署费用是指开发者将一个智能合约部署到区块链上需要向区块链系统支付一定的费用,部署费用与脚本大小以及合约manifest文件大小有关,具体为`StoragePrice * (script.Length + manifest.Length)`,其中StoragePrice为每字节存储费用,当前为0.001 GAS。执行费用是指每执行一条智能合约的指令都会向 Neo 系统支付一定的执行费用。所有的操作都有费用,且大部分的操作默认为 0.001 GAS。人为的提高执行费用可以让合约优先执行。更多关于收费的信息,请参阅 [智能合约费用](../fees.md)。 ## 一些简单的智能合约(C#) From 87db29de65f8546f84d19a729c234588eac97184 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Mon, 23 Nov 2020 16:25:30 +0800 Subject: [PATCH 09/15] update nep5 --- docs/zh-cn/develop/write/nep5.md | 71 ++++++++++++++------------------ 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/docs/zh-cn/develop/write/nep5.md b/docs/zh-cn/develop/write/nep5.md index c6a60d19d..00f9bbc28 100644 --- a/docs/zh-cn/develop/write/nep5.md +++ b/docs/zh-cn/develop/write/nep5.md @@ -1,8 +1,8 @@ -# NEP-5 +# NEP-17 -NEP5 协议是 Neo 补充协议中的第5号协议。其目的是为 Neo 建立标准的 token 化智能合约通用交互机制。NEP5资产是在合约存储区内记账,通过对存储区内不同账户 hash 所记录余额数值的变化,完成交易。 +NEP17 协议是 Neo 补充协议中的第17号协议,替代了原先的NEP5协议。其目的是为 Neo 建立标准的 token 化智能合约通用交互机制。NEP17资产是在合约存储区内记账,通过对存储区内不同账户 hash 所记录余额数值的变化,完成交易。 -参照 NEP5 协议的要求,在编写 NEP5 资产智能合约时必须实现以下方法: +参照 NEP17 协议的要求,在编写 NEP17 资产智能合约时必须实现以下方法: **totalSupply** @@ -10,17 +10,7 @@ NEP5 协议是 Neo 补充协议中的第5号协议。其目的是为 Neo 建立 public static BigInteger totalSupply() ``` -Returns 部署在系统内该 token 的总数。 - -**name** - -```c# -public static string name() -``` - -Returns token的名称. e.g. "MyToken"。 - -该方法每次被调用时必需返回一样的值。 +返回部署在系统内该 token 的总数。 **symbol** @@ -28,11 +18,11 @@ Returns token的名称. e.g. "MyToken"。 public static string symbol() ``` -Returns 合约所管理的token的短字符串符号 . e.g. "MYT"。 +返回合约所管理的token的短字符串符号 . e.g. `"MYT"`。 -该符号需要应该比较短小 (建议3-8个字符), 没有空白字符或换行符 ,并限制为大写拉丁字母 (26个英文字符)。 +该符号必须是一个有效的ASCII字符串,不能有空白字符或换行符,应该限制为简短的(建议为3-8个字符长)大写拉丁字母 (即26个英文字符)。 -该方法每次被调用时必需返回一样的值。 +该方法每次被调用时必须返回一样的值。 **decimals** @@ -40,9 +30,9 @@ Returns 合约所管理的token的短字符串符号 . e.g. "MYT"。 public static byte decimals() ``` -Returns token使用的小数位数 - e.g. 8,意味着把 token 数量除以 100,000,000 来获得它的表示值。 +返回token使用的小数位数 - e.g. `8`,意味着把 token 数量除以 `100,000,000` 来获得它的表示值。 -该方法每次被调用时必需返回一样的值。 +该方法每次被调用时必须返回一样的值。 **balanceOf** @@ -50,43 +40,44 @@ Returns token使用的小数位数 - e.g. 8,意味着把 token 数量除以 10 public static BigInteger balanceOf(byte[] account) ``` -Returns 账户的token金额。 +返回`account`的token余额。 -参数账户必需是一个 20 字节的地址。如果不是,该方法会抛出一个异常。 +参数`account`必须是一个 20 字节的地址。如果不是,该方法应该`抛出异常`。 -如果该账户是个未被使用的地址,该方法会返回0。 +如果`account`是个未被使用的地址,该方法必须返回`0`。 **transfer** ```c# public static bool transfer(byte[] from, byte[] to, BigInteger amount) ``` +从账户`from`转移数量为`amount`的token到地址`to`。 -从一个账户转移一定数量的 token 到另一个账户. 参数 from 和 to 必需是 20 字节的地址,否则,该方法会报错。 +参数 `from` 和 `to` 必须是 20 字节长的地址。否则,该方法应该`抛出异常`。 -参数 amount 必需大于等于0,否则,该方法会报错。 +参数 `amount` 必须大于或等于`0`。否则,该方法应该`抛出异常`。 -如果账户没有足够的支付金额,该函数会返回 false。 +如果账户`from`的余额不足以支付费用,该函数必须返回 `false`。 -如果方法执行成功,会触发转移事件,并返回 true,即使数量为 0 或者 from 和 to 是同一个地址。 +如果方法执行成功,必须触发`Transfer`事件,并且必须返回 `true`,即使`amount`为 0 或者 `from` 和 `to` 是同一个地址。 -函数会检查 from 的地址是否等于调用合约的 hash,如果是,则转移会被处理;否则,函数会调用 SYSCALL `Neo.Runtime.CheckWitness`来确认转移。 +函数应该检查当前调用该方法的合约哈希是否等于地址`from`。如果是,则应该对转账操作进行处理;否则,函数应该调用 SYSCALL `Neo.Runtime.CheckWitness`来验证转账操作。 -如果 to 地址是一个部署合约,函数会检查其 payable 标志位来决定是否把 token 转移到该合约。 +如果转账操作没有执行成功,该函数必须返回`false`。 -如果转移没有被处理,函数会返回false。 +如果 `to` 是一个已部署合约的地址哈希,函数必须在触发`Transfer`事件后调用合约`to`的`onPayment`方法。如果合约`to`不想接收这笔转账,则必须调用操作码`ABORT`。 -**事件 transfer** +**事件 Transfer** ```c# public static event transfer(byte[] from, byte[] to, BigInteger amount) ``` -会在token被转移时触发,包括零值转移。 +在token转账完成后必须触发该事件,包括`amount`为0以及`from`和`to`为同一地址的情况。 -一个创建新 token 的 token 合约在创建 token 时会触发转移事件,并将from的地址设置为 null。 +一个创建新 token 的 token 合约在创建 token 时必须触发`Transfer`事件,并将地址`from`设置为 `null`。 -一个销毁 token 的 token 合约在销毁 token 时会触发转移事件,并将to的地址设置为 null。 +一个销毁 token 的 token 合约在销毁 token 时必须触发`Transfer`事件,并将地址`to`设置为 `null`。 完整的 NEP-5 合约如下,也可参考 [GitHub 源码](https://github.com/neo-ngd/Neo3-Smart-Contract-Examples/blob/master/NEP5/Contract1.cs) @@ -103,7 +94,7 @@ namespace NEP5 [Features(ContractFeatures.HasStorage)] public class NEP5 : SmartContract { - [DisplayName("transfer")] + [DisplayName("Transfer")] public static event Action Transferred; private static readonly BigInteger TotalSupplyValue = 10000000000000000; @@ -159,17 +150,16 @@ namespace NEP5 public static BigInteger BalanceOf(byte[] account) { if (account.Length != 20) - throw new InvalidOperationException("The parameter account SHOULD be 20-byte addresses."); + throw new InvalidOperationException("The parameter account SHOULD be 20-byte non-zero addresses."); return asset.Get(account).TryToBigInteger(); } [DisplayName("decimals")] public static byte Decimals() => 8; - private static bool IsPayable(byte[] to) + private static void onPayment(BigInteger amount) { - var c = Blockchain.GetContract(to); - return c == null || c.IsPayable; + SmartContract.Abort(); } [DisplayName("name")] @@ -199,8 +189,6 @@ namespace NEP5 throw new InvalidOperationException("The parameters from and to SHOULD be 20-byte addresses."); if (amount <= 0) throw new InvalidOperationException("The parameter amount MUST be greater than 0."); - if (!IsPayable(to)) - return false; if (!Runtime.CheckWitness(from) && from.TryToBigInteger() != callscript.TryToBigInteger()) return false; var fromAmount = asset.Get(from).TryToBigInteger(); @@ -220,6 +208,9 @@ namespace NEP5 asset.Put(to, toAmount + amount); Transferred(from, to, amount); + + // Validate payable + if (Blockchain.GetContract(to) != null) Contract.Call(to, "onPayment", new object[] { amount }); return true; } } From f1603e702bd3d33bb59765fc9d00dc51829a6300 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Wed, 25 Nov 2020 17:43:02 +0800 Subject: [PATCH 10/15] update sdk --- docs/zh-cn/develop/tool/sdk/contract.md | 100 +++++---- docs/zh-cn/develop/tool/sdk/introduction.md | 4 +- docs/zh-cn/develop/tool/sdk/monitor.md | 45 ++-- docs/zh-cn/develop/tool/sdk/rpc.md | 167 +++++++------- docs/zh-cn/develop/tool/sdk/transaction.md | 227 +++++++++++--------- docs/zh-cn/develop/tool/sdk/wallet.md | 31 ++- 6 files changed, 319 insertions(+), 255 deletions(-) diff --git a/docs/zh-cn/develop/tool/sdk/contract.md b/docs/zh-cn/develop/tool/sdk/contract.md index 418681f68..4901b8170 100644 --- a/docs/zh-cn/develop/tool/sdk/contract.md +++ b/docs/zh-cn/develop/tool/sdk/contract.md @@ -8,9 +8,9 @@ ## 合约部署 -`ContractClient` 中提供了合约部署交易的构建方法 `CreateDeployContractTx`, 参数为合约脚本,manifest 和支付系统费和网络费的账户密钥对,其中合约脚本和 manifest 可通过编译获取,账户中需要有足够的 GAS 支付所需费用。 +`ContractClient` 中提供了合约部署交易的构建方法 `CreateDeployContractTxAsync`, 参数为合约脚本,manifest 和支付系统费和网络费的账户密钥对,其中合约脚本和 manifest 可通过编译获取,账户中需要有足够的 GAS 支付所需费用。 -读取合约 nef 和 manifest.json 文件: +1. 读取合约 nef 和 manifest.json 文件: ```C# // read nefFile & manifestFile @@ -28,14 +28,14 @@ ContractManifest manifest = ContractManifest.Parse(File.ReadAllBytes(manifestFil ```c# // create the deploy contract transaction byte[] script = nefFile.Script; -Transaction transaction = contractClient.CreateDeployContractTx(script, manifest, senderKeyPair); +Transaction transaction = await contractClient.CreateDeployContractTxAsync(script, manifest, senderKeyPair); ``` 交易构建后需要广播到链上: ```c# // Broadcast the transaction over the Neo network -client.SendRawTransaction(transaction); +await client.SendRawTransactionAsync(transaction); Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); ``` @@ -44,7 +44,7 @@ Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); ```c# // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); -neoAPI.WaitTransaction(transaction) +await neoAPI.WaitTransactionAsync(transaction) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); ``` @@ -58,6 +58,8 @@ using Neo.SmartContract; using Neo.SmartContract.Manifest; using Neo.Wallets; using System; +using Neo.IO; +using System.IO; namespace ConsoleApp1 { @@ -65,12 +67,18 @@ namespace ConsoleApp1 { static void Main(string[] args) { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + Test().GetAwaiter().GetResult(); + Console.Read(); + } + + private static async Task Test() + { + // choose a neo node with rpc opened, here we use the localhost + RpcClient client = new RpcClient("http://127.0.0.1:10332"); ContractClient contractClient = new ContractClient(client); - string nefFilePath = "Test.nef"; - string manifestFilePath = "Test.manifest.json"; + string nefFilePath = "sc/Contract1.nef"; + string manifestFilePath = "sc/Contract1.manifest.json"; // read nefFile & manifestFile NefFile nefFile; @@ -82,22 +90,20 @@ namespace ConsoleApp1 ContractManifest manifest = ContractManifest.Parse(File.ReadAllBytes(manifestFilePath)); // deploying contract needs sender to pay the system fee - KeyPair senderKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); + KeyPair senderKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); // create the deploy transaction byte[] script = nefFile.Script; - Transaction transaction = contractClient.CreateDeployContractTx(script, manifest, senderKey); + Transaction transaction = await contractClient.CreateDeployContractTxAsync(script, manifest, senderKey).ConfigureAwait(false); - // Broadcast the transaction over the Neo network - client.SendRawTransaction(transaction); + // Broadcast the transaction over the NEO network + await client.SendRawTransactionAsync(transaction).ConfigureAwait(false); Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(transaction) + await neoAPI.WaitTransactionAsync(transaction) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); } } } @@ -105,28 +111,34 @@ namespace ConsoleApp1 ## 合约模拟调用 -`ContractClient` 提供了 `TestInvoke` 方法来对合约进行模拟调用,执行后不会影响链上数据。可以直接调用读取信息的合约方法,比如下面的例子调用了NEO原生合约中的name方法 +`ContractClient` 提供了 `TestInvokeAsync` 方法来对合约进行模拟调用,执行后不会影响链上数据。可以直接调用读取信息的合约方法,比如下面的例子调用了NEO原生合约中的name方法 ```c# // choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); ContractClient contractClient = new ContractClient(client); // get the contract hash UInt160 scriptHash = NativeContract.NEO.Hash; // test invoking the method provided by the contract -string name = contractClient.TestInvoke(scriptHash, "name") - .Stack.Single().ToStackItem().GetString(); +RpcInvokeResult invokeResult = await contractClient.TestInvokeAsync(scriptHash, "name").ConfigureAwait(false); +Console.WriteLine($"The name is {invokeResult.Stack.Single().GetString()}"); ``` -或者使用 `MakeScript` 构造想要执行的脚本,再调用 `InvokeScript` 获取执行结果 +或者使用 `MakeScript` 构造想要执行的脚本,再调用 `RpcClient`中的方法`InvokeScriptAsync` 获取执行结果 ```c# -// construct the script you want to run in test mode +// choose a neo node with rpc opened +RpcClient client = new RpcClient("http://127.0.0.1:10332"); + +// get the contract hash +UInt160 scriptHash = NativeContract.NEO.Hash; + byte[] script = scriptHash.MakeScript("name"); // call invoke script -name = client.InvokeScript(script).Stack.Single().ToStackItem().GetString(); +RpcInvokeResult invokeResult = await client.InvokeScriptAsync(script).ConfigureAwait(false); +Console.WriteLine($"The name is {invokeResult.Stack.Single().GetString()}"); ``` ## 合约调用(上链交易) @@ -138,30 +150,27 @@ name = client.InvokeScript(script).Stack.Single().ToStackItem().GetString(); 以调用原生合约 NEO 的 `transfer` 方法为例: ```c# - // construct the script, in this example, we will transfer 1 NEO to receiver + // construct the script, in this example, we will transfer 1024 NEO to receiver UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); + byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1024); ``` 2. 构建交易: ```c# - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, sender) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add signature for the transaction with sendKey - .AddSignature(sendKey) - // sign transaction with the added signature - .Sign() - .Tx; + // initialize the TransactionManagerFactory with rpc client and magic + // fill the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddSignature(sendKey).SignAsync().ConfigureAwait(false); ``` 3. 交易构造后广播到链上: ```c# // broadcasts the transaction over the Neo network - client.SendRawTransaction(tx); + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); ``` 4. 等待交易上链后,获取交易的执行状态以确保合约调用成功: @@ -169,7 +178,7 @@ name = client.InvokeScript(script).Stack.Single().ToStackItem().GetString(); ```c# // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) + await neoAPI.WaitTransactionAsync(tx) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); ``` @@ -181,21 +190,28 @@ name = client.InvokeScript(script).Stack.Single().ToStackItem().GetString(); ```c# Nep5API nep5API = new Nep5API(client); -Transaction tx = nep5API.CreateTransferTx(scriptHash, sendKey, receiver, 1); +Transaction tx = await nep5API.CreateTransferTxAsync(scriptHash, sendKey, receiver, 1).ConfigureAwait(false); ``` -此外 `Nep5API` 还提供了简单的读取方法: +此外 `Nep5API` 还提供了以下6种读取方法: ```c# // get nep5 name -string name = nep5API.Name(scriptHash); +string name = await nep5API.NameAsync(NativeContract.NEO.Hash).ConfigureAwait(false); // get nep5 symbol -string symbol = nep5API.Symbol(scriptHash); +string symbol = await nep5API.SymbolAsync(NativeContract.NEO.Hash).ConfigureAwait(false); // get nep5 token decimals -uint decimals = nep5API.Decimals(scriptHash); +byte decimals = await nep5API.DecimalsAsync(NativeContract.NEO.Hash).ConfigureAwait(false); // get nep5 token total supply -BigInteger totalSupply = nep5API.TotalSupply(scriptHash); +BigInteger totalSupply = await nep5API.TotalSupplyAsync(NativeContract.NEO.Hash).ConfigureAwait(false); + +// get the balance of nep5 token +UInt160 account = Utility.GetScriptHash("NXjtqYERuvSWGawjVux8UerNejvwdYg7eE"); +BigInteger balance = await nep5API.BalanceOfAsync(NativeContract.NEO.Hash, account).ConfigureAwait(false); + +// get token information +RpcNep5TokenInfo tokenInfo = await nep5API.GetTokenInfoAsync(NativeContract.NEO.Hash).ConfigureAwait(false); ``` diff --git a/docs/zh-cn/develop/tool/sdk/introduction.md b/docs/zh-cn/develop/tool/sdk/introduction.md index d767f445c..43785c6e5 100644 --- a/docs/zh-cn/develop/tool/sdk/introduction.md +++ b/docs/zh-cn/develop/tool/sdk/introduction.md @@ -42,9 +42,9 @@ `Neo RPC SDK` 主要通过 RPC 请求与 Neo 节点进行交互,当 RPC 请求返回的消息中带有 Error 时系统就会抛出异常,所以最常见的异常类型是 `RpcException`, 主要包含下面几种: -- -100, "Unknown transaction" or "Unknown block" +- -100, "Unknown transaction/blockhash" - -300, "Insufficient funds" -- -301, "The transaction is failed because the necessary fee exceeds the Max_fee. Please increase your Max_fee value." +- -301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value." - -400, "Access denied" - -500, Relay does not succeed, the detailed reasons contain "AlreadyExists, OutOfMemory, UnableToVerify, Invalid, Expired, InsufficientFunds, PolicyFail, Unknown" - -32600, "Invalid Request" diff --git a/docs/zh-cn/develop/tool/sdk/monitor.md b/docs/zh-cn/develop/tool/sdk/monitor.md index 2d0da855d..205dd350d 100644 --- a/docs/zh-cn/develop/tool/sdk/monitor.md +++ b/docs/zh-cn/develop/tool/sdk/monitor.md @@ -11,30 +11,36 @@ ```c# // choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); -// get the highest block hash -string hash = client.GetBestBlockHash(); +// get the hash of the tallest block in the main chain +string hash = await client.GetBestBlockHashAsync().ConfigureAwait(false); -// get the highest block height -uint height = client.GetBlockCount() - 1; +// get the number of blocks in the main chain +uint count = await client.GetBlockCountAsync().ConfigureAwait(false); ``` -获取某个区块内具体数据,包括交易列表等: +获取指定高度或哈希的区块内具体数据,包括交易列表等;结果可以是Base64编码的字符串或者Json字符串: ```c# -// get block data -RpcBlock block = client.GetBlock("166396"); +// get the Base64 string of the block with block height +string blockHex = await client.GetBlockHexAsync("166396").ConfigureAwait(false); + +// get the Base64 string of the block with block hash +string blockHex = await client.GetBlockHexAsync("0x4e61cd9d76e30e9147ee0f5b9c92f4447decbe52c6c8b412d0382a14d3a0b408").ConfigureAwait(false); + +// get block data with block height +RpcBlock block = await client.GetBlockAsync("166396").ConfigureAwait(false); // get block data with block hash -RpcBlock block = client.GetBlock("0x953f6efa29c740b68c87e0a060942056382a6912a0ddeddc2f6641acb92d9700"); +RpcBlock block = await client.GetBlockAsync("0x4e61cd9d76e30e9147ee0f5b9c92f4447decbe52c6c8b412d0382a14d3a0b408").ConfigureAwait(false); ``` 通过 `RpcClient` 获取合约脚本、哈希与 manifest 的信息: ```c# // get NEO contract state -ContractState contractState = client.GetContractState(NativeContract.NEO.Hash.ToString()); +ContractState contractState = await client.GetContractStateAsync(NativeContract.NEO.Hash.ToString()).ConfigureAwait(false); ``` 更多信息请参见 [RPC 调用方法](rpc.md)。 @@ -45,19 +51,20 @@ ContractState contractState = client.GetContractState(NativeContract.NEO.Hash.To ```c# // choose a neo node with rpc opened -PolicyAPI policyAPI = new PolicyAPI(new RpcClient("http://seed1t.neo.org:20332")); - -// get the accounts blocked by policy -UInt160[] blockedAccounts = policyAPI.GetBlockedAccounts(); // [], no account is blocked by now +PolicyAPI policyAPI = new PolicyAPI(new RpcClient("http://127.0.0.1:10332")); // get the system fee per byte -long feePerByte = policyAPI.GetFeePerByte(); // 1000, 0.00001000 GAS per byte +long feePerByte = await policyAPI.GetFeePerByteAsync().ConfigureAwait(false); // 1000, 0.00001000 GAS per byte // get the max size of one block -uint maxBlockSize = policyAPI.GetMaxBlockSize(); // 262144, (1024 * 256) bytes one block +uint maxBlockSize = await policyAPI.GetMaxBlockSizeAsync().ConfigureAwait(false); // 262144, (1024 * 256) bytes one block // get the max transaction count per block -uint maxTransactionsPerBlock = policyAPI.GetMaxTransactionsPerBlock(); // 512, max 512 transactions one block +uint maxTransactionsPerBlock = await policyAPI.GetMaxTransactionsPerBlockAsync().ConfigureAwait(false); // 512, max 512 transactions one block + +// check if the account is blocked +UInt160 account = Utility.GetScriptHash("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); +bool isBlocked = await policyAPI.IsBlockedAsync(account).ConfigureAwait(false); ``` ## 获取 NEP5 合约信息 @@ -66,7 +73,7 @@ NEP5 是 Neo3 中的资产标准,NEO 和 GAS 都基于 NEP5 原生合约。调 ```c# // get nep5 token info -Nep5API nep5API = new Nep5API(client); -RpcNep5TokenInfo tokenInfo = nep5API.GetTokenInfo(NativeContract.NEO.Hash); +Nep5API nep5API = new Nep5API(new RpcClient("http://127.0.0.1:10332")); +RpcNep5TokenInfo tokenInfo = await nep5API.GetTokenInfoAsync(NativeContract.NEO.Hash).ConfigureAwait(false); ``` diff --git a/docs/zh-cn/develop/tool/sdk/rpc.md b/docs/zh-cn/develop/tool/sdk/rpc.md index dd3730854..e37d6d27f 100644 --- a/docs/zh-cn/develop/tool/sdk/rpc.md +++ b/docs/zh-cn/develop/tool/sdk/rpc.md @@ -17,7 +17,7 @@ RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); ```c# // Local Node -RpcClient client = new RpcClient("http://localhost:10332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); ``` > [!Note] @@ -30,7 +30,7 @@ RpcClient client = new RpcClient("http://localhost:10332"); 获取区块链中高度最大的区块的哈希: ```c# -string hexString = client.GetBestBlockHash(); +string hexString = await client.GetBestBlockHashAsync().ConfigureAwait(false); byte[] hashBytes = hexString.HexToBytes(); UInt256 hash256 = UInt256.Parse(hexString); ``` @@ -39,32 +39,33 @@ UInt256 hash256 = UInt256.Parse(hexString); 可以通过区块散列值或者区块索引获取具体的区块信息: ```c# -Block block = client.GetBlock("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e").Block; +RpcBlock rpcBlock = await client.GetBlockAsync("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e").ConfigureAwait(false); +Block block = rpcBlock.Block; ``` 或者 ```c# -Block block = client.GetBlock("10000").Block; +RpcBlock rpcBlock = await client.GetBlockAsync("1024").ConfigureAwait(false); +Block block = rpcBlock.Block; ``` 也可以通过区块散列值或者区块索引获取序列化后的区块信息: ```c# -string serializedBlock = client.GetBlockHex("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e"); +string serializedBlock = await client.GetBlockHexAsync("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e").ConfigureAwait(false); ``` - ### 获取当前区块数量 区块索引(Index) = 区块高度(Height) = 区块数量(Count) - 1 ```c# -uint blockCount = client.GetBlockCount(); +uint blockCount = await client.GetBlockCountAsync().ConfigureAwait(false); ``` ### 根据区块索引获取区块的散列: ```c# -string hexString = client.GetBlockHash(10000); +string hexString = await client.GetBlockHashAsync(10000).ConfigureAwait(false); byte[] hashBytes = hexString.HexToBytes(); UInt256 hash256 = UInt256.Parse(hexString); ``` @@ -73,89 +74,88 @@ UInt256 hash256 = UInt256.Parse(hexString); 可以通过区块散列值或者区块索引获取具体的区块头信息: ```c# -Header header = client.GetBlockHeader("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957").Header; +RpcBlockHeader blockHeader = await client.GetBlockHeaderAsync("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957").ConfigureAwait(false); +Header header = blockHeader.Header; ``` 或者 ```c# -Header header = client.GetBlockHeader("10000").Header; +RpcBlockHeader blockHeader = await client.GetBlockHeaderAsync("10000").ConfigureAwait(false); +Header header = blockHeader.Header; ``` 也可以通过区块散列值或者区块索引获取序列化后的区块头信息: ```c# -string serializedBlockHeader = client.GetBlockHeaderHex("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957"); +string serializedBlockHeader = await client.GetBlockHeaderHexAsync("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957").ConfigureAwait(false); ``` -### 获取系统手续费 -通过指定的索引获取截止到该区块前的系统手续费: +或者 ```c# -BigInteger sysFee = client.GetBlockSysFee(10000); +string serializedBlockHeader = await client.GetBlockHeaderHexAsync("10000").ConfigureAwait(false); ``` - ### 获取合约信息 通过合约哈希获取合约信息: ```c# -ContractState contractState = client.GetContractState("dc675afc61a7c0f7b3d2682bf6e1d8ed865a0e5f"); -``` - -通过合约Id获取合约信息: - -```c# -ContractState contractState = client.GetContractState(-1); +ContractState contractState = await client.GetContractStateAsync("dc675afc61a7c0f7b3d2682bf6e1d8ed865a0e5f").ConfigureAwait(false); ``` ### 获取内存中的交易列表 只获取内存中已确认的交易散列列表: ```c# -string[] verifiedTransactions = client.GetRawMempool(); +string[] verifiedTransactions = await client.GetRawMempoolAsync().ConfigureAwait(false); ``` 同时获取内存中已确认和未确认的交易散列列表: ```c# -RpcRawMemPool memPool = client.GetRawMempoolBoth(); +RpcRawMemPool memPool = await client.GetRawMempoolBothAsync().ConfigureAwait(false); string[] verifiedTransactions = memPool.Verified; string[] unverifiedTransactions = memPool.UnVerified; ``` ### 获取交易信息 -通过交易 ID 来获取对应的交易信息: +通过交易哈希来获取对应的交易信息: ```c# -RpcTransaction rpcTransaction = client.GetRawTransaction("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657"); +RpcTransaction rpcTransaction = await client.GetRawTransactionAsync("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657").ConfigureAwait(false); Transaction transaction = rpcTransaction.Transaction; ``` -也可以通过交易 ID 来获取对应的序列化后的交易: +也可以通过交易哈希来获取对应的序列化后的交易: + +```c# +string serializedTransaction = await client.GetRawTransactionHexAsync("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657").ConfigureAwait(false); +``` +### 计算交易网络费 +计算指定交易的网络费用 ```c# -string serializedTransaction = client.GetRawTransactionHex("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657"); +long networkFee = await rpcClient.CalculateNetworkFeeAsync(transaction).ConfigureAwait(false); ``` ### 获取合约存储区的值 通过合约脚本散列和存储的`键`(需要转化为 hex string)获取对应存储的值: ```c# -string value = client.GetStorage("03febccf81ac85e3d795bc5cbd4e84e907812aa3", "5065746572"); +string value = await client.GetStorageAsync("03febccf81ac85e3d795bc5cbd4e84e907812aa3", "5065746572").ConfigureAwait(false); ``` ### 获取指定交易的高度 -通过交易 ID 获取指定交易所在的区块高度: +通过交易哈希获取指定交易所在的区块高度: ```c# -uint height = client.GetTransactionHeight("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657"); +uint height = await client.GetTransactionHeightAsync("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657").ConfigureAwait(false); ``` -### 获取当前共识节点的信息 -获取当前网络中共识节点的信息及投票情况: - +### 获取下一轮共识节点的信息 +获取网络中下一轮共识节点的信息及投票情况: ```c# -RpcValidator[] rpcValidators = client.GetValidators(); +RpcValidator[] rpcValidators = await client.GetNextBlockValidatorsAsync().ConfigureAwait(false); foreach (var validator in rpcValidators) { string publicKey = validator.PublicKey; @@ -163,21 +163,25 @@ foreach (var validator in rpcValidators) bool isActive = validator.Active; } ``` - +### 获取当前委员会成员 +获取网络中当前委员会成员公钥列表 +```c# +string[] committees = await client.GetCommitteeAsync().ConfigureAwait(false); +``` ## 节点 ### 获取节点连接数 获取连接到该节点的节点数量: ```c# -int connectionCount = client.GetConnectionCount(); +int connectionCount = await client.GetConnectionCountAsync().ConfigureAwait(false); ``` ### 获取已连接/未连接的节点 获得该节点当前已连接/未连接的节点列表,包括 IP 地址和端口: ```c# -RpcPeers rpcPeers = client.GetPeers(); +RpcPeers rpcPeers = await client.GetPeersAsync().ConfigureAwait(false);; RpcPeer[] connected = rpcPeers.Connected; RpcPeer[] unconnected = rpcPeers.Unconnected; if (connected.Length > 0) @@ -192,7 +196,7 @@ if (connected.Length > 0) 获取接收 RPC 请求的节点的版本信息: ```c# -RpcVersion rpcVersion = client.GetVersion(); +RpcVersion rpcVersion = await client.GetVersionAsync().ConfigureAwait(false); string version = rpcVersion.UserAgent; ``` @@ -200,22 +204,20 @@ string version = rpcVersion.UserAgent; 发送并广播序列化后的交易: ```c# -bool result = client.SendRawTransaction("80000001195876cb34364dc38b730077156c6bc3a7fc570044a66fbfeeea56f71327e8ab0000029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500c65eaf440000000f9a23e06f74cf86b8827a9108ec2e0f89ad956c9b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50092e14b5e00000030aab52ad93f6ce17ca07fa88fc191828c58cb71014140915467ecd359684b2dc358024ca750609591aa731a0b309c7fb3cab5cd0836ad3992aa0a24da431f43b68883ea5651d548feb6bd3c8e16376e6e426f91f84c58232103322f35c7819267e721335948d385fae5be66e7ba8c748ac15467dcca0693692dac"); +UInt256 txHash = await client.SendRawTransactionAsync("80000001195876cb34364dc38b730077156c6bc3a7fc570044a66fbfeeea56f71327e8ab0000029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500c65eaf440000000f9a23e06f74cf86b8827a9108ec2e0f89ad956c9b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50092e14b5e00000030aab52ad93f6ce17ca07fa88fc191828c58cb71014140915467ecd359684b2dc358024ca750609591aa731a0b309c7fb3cab5cd0836ad3992aa0a24da431f43b68883ea5651d548feb6bd3c8e16376e6e426f91f84c58232103322f35c7819267e721335948d385fae5be66e7ba8c748ac15467dcca0693692dac").ConfigureAwait(false); ``` -当 `result` 为 `true` 时表明当前交易广播成功; -当 `result` 为 `false` 时表示当前交易广播失败,原因可能有双重花费、签名不完整等。 +或者将交易对象tx在网络中进行广播: +```c# +UInt256 txHash = await client.SendRawTransactionAsync(transaction).ConfigureAwait(false); +``` ### 广播区块 发送并广播序列化后的区块: ```c# -bool result = client.SubmitBlock("000000000000000000000000000000000000000000000000000000000000000000000000845c34e7c1aed302b1718e914da0c42bf47c476ac4d89671f278d8ab6d27aa3d65fc8857000000001dac2b7c00000000be48d3a3f5d10013ab9ffee489706078714f1ea2010001510400001dac2b7c00000000400000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000400001445b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e5b881227d2c7b226c616e67223a22656e222c226e616d65223a22416e74436f696e227d5d0000c16ff286230008009f7fd096d37ed2c0e3f7f0cfc924beef4ffceb680000000001000000019b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50000c16ff2862300be48d3a3f5d10013ab9ffee489706078714f1ea201000151"); +UInt256 blockHash = await client.SubmitBlockAsync("000000000000000000000000000000000000000000000000000000000000000000000000845c34e7c1aed302b1718e914da0c42bf47c476ac4d89671f278d8ab6d27aa3d65fc8857000000001dac2b7c00000000be48d3a3f5d10013ab9ffee489706078714f1ea2010001510400001dac2b7c00000000400000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000400001445b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e5b881227d2c7b226c616e67223a22656e222c226e616d65223a22416e74436f696e227d5d0000c16ff286230008009f7fd096d37ed2c0e3f7f0cfc924beef4ffceb680000000001000000019b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50000c16ff2862300be48d3a3f5d10013ab9ffee489706078714f1ea201000151").ConfigureAwait(false); ``` - -当 `result` 为 `true` 时表明区块广播成功; -当 `result` 为 `false` 时,区块广播失败并引发异常。 - ## 智能合约 ### 调用智能合约的特定方法 @@ -228,7 +230,7 @@ RpcStack rpcStack = new RpcStack() Value = "91b83e96f2a7c4fdf0c1688441ec61986c7cae26" }; UInt160 scriptHashesForVerifying = UInt160.Parse("0x20e22e16cfbcfdd29f347268427b76863b7679fa"); -RpcInvokeResult rpcInvokeResult = client.InvokeFunction("af7c7328eee5a275a3bcaee2bf0cf662b5e739be", "balanceOf", new RpcStack[] { rpcStack },scriptHashesForVerifying); +RpcInvokeResult rpcInvokeResult = await client.InvokeFunctionAsync("af7c7328eee5a275a3bcaee2bf0cf662b5e739be", "balanceOf", new RpcStack[] { rpcStack },scriptHashesForVerifying).ConfigureAwait(false); string script = rpcInvokeResult.Script; string engineState = rpcInvokeResult.State; long gasConsumed = long.Parse(rpcInvokeResult.GasConsumed); @@ -247,10 +249,17 @@ string transaction = rpcInvokeResult.Tx; ```c# byte[] script = "00046e616d656724058e5e1b6008847cd662728549088a9ee82191".HexToBytes(); UInt160 scriptHashesForVerifying = UInt160.Parse("0x20e22e16cfbcfdd29f347268427b76863b7679fa"); -RpcInvokeResult rpcInvokeResult = client.InvokeScript(script,scriptHashesForVerifying); +RpcInvokeResult rpcInvokeResult = await client.InvokeScriptAsync(script, scriptHashesForVerifying).ConfigureAwait(false); ``` +### 获取未领取的Gas +获取指定地址未领取的Gas数量: +```c# +RpcUnclaimedGas unclaimedGas = await client.GetUnclaimedGasAsync("NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM").ConfigureAwait(false); +BigInteger unclaimed = unclaimedGas.Unclaimed; +string address = unclaimedGas.Address; +``` ## 工具 @@ -258,7 +267,7 @@ RpcInvokeResult rpcInvokeResult = client.InvokeScript(script,scriptHashesForVeri 显示节点已加载的插件列表: ```c# -RpcPlugin[] rpcPlugins = client.ListPlugins(); +RpcPlugin[] rpcPlugins = await client.ListPluginsAsync().ConfigureAwait(false); foreach (var item in rpcPlugins) { string name = item.Name; @@ -270,7 +279,8 @@ foreach (var item in rpcPlugins) 验证指定地址是否是正确的 Neo 地址: ```c# -RpcValidateAddressResult result = client.ValidateAddress("AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i"); +RpcValidateAddressResult result = await client.ValidateAddressAsync("AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i").ConfigureAwait(false); +string address = result.Address; bool isValid = result.IsValid; ``` @@ -278,39 +288,48 @@ bool isValid = result.IsValid; 节点本地钱包接口包含可以访问节点本地钱包文件的功能,使用该部分的方法之前需要先通过 `openwallet` 方法打开钱包。 节点的配置文件默认禁用此方法,因为有很高的安全风险。 +### 打开钱包 +打开节点所在机器中的钱包文件: + +```c# +string path = "D:/temp/123.json"; +string password = "Password***"; +bool result = await client.OpenWalletAsync(path, password).ConfigureAwait(false); +``` + ### 关闭钱包 关闭钱包将清除内存中的钱包信息: ```c# -bool result = client.CloseWallet(); +bool result = await client.CloseWalletAsync().ConfigureAwait(false); ``` ### 导出私钥 导出指定地址的私钥: ```c# -string wif = client.DumpPrivKey("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"); +string wif = await client.DumpPrivKeyAsync("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ").ConfigureAwait(false); ``` ### 余额查询 -根据指定的资产编号,返回钱包中对应资产的余额信息。该方法适用于原生合约资产及符合 NEP-5 标准的合约资产: +根据指定的资产哈希,返回钱包中对应资产的余额信息。该方法适用于原生合约资产及符合 NEP-5 标准的合约资产: ```c# -BigInteger balance = client.GetBalance(NativeContract.NEO.Hash.ToString()); +BigDecimal balance = await client.GetWalletBalanceAsync(NativeContract.NEO.Hash.ToString()).ConfigureAwait(false); ``` ### 创建账号 在打开的钱包文件中创建一个新的账号,并返回该账号的地址: ```c# -string address = client.GetNewAddress(); +string address = await client.GetNewAddressAsync().ConfigureAwait(false); ``` ### 获取可提取的 GAS 数量 -显示钱包中未提取的 GAS 数量: +显示钱包中可提取的 GAS 数量: ```c# -BigInteger amount = client.GetUnclaimedGas(); +BigInteger amount = await client.GetWalletUnclaimedGasAsync().ConfigureAwait(false); ``` ### 导入私钥 @@ -318,25 +337,15 @@ BigInteger amount = client.GetUnclaimedGas(); ```c# string wif = "KyoYyZpoccbR6KZ25eLzhMTUxREwCpJzDsnuodGTKXSG8fDW9t7x"; -RpcAccount account = client.ImportPrivKey(wif); +RpcAccount account = await client.ImportPrivKeyAsync(wif).ConfigureAwait(false); ``` ### 列出钱包账号 列出当前钱包内的所有地址: ```c# -List acoounts = client.ListAddress(); +List acoounts = await client.ListAddressAsync().ConfigureAwait(false); ``` - -### 打开钱包 -打开节点所在机器中的钱包文件: - -```c# -string path = "D:/temp/123.json"; -string pass = "Password***"; -bool result = client.OpenWallet(path, pass); -``` - ### 从指定地址转账 从指定地址,向指定地址转账: @@ -345,7 +354,7 @@ string assetId = NativeContract.NEO.Hash.ToString(); string fromAddress = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; string toAddress= "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; string amount = "100"; -JObject result = client.SendFrom(assetId, fromAddress, toAddress, amount); +JObject result = await client.SendFromAsync(assetId, fromAddress, toAddress, amount).ConfigureAwait(false); ``` 返回JSON交易详情说明交易发送成功,否则交易发送失败。 如果签名不完整会返回待签名的交易。 @@ -368,7 +377,7 @@ outs.Add(new RpcTransferOut ScriptHash = Utility.GetScriptHash("NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"), Value = "100.12345678" }); -JObject result = client.SendMany("", outs); +JObject result = await client.SendManyAsync("", outs).ConfigureAwait(false); ``` 返回JSON交易详情说明交易发送成功,否则交易发送失败。 如果签名不完整会返回待签名的交易。 @@ -381,7 +390,7 @@ JObject result = client.SendMany("", outs); string assetId = NativeContract.NEO.Hash.ToString(); string toAddress = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; string amount = "100"; -JObject result = client.SendToAddress(assetId, toAddress,amount); +JObject result = await client.SendToAddressAsync(assetId, toAddress, amount).ConfigureAwait(false); ``` 返回JSON交易详情说明交易发送成功,否则交易发送失败。 如果签名不完整会返回待签名的交易。 @@ -395,7 +404,13 @@ JObject result = client.SendToAddress(assetId, toAddress,amount); ```c# string txHash = "0x23bf33766d00b4bb3314185f1ff0c2c85182d4d5e4e96f7c2df7506e7f99098b"; -RpcApplicationLog log = client.GetApplicationLog(txHash); +RpcApplicationLog log = await client.GetApplicationLogAsync(txHash).ConfigureAwait(false); +``` + +或者根据指定的交易ID和触发器类型获取合约日志: +```c# +string txHash = "0x23bf33766d00b4bb3314185f1ff0c2c85182d4d5e4e96f7c2df7506e7f99098b"; +RpcApplicationLog log = await client.GetApplicationLogAsync(txHash, TriggerType.Application).ConfigureAwait(false); ``` ### 查询 NEP-5 资产余额 @@ -404,7 +419,7 @@ RpcApplicationLog log = client.GetApplicationLog(txHash); ```c# string address = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; -RpcNep5Balances balances = client.GetNep5Balances(address); +RpcNep5Balances balances = await client.GetNep5BalancesAsync(address).ConfigureAwait(false); ``` ### 查询交易记录 @@ -415,7 +430,7 @@ RpcNep5Balances balances = client.GetNep5Balances(address); ```c# string address = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; -RpcNep5Transfers transfers = client.GetNep5Transfers(address, 0); +RpcNep5Transfers transfers = await client.GetNep5TransfersAsync(address, 0).ConfigureAwait(false); ``` diff --git a/docs/zh-cn/develop/tool/sdk/transaction.md b/docs/zh-cn/develop/tool/sdk/transaction.md index bc049484d..511758ba1 100644 --- a/docs/zh-cn/develop/tool/sdk/transaction.md +++ b/docs/zh-cn/develop/tool/sdk/transaction.md @@ -16,21 +16,14 @@ byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); ``` -2. 初始化 `TransactionManager` ,将 `RpcClient ` 和发起账户的 `ScriptHash ` 作为参数。 +2. 构造 `TransactionManagerFactory`,将`RpcClient`和 `Magic`作为参数; 构造`TransactionManager`, 将`Script`和`Signers`作为参数。 ```c# - // initialize the TransactionManager with rpc client and the sender scripthash - TransactionManager txManager = new TransactionManager(client, sender); + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); ``` -3. 调用 `MakeTransaction` 方法,传入交易脚本、交易属性和cosigner。 - - ```c# - // fill the script, attributes and cosigners - txManager.MakeTransaction(script, null, cosigners); - ``` - -4. 添加签名(单签或者多签),将账户的 `KeyPair` 作为签名的参数。 +3. 添加签名(单签或者多签),将账户的 `KeyPair` 作为签名的参数;并且签名。 - 单签 @@ -62,15 +55,13 @@ ```c# // sign the transaction with the added signatures - txManager.Sign(); - Transaction tx = txManager.Tx; + Transaction tx = await txManager.SignAsync().ConfigureAwait(false); ``` - ## 交易构造示例 ### 构造 NEP5 转账交易 -下面的示例实现了从send账户转账1个NEO到receiver账户的功能。构建不同交易时需要关注交易中脚本和所需签名的不同。 +下面的示例实现了从sender账户转账1024个NEO到receiver账户的功能。构建不同交易时需要关注交易中脚本和所需签名的不同。 ```c# using Neo; @@ -81,7 +72,6 @@ using Neo.SmartContract.Native; using Neo.VM; using Neo.Wallets; using System; -using Utility = Neo.Network.RPC.Utility; namespace ConsoleApp1 { @@ -89,55 +79,91 @@ namespace ConsoleApp1 { static void Main(string[] args) { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + TestNep5Transfer().GetAwaiter().GetResult(); + Console.Read(); + } + private static async Task TestNep5Transfer() + { + // choose a neo node with rpc opened + RpcClient client = new RpcClient("http://127.0.0.1:10332"); // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); + KeyPair sendKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; - // add Cosigners, which is a collection of scripthashs that need to be signed - Cosigner[] cosigners = new[] { new Cosigner { Scopes = WitnessScope.CalledByEntry, Account = sender } }; + // add Signers, which is a collection of scripthashs that need to be signed + Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } }; // get the scripthash of the account you want to transfer to - UInt160 receiver = Utility.GetScriptHash("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"); + UInt160 receiver = Utility.GetScriptHash("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); - // construct the script, in this example, we will transfer 1 NEO to receiver + // construct the script, in this example, we will transfer 1024 NEO to receiver UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); - - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, sender) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add signature for the transaction with sendKey - .AddSignature(sendKey) - // sign transaction with the added signature - .Sign() - .Tx; + byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1024); + + // initialize the TransactionManagerFactory with rpc client and magic + // fill in the TransactionManager with the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddSignature(sendKey).SignAsync().ConfigureAwait(false); // broadcasts the transaction over the Neo network. - client.SendRawTransaction(tx); + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) + await neoAPI.WaitTransactionAsync(tx) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); } } } - - ``` `WalletAPI` 封装了上面的过程,NEP5 转账可以简化为: ```c# -WalletAPI walletAPI = new WalletAPI(client); -Transaction tx = walletAPI.Transfer(NativeContract.NEO.Hash, sendKey, receiver, 1); +using Neo; +using Neo.Network.P2P.Payloads; +using Neo.Network.RPC; +using Neo.SmartContract; +using Neo.SmartContract.Native; +using Neo.VM; +using Neo.Wallets; +using System; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + TestNep5Transfer().GetAwaiter().GetResult(); + Console.Read(); + } + + private static async Task TestNep5Transfer() + { + // choose a neo node with rpc opened + RpcClient client = new RpcClient("http://127.0.0.1:10332"); + // get the KeyPair of your account, which will pay the system and network fee + KeyPair sendKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + + // get the scripthash of the account you want to transfer to + UInt160 receiver = Utility.GetScriptHash("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); + + // use WalletAPI to create and send the transfer transaction + WalletAPI walletAPI = new WalletAPI(client); + Transaction tx = await walletAPI.TransferAsync(NativeContract.NEO.Hash, sendKey, receiver, 1024).ConfigureAwait(false); + + // print a message after the transaction is on chain + WalletAPI neoAPI = new WalletAPI(client); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} ``` ### 构造交易向多签账户转账 @@ -161,50 +187,50 @@ namespace ConsoleApp1 { static void Main(string[] args) { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + TestToMultiTransfer().GetAwaiter().GetResult(); + Console.Read(); + } + private static async Task TestToMultiTransfer() + { + // choose a neo node with rpc opened + RpcClient client = new RpcClient("http://127.0.0.1:10332"); // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); + KeyPair sendKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; // get the KeyPair of your accounts - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); + KeyPair key2 = Utility.GetKeyPair("L1bQBbZWnKbPkpHM3jXWD3E5NwK7nui2eWHYXVZPy3t8jSFF1Qj3"); + KeyPair key3 = Utility.GetKeyPair("KwrJfYyc7KWfZG5h97SYfcCQyW4jRw1njmHo48kZhZmuQWeTtUHM"); // create multi-signatures contract, this contract needs at least 2 of 3 KeyPairs to sign Contract multiContract = Contract.CreateMultiSigContract(2, sendKey.PublicKey, key2.PublicKey, key3.PublicKey); // get the scripthash of the multi-signature Contract UInt160 multiAccount = multiContract.Script.ToScriptHash(); - // construct the script, in this example, we will transfer 10 GAS to multi-sign account + // construct the script, in this example, we will transfer 1024 GAS to multi-sign account // in contract parameter, the amount type is BigInteger, so we need to muliply the contract factor UInt160 scriptHash = NativeContract.GAS.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, multiAccount, 10 * NativeContract.GAS.Factor); - - // add Cosigners, this is a collection of scripthashs which need to be signed - Cosigner[] cosigners = new[] { new Cosigner { Scopes = WitnessScope.CalledByEntry, Account = sender } }; - - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, sender) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add signature for the transaction with sendKey - .AddSignature(sendKey) - // sign transaction with the added signature - .Sign() - .Tx; - - // broadcasts transaction over the Neo network. - client.SendRawTransaction(tx); + byte[] script = scriptHash.MakeScript("transfer", sender, multiAccount, 1024 * NativeContract.GAS.Factor); + + // add Signers, which is a collection of scripthashs that need to be signed + Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } }; + + // initialize the TransactionManager with rpc client and magic + // fill the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddSignature(sendKey).SignAsync().ConfigureAwait(false); + + // broadcasts the transaction over the Neo network. + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) + await neoAPI.WaitTransactionAsync(tx) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); } } } @@ -213,7 +239,7 @@ namespace ConsoleApp1 ### 构造交易从多签账户转账 -下面的示例实现了从多签账户转出1个GAS的功能。多签账户的scripthash由多签合约脚本的hash得来。因为需要从多签账户转账,添加签名时要根据多签合约要求的签名数量添加。 +下面的示例实现了从多签账户转出1024个GAS的功能。多签账户的scripthash由多签合约脚本的hash得来。因为需要从多签账户转账,添加签名时要根据多签合约要求的签名数量添加。 ```c# using Neo; @@ -231,51 +257,54 @@ namespace ConsoleApp1 class Program { static void Main(string[] args) + { + TestFromMultiTransfer().GetAwaiter().GetResult(); + Console.Read(); + } + + private static async Task TestFromMultiTransfer() { // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + RpcClient client = new RpcClient("http://127.0.0.1:10332"); // get the KeyPair of your account - KeyPair receiverKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); + KeyPair receiverKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + KeyPair key2 = Utility.GetKeyPair("L1bQBbZWnKbPkpHM3jXWD3E5NwK7nui2eWHYXVZPy3t8jSFF1Qj3"); + KeyPair key3 = Utility.GetKeyPair("KwrJfYyc7KWfZG5h97SYfcCQyW4jRw1njmHo48kZhZmuQWeTtUHM"); // create multi-signature contract, this contract needs at least 2 of 3 KeyPairs to sign Contract multiContract = Contract.CreateMultiSigContract(2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); - - // construct the script, in this example, we will transfer 10 GAS to receiver - UInt160 scriptHash = NativeContract.GAS.Hash; + // get the scripthash of the multi-signature Contract UInt160 multiAccount = multiContract.Script.ToScriptHash(); + UInt160 receiver = Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash; - byte[] script = scriptHash.MakeScript("transfer", multiAccount, receiver, 10 * NativeContract.GAS.Factor); - - // add Cosigners, this is a collection of scripthashs which need to be signed - Cosigner[] cosigners = new[] { new Cosigner { Scopes = WitnessScope.CalledByEntry, Account = multiAccount } }; - - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, multiAccount) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add multi-signature for the transaction with sendKey - .AddMultiSig(receiverKey, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey) - .AddMultiSig(key2, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey) - // sign the transaction with the added signature - .Sign() - .Tx; - - // broadcast the transaction over the Neo network. - client.SendRawTransaction(tx); + + // construct the script, in this example, we will transfer 1024 GAS to multi-sign account + // in contract parameter, the amount type is BigInteger, so we need to muliply the contract factor + UInt160 scriptHash = NativeContract.GAS.Hash; + byte[] script = scriptHash.MakeScript("transfer", multiAccount, receiver, 1024 * NativeContract.GAS.Factor); + + // add Signers, which is a collection of scripthashs that need to be signed + Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = multiAccount } }; + + // initialize the TransactionManager with rpc client and magic + // fill the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddMultiSig(new KeyPair[]{receiverKey, key2}, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey) + .SignAsync().ConfigureAwait(false); + + // broadcasts the transaction over the Neo network. + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) - .ContinueWith(async (p) => Console.WriteLine($"Transaction is on block {(await p).BlockHash}")); - - Console.ReadKey(); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); } } } - ``` diff --git a/docs/zh-cn/develop/tool/sdk/wallet.md b/docs/zh-cn/develop/tool/sdk/wallet.md index 8eec19c9a..c48ae49f7 100644 --- a/docs/zh-cn/develop/tool/sdk/wallet.md +++ b/docs/zh-cn/develop/tool/sdk/wallet.md @@ -124,7 +124,7 @@ using (wallet.Unlock(password)) ```c# // choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); WalletAPI walletAPI = new WalletAPI(client); ``` @@ -140,7 +140,7 @@ WalletAPI walletAPI = new WalletAPI(client); // get the neo balance of account string tokenHash = NativeContract.NEO.Hash.ToString(); string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; -BigInteger balance = walletAPI.GetTokenBalance(tokenHash, address); +BigInteger balance = await walletAPI.GetTokenBalanceAsync(tokenHash, address).ConfigureAwait(false); ``` 也可以使用 ScriptHash 类型的参数: @@ -150,17 +150,17 @@ BigInteger balance = walletAPI.GetTokenBalance(tokenHash, address); UInt160 tokenScriptHash = Utility.GetScriptHash(tokenHash); UInt160 accountHash = Utility.GetScriptHash(address); Nep5API nep5API = new Nep5API(client); -BigInteger balance = nep5API.BalanceOf(tokenScriptHash, accountHash); +BigInteger balance = await nep5API.BalanceOfAsync(tokenScriptHash, accountHash).ConfigureAwait(false); ``` 在 Neo3 中 NEO 和 GAS 都是 NEP5 资产,且脚本哈希固定,所以这里提供了更简单的接口: ```c# // Get the NEO balance -uint neoBalance = walletAPI.GetNeoBalance(address); +uint neoBalance = await walletAPI.GetNeoBalanceAsync(address).ConfigureAwait(false); // Get the GAS balance -decimal gasBalance = walletAPI.GetGasBalance(address); +decimal gasBalance = await walletAPI.GetGasBalanceAsync(address).ConfigureAwait(false); ``` ## 提取 GAS @@ -172,7 +172,7 @@ decimal gasBalance = walletAPI.GetGasBalance(address); ```c# // Get the claimable GAS of one address string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; - decimal gasAmount = walletAPI.GetUnclaimedGas(address); + decimal gasAmount = await walletAPI.GetUnclaimedGasAsync(address).ConfigureAwait(false); ``` 也可以使用账户的 ScriptHash 查询: @@ -180,7 +180,7 @@ decimal gasBalance = walletAPI.GetGasBalance(address); ```c# string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; UInt160 accountHash = Utility.GetScriptHash(address); - decimal gasAmount = walletAPI.GetUnclaimedGas(accountHash); + decimal gasAmount = await walletAPI.GetUnclaimedGasAsync(accountHash).ConfigureAwait(false); ``` 2. 构建一笔给自己转账的交易,自动提取 GAS: @@ -188,13 +188,13 @@ decimal gasBalance = walletAPI.GetGasBalance(address); ```c# // Claiming GAS needs the KeyPair of account. You can also use wif or private key hex string string wif = "L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"; - Transaction transaction = walletAPI.ClaimGas(wif); + Transaction transaction = await walletAPI.ClaimGasAsync(wif).ConfigureAwait(false); ``` 也可以使用`KeyPair`: ```c# KeyPair keyPair = Utility.GetKeyPair(wif); - Transaction transaction = walletAPI.ClaimGas(keyPair); + Transaction transaction = await walletAPI.ClaimGasAsync(keyPair).ConfigureAwait(false); ``` ## 资产转账 @@ -209,12 +209,12 @@ string wif = "L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"; string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; // Transfer 10 NEO from wif to address -walletAPI.Transfer(tokenHash, wif, address, 10); +await walletAPI.TransferAsync(tokenHash, wif, address, 10).ConfigureAwait(false); // Print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); -neoAPI.WaitTransaction(transaction) - .ContinueWith(async (p) => Console.WriteLine($"Transaction is on block {(await p).BlockHash}")); +await neoAPI.WaitTransactionAsync(transaction) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); ``` 也可以使用 `KeyPair` 和 `UInt160` (ScriptHash): @@ -226,7 +226,7 @@ KeyPair sender = Utility.GetKeyPair(wif); UInt160 receiver = Utility.GetScriptHash(address); // Transfer 10 NEO from wif to address -walletAPI.Transfer(NativeContract.NEO.Hash, sender, receiver, 10); +await walletAPI.TransferAsync(NativeContract.NEO.Hash, sender, receiver, 10).ConfigureAwait(false); ``` 多签账户的 NEP5 转账: @@ -239,10 +239,7 @@ KeyPair keyPair3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5 KeyPair keyPair4 = Utility.GetKeyPair("L3Ke1RSBycXmRukv27L6o7sQWzDwDbFcbfR9oBBwXbCKHdBvb4ZM"); //make transaction -Transaction tx = walletAPI.CreateTransferTx(gas, 3, new ECPoint[] { keyPair1.PublicKey, keyPair2.PublicKey, keyPair3.PublicKey, keyPair4.PublicKey }, new KeyPair[] { keyPair1, keyPair2, keyPair3 }, Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash, new BigInteger(10)); - -//broadcast -RpcClient.SendRawTransaction(tx); +Transaction tx = await walletAPI.TransferAsync(NativeContract.GAS.Hash, 3, new ECPoint[] { keyPair1.PublicKey, keyPair2.PublicKey, keyPair3.PublicKey, keyPair4.PublicKey }, new KeyPair[] { keyPair1, keyPair2, keyPair3 }, Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash, new BigInteger(10 * NativeContract.GAS.Factor)).ConfigureAwait(false); ``` From e5c0d0069f44987cb38756d344bd5387bdc0b262 Mon Sep 17 00:00:00 2001 From: Celia18305 Date: Mon, 30 Nov 2020 18:06:17 +0800 Subject: [PATCH 11/15] updated English SDK --- docs/en-us/develop/tool/sdk/contract.md | 126 +++++++---- docs/en-us/develop/tool/sdk/introduction.md | 4 +- docs/en-us/develop/tool/sdk/monitor.md | 43 ++-- docs/en-us/develop/tool/sdk/rpc.md | 228 +++++++++++--------- docs/en-us/develop/write/nep5.md | 62 +++--- docs/en-us/intro/glossary.md | 8 +- docs/en-us/intro/introduction.md | 14 +- docs/en-us/toc.yml | 2 + docs/zh-cn/develop/tool/sdk/contract.md | 4 +- docs/zh-cn/develop/tool/sdk/rpc.md | 1 + docs/zh-cn/develop/write/nep5.md | 2 +- docs/zh-cn/toc.yml | 2 + 12 files changed, 287 insertions(+), 209 deletions(-) diff --git a/docs/en-us/develop/tool/sdk/contract.md b/docs/en-us/develop/tool/sdk/contract.md index ef7ce1f29..46717a2ae 100644 --- a/docs/en-us/develop/tool/sdk/contract.md +++ b/docs/en-us/develop/tool/sdk/contract.md @@ -10,18 +10,34 @@ This document introduces the following SDK features: ## Contract deployment -`ContractClient` provides the method, `CreateDeployContractTx`, to construct deployment transactions of the contract. The parameters are contract scripts, manifests, and account key pairs for payment of system and network fees, where contract scripts and manifests are available from the compilation. There must be sufficient GAS in the sender account. +`ContractClient` provides the method, `CreateDeployContractTxAsync`, to construct deployment transactions of the contract. The parameters are contract scripts, manifests, and account key pairs for payment of system and network fees, where contract scripts and manifests are available from the compilation. There must be sufficient GAS in the sender account. + +Read the nef and manifest.json files of the contract: + +```C# +// read nefFile & manifestFile +NefFile nefFile; +using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Encoding.UTF8, false)) +{ + nefFile = stream.ReadSerializable(); +} + +ContractManifest manifest = ContractManifest.Parse(File.ReadAllBytes(manifestFilePath)); +``` + +Construct a contract deployment transaction: ```c# // create the deploy contract transaction -Transaction transaction = contractClient.CreateDeployContractTx(script, manifest, senderKey); +byte[] script = nefFile.Script; +Transaction transaction = await contractClient.CreateDeployContractTxAsync(script, manifest, senderKeyPair); ``` After the transaction is constructed, you need to broadcast it on the blockchain: ```c# // Broadcast the transaction over the Neo network -client.SendRawTransaction(transaction); +await client.SendRawTransactionAsync(transaction); Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); ``` @@ -30,9 +46,8 @@ After the transaction is added to the blockchain you can get the transaction exe ```c# // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); -neoAPI.WaitTransaction(transaction) +await neoAPI.WaitTransactionAsync(transaction) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - ``` Here is the complete code: @@ -44,6 +59,8 @@ using Neo.SmartContract; using Neo.SmartContract.Manifest; using Neo.Wallets; using System; +using Neo.IO; +using System.IO; namespace ConsoleApp1 { @@ -51,32 +68,43 @@ namespace ConsoleApp1 { static void Main(string[] args) { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + Test().GetAwaiter().GetResult(); + Console.Read(); + } + + private static async Task Test() + { + // choose a neo node with rpc opened, here we use the localhost + RpcClient client = new RpcClient("http://127.0.0.1:10332"); ContractClient contractClient = new ContractClient(client); - // contract script, it should be from compiled file, we use empty byte[] in this example - byte[] script = new byte[1]; + string nefFilePath = "sc/Contract1.nef"; + string manifestFilePath = "sc/Contract1.manifest.json"; - // we use default ContractManifest in this example - ContractManifest manifest = ContractManifest.CreateDefault(script.ToScriptHash()); + // read nefFile & manifestFile + NefFile nefFile; + using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Encoding.UTF8, false)) + { + nefFile = stream.ReadSerializable(); + } + + ContractManifest manifest = ContractManifest.Parse(File.ReadAllBytes(manifestFilePath)); // deploying contract needs sender to pay the system fee - KeyPair senderKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); + KeyPair senderKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); // create the deploy transaction - Transaction transaction = contractClient.CreateDeployContractTx(script, manifest, senderKey); + byte[] script = nefFile.Script; + Transaction transaction = await contractClient.CreateDeployContractTxAsync(script, manifest, senderKey).ConfigureAwait(false); - // Broadcast the transaction over the Neo network - client.SendRawTransaction(transaction); + // Broadcast the transaction over the NEO network + await client.SendRawTransactionAsync(transaction).ConfigureAwait(false); Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(transaction) + await neoAPI.WaitTransactionAsync(transaction) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); } } } @@ -84,28 +112,34 @@ namespace ConsoleApp1 ## Contract invocation simulation -`ContractClient` provides the method `TestInvoke` to simulate the contract invocation, which does not affect the data on the chain after execution. You can directly invoke the contract method that reads the data. For example, the following example invokes the name method in the NEO native contract. +`ContractClient` provides the method `TestInvokeAsync` to simulate the contract invocation, which does not affect the data on the chain after execution. You can directly invoke the contract method that reads the data. For example, the following example invokes the name method in the NEO native contract. ```c# // choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); ContractClient contractClient = new ContractClient(client); // get the contract hash UInt160 scriptHash = NativeContract.NEO.Hash; // test invoking the method provided by the contract -string name = contractClient.TestInvoke(scriptHash, "name") - .Stack.Single().ToStackItem().GetString(); +RpcInvokeResult invokeResult = await contractClient.TestInvokeAsync(scriptHash, "name").ConfigureAwait(false); +Console.WriteLine($"The name is {invokeResult.Stack.Single().GetString()}"); ``` -Or you can use `MakeScript` to construct the script you want to execute and then invoke `InvokeScript` to get the execution result. +Or you can use `MakeScript` to construct the script you want to execute and then invoke the method `InvokeScriptAsync` in `RpcClient`to get the execution result. ```c# -// construct the script you want to run in test mode +// choose a neo node with rpc opened +RpcClient client = new RpcClient("http://127.0.0.1:10332"); + +// get the contract hash +UInt160 scriptHash = NativeContract.NEO.Hash; + byte[] script = scriptHash.MakeScript("name"); // call invoke script -name = client.InvokeScript(script).Stack.Single().ToStackItem().GetString(); +RpcInvokeResult invokeResult = await client.InvokeScriptAsync(script).ConfigureAwait(false); +Console.WriteLine($"The name is {invokeResult.Stack.Single().GetString()}"); ``` ## Contract invocation (on-chain transactions) @@ -117,30 +151,27 @@ Generally invoking a deployed contract on the blockchain contains the following Take the `transfer` method of native contract Neo as an example: ```c# - // construct the script, in this example, we will transfer 1 NEO to receiver + // construct the script, in this example, we will transfer 1024 NEO to receiver UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); + byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1024); ``` 2. Construct the transaction: ```c# - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, sender) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add signature for the transaction with sendKey - .AddSignature(sendKey) - // sign transaction with the added signature - .Sign() - .Tx; + // initialize the TransactionManagerFactory with rpc client and magic + // fill the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddSignature(sendKey).SignAsync().ConfigureAwait(false); ``` - + 3. Broadcast the transaction on the blockchain: ```c# // broadcasts the transaction over the Neo network - client.SendRawTransaction(tx); + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); ``` 4. Wait until the transaction is added to the blockchain and then get the transaction execution status to make sure the contract is invoked successfully: @@ -148,7 +179,7 @@ Generally invoking a deployed contract on the blockchain contains the following ```c# // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) + await neoAPI.WaitTransactionAsync(tx) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); ``` @@ -160,22 +191,29 @@ For complete code refer to [Transaction Construction](transaction.md). ```c# Nep5API nep5API = new Nep5API(client); -Transaction tx = nep5API.CreateTransferTx(scriptHash, sendKey, receiver, 1); +Transaction tx = await nep5API.CreateTransferTxAsync(scriptHash, sendKey, receiver, 1).ConfigureAwait(false); ``` Additionally, `Nep5API` also provides a set of simple methods to get data: ```c# // get nep5 name -string name = nep5API.Name(scriptHash); +string name = await nep5API.NameAsync(NativeContract.NEO.Hash).ConfigureAwait(false); // get nep5 symbol -string symbol = nep5API.Symbol(scriptHash); +string symbol = await nep5API.SymbolAsync(NativeContract.NEO.Hash).ConfigureAwait(false); // get nep5 token decimals -uint decimals = nep5API.Decimals(scriptHash); +byte decimals = await nep5API.DecimalsAsync(NativeContract.NEO.Hash).ConfigureAwait(false); // get nep5 token total supply -BigInteger totalSupply = nep5API.TotalSupply(scriptHash); +BigInteger totalSupply = await nep5API.TotalSupplyAsync(NativeContract.NEO.Hash).ConfigureAwait(false); + +// get the balance of nep5 token +UInt160 account = Utility.GetScriptHash("NXjtqYERuvSWGawjVux8UerNejvwdYg7eE"); +BigInteger balance = await nep5API.BalanceOfAsync(NativeContract.NEO.Hash, account).ConfigureAwait(false); + +// get token information +RpcNep5TokenInfo tokenInfo = await nep5API.GetTokenInfoAsync(NativeContract.NEO.Hash).ConfigureAwait(false); ``` diff --git a/docs/en-us/develop/tool/sdk/introduction.md b/docs/en-us/develop/tool/sdk/introduction.md index 75832de2b..151a98f81 100644 --- a/docs/en-us/develop/tool/sdk/introduction.md +++ b/docs/en-us/develop/tool/sdk/introduction.md @@ -40,9 +40,9 @@ This document is applicable to Neo3 preview2. It is recommended you use NEO SDK `Neo RPC SDK` mainly interacts with Neo nodes through RPC requests. When the message returned by the RPC request contains an Error the system throws an exception. The most common exception type is `RpcException`, which includes: -- -100, "Unknown transaction" or "Unknown block" +- -100, "Unknown transaction/blockhash" - -300, "Insufficient funds" -- -301, "The transaction is failed because the necessary fee exceeds the Max_fee. Please increase your Max_fee value." +- -301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value." - -400, "Access denied" - -500, Relay does not succeed, the detailed reasons contain "AlreadyExists, OutOfMemory, UnableToVerify, Invalid, Expired, InsufficientFunds, PolicyFail, Unknown" - -32600, "Invalid Request" diff --git a/docs/en-us/develop/tool/sdk/monitor.md b/docs/en-us/develop/tool/sdk/monitor.md index 2a95cc096..1c658656a 100644 --- a/docs/en-us/develop/tool/sdk/monitor.md +++ b/docs/en-us/develop/tool/sdk/monitor.md @@ -11,30 +11,36 @@ Gets the latest block height or hash: ```c# // choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); -// get the highest block hash -string hash = client.GetBestBlockHash(); +// get the hash of the tallest block in the main chain +string hash = await client.GetBestBlockHashAsync().ConfigureAwait(false); -// get the highest block height -uint height = client.GetBlockCount() - 1; +// get the number of blocks in the main chain +uint count = await client.GetBlockCountAsync().ConfigureAwait(false); ``` Gets the specific data inside a block, including transaction list, etc. ```c# -// get block data -RpcBlock block = client.GetBlock("166396"); +// get the Base64 string of the block with block height +string blockHex = await client.GetBlockHexAsync("166396").ConfigureAwait(false); + +// get the Base64 string of the block with block hash +string blockHex = await client.GetBlockHexAsync("0x4e61cd9d76e30e9147ee0f5b9c92f4447decbe52c6c8b412d0382a14d3a0b408").ConfigureAwait(false); + +// get block data with block height +RpcBlock block = await client.GetBlockAsync("166396").ConfigureAwait(false); // get block data with block hash -RpcBlock block = client.GetBlock("0x953f6efa29c740b68c87e0a060942056382a6912a0ddeddc2f6641acb92d9700"); +RpcBlock block = await client.GetBlockAsync("0x4e61cd9d76e30e9147ee0f5b9c92f4447decbe52c6c8b412d0382a14d3a0b408").ConfigureAwait(false); ``` Gets the contract script, hash, and manifest through `RpcClient`: ```c# // get NEO contract state -ContractState contractState = client.GetContractState(NativeContract.NEO.Hash.ToString()); +ContractState contractState = await client.GetContractStateAsync(NativeContract.NEO.Hash.ToString()).ConfigureAwait(false); ``` For more information refer to [RPC invocation methods](rpc.md). @@ -45,19 +51,20 @@ Invokes the method `policyAPI` in the native contract `PolicyContract` to get t ```c# // choose a neo node with rpc opened -PolicyAPI policyAPI = new PolicyAPI(new RpcClient("http://seed1t.neo.org:20332")); - -// get the accounts blocked by policy -UInt160[] blockedAccounts = policyAPI.GetBlockedAccounts(); // [], no account is blocked by now +PolicyAPI policyAPI = new PolicyAPI(new RpcClient("http://127.0.0.1:10332")); // get the system fee per byte -long feePerByte = policyAPI.GetFeePerByte(); // 1000, 0.00001000 GAS per byte +long feePerByte = await policyAPI.GetFeePerByteAsync().ConfigureAwait(false); // 1000, 0.00001000 GAS per byte // get the max size of one block -uint maxBlockSize = policyAPI.GetMaxBlockSize(); // 262144, (1024 * 256) bytes one block +uint maxBlockSize = await policyAPI.GetMaxBlockSizeAsync().ConfigureAwait(false); // 262144, (1024 * 256) bytes one block // get the max transaction count per block -uint maxTransactionsPerBlock = policyAPI.GetMaxTransactionsPerBlock(); // 512, max 512 transactions one block +uint maxTransactionsPerBlock = await policyAPI.GetMaxTransactionsPerBlockAsync().ConfigureAwait(false); // 512, max 512 transactions one block + +// check if the account is blocked +UInt160 account = Utility.GetScriptHash("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); +bool isBlocked = await policyAPI.IsBlockedAsync(account).ConfigureAwait(false); ``` ## Getting NEP-5 contract information @@ -66,7 +73,7 @@ NEP5 is an asset standard for Neo3, such as NEO and GAS, both of which are asset ```c# // get nep5 token info -Nep5API nep5API = new Nep5API(client); -RpcNep5TokenInfo tokenInfo = nep5API.GetTokenInfo(NativeContract.NEO.Hash); +Nep5API nep5API = new Nep5API(new RpcClient("http://127.0.0.1:10332")); +RpcNep5TokenInfo tokenInfo = await nep5API.GetTokenInfoAsync(NativeContract.NEO.Hash).ConfigureAwait(false); ``` diff --git a/docs/en-us/develop/tool/sdk/rpc.md b/docs/en-us/develop/tool/sdk/rpc.md index f4e2a42c6..98cc02ec4 100644 --- a/docs/en-us/develop/tool/sdk/rpc.md +++ b/docs/en-us/develop/tool/sdk/rpc.md @@ -17,7 +17,7 @@ Local node (the local Neo-CLI that can be connected to main net, test net, or pr ```c# // Local Node -RpcClient client = new RpcClient("http://localhost:10332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); ``` > [!Note] @@ -26,52 +26,52 @@ RpcClient client = new RpcClient("http://localhost:10332"); ## Blockchain data -### GetBestBlockHash +### GetBestBlockHashAsync Gets the hash of the highest block in the blockchain: ```c# -string hexString = client.GetBestBlockHash(); +string hexString = await client.GetBestBlockHashAsync().ConfigureAwait(false); byte[] hashBytes = hexString.HexToBytes(); UInt256 hash256 = UInt256.Parse(hexString); ``` -### GetBlock +### GetBlockAsync Gets the detailed block information by the block hash or block index. ```c# -Block block = client.GetBlock("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e").Block; +RpcBlock rpcBlock = await client.GetBlockAsync("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e").ConfigureAwait(false); +Block block = rpcBlock.Block; ``` or ```c# -Block block = client.GetBlock("10000").Block; +RpcBlock rpcBlock = await client.GetBlockAsync("1024").ConfigureAwait(false); +Block block = rpcBlock.Block; ``` -### GetBlockHex - -Gets the serialized block information by the block hash or block index: +You can also get the serialized block information through the block hash value or block index: ```c# -string serializedBlock = client.GetBlockHex("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e"); +string serializedBlock = await client.GetBlockHexAsync("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e").ConfigureAwait(false); ``` -### GetBlockCount +### GetBlockCountAsync Gets the current block quantity. Block index(Index) = Block height(Height) = Block count(Count) - 1 ```c# -uint blockCount = client.GetBlockCount(); +uint blockCount = await client.GetBlockCountAsync().ConfigureAwait(false); ``` -### GetBlockHash +### GetBlockHashAsync Gets the block hash by the block index. ```c# -string hexString = client.GetBlockHash(10000); +string hexString = await client.GetBlockHashAsync(10000).ConfigureAwait(false); byte[] hashBytes = hexString.HexToBytes(); UInt256 hash256 = UInt256.Parse(hexString); ``` @@ -80,92 +80,102 @@ UInt256 hash256 = UInt256.Parse(hexString); Get the specific block header information by the block hash or block index: ```c# -Header header = client.GetBlockHeader("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957").Header; +RpcBlockHeader blockHeader = await client.GetBlockHeaderAsync("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957").ConfigureAwait(false); +Header header = blockHeader.Header; ``` or ```c# -Header header = client.GetBlockHeader("10000").Header; +RpcBlockHeader blockHeader = await client.GetBlockHeaderAsync("10000").ConfigureAwait(false); +Header header = blockHeader.Header; ``` Get the serialized block header information from the block hash or block index: ```c# -string serializedBlockHeader = client.GetBlockHeaderHex("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957"); +string serializedBlockHeader = await client.GetBlockHeaderHexAsync("a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957").ConfigureAwait(false); ``` -### GetBlockSysFee -Gets the system fee for the block and all the previous blocks through the specific block index. +or -```c# -BigInteger sysFee = client.GetBlockSysFee(10000); +``` +string serializedBlockHeader = await client.GetBlockHeaderHexAsync("10000").ConfigureAwait(false); ``` -### GetContractState +### GetContractStateAsync Gets the contract information from the contract hash or contract ID ```c# -ContractState contractState = client.GetContractState("dc675afc61a7c0f7b3d2682bf6e1d8ed865a0e5f"); +ContractState contractState = await client.GetContractStateAsync("dc675afc61a7c0f7b3d2682bf6e1d8ed865a0e5f").ConfigureAwait(false); ``` ```c# ContractState contractState = client.GetContractState(-1); ``` -### GetRawMempool +### GetRawMempoolAsync Gets hash list of the confirmed transactions in the memory. ```c# -string[] verifiedTransactions = client.GetRawMempool(); +string[] verifiedTransactions = await client.GetRawMempoolAsync().ConfigureAwait(false); ``` -### GetRawMempoolBoth +### GetRawMempoolBothAsync -Gets the hash list of both confirmed and unconfirmed transactions in memory. +Gets both confirmed and unconfirmed transaction hashes in memory: ```c# -RpcRawMemPool memPool = client.GetRawMempoolBoth(); +RpcRawMemPool memPool = await client.GetRawMempoolBothAsync().ConfigureAwait(false); string[] verifiedTransactions = memPool.Verified; string[] unverifiedTransactions = memPool.UnVerified; ``` -### GetRawTransaction +### GetRawTransactionAsync Gets the transaction information by transaction ID. ```c# -RpcTransaction rpcTransaction = client.GetRawTransaction("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657"); +RpcTransaction rpcTransaction = await client.GetRawTransactionAsync("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657").ConfigureAwait(false); Transaction transaction = rpcTransaction.Transaction; ``` -### GetRawTransactionHex +### GetRawTransactionHexAsync Gets the serialized transaction by transaction ID. ```c# -string serializedTransaction = client.GetRawTransactionHex("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657"); +string serializedTransaction = await client.GetRawTransactionHexAsync("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657").ConfigureAwait(false); ``` -### GetStorage +### CalculateNetworkFeeAsync + +Calculates network fee of the specified transaction. + +``` +long networkFee = await rpcClient.CalculateNetworkFeeAsync(transaction).ConfigureAwait(false); +``` + +### GetStorageAsync + Gets the stored value through the contract script hash and stored key (which needs to be converted into a hex string): ```c# -string value = client.GetStorage("03febccf81ac85e3d795bc5cbd4e84e907812aa3", "5065746572"); +string value = await client.GetStorageAsync("03febccf81ac85e3d795bc5cbd4e84e907812aa3", "5065746572").ConfigureAwait(false); ``` -### GetTransactionHeight +### GetTransactionHeightAsync Gets the block height of the specified transaction by transaction ID: ```c# -uint height = client.GetTransactionHeight("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657"); +uint height = await client.GetTransactionHeightAsync("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657").ConfigureAwait(false); ``` -### GetValidators +### GetNextBlockValidatorsAsync Gets the consensus nodes information and voting status in the current network. ```c# -RpcValidator[] rpcValidators = client.GetValidators(); +RpcValidator[] rpcValidators = await client.GetNextBlockValidatorsAsync().ConfigureAwait(false); foreach (var validator in rpcValidators) { string publicKey = validator.PublicKey; @@ -174,20 +184,28 @@ foreach (var validator in rpcValidators) } ``` +### GetCommitteeAsync + +Gets the public key list of the current committee members. + +```c# +string[] committees = await client.GetCommitteeAsync().ConfigureAwait(false); +``` + ## Node ### GetConnectionCount Gets the number of nodes connected to this node. ```c# -int connectionCount = client.GetConnectionCount(); +int connectionCount = await client.GetConnectionCountAsync().ConfigureAwait(false); ``` -### GetPeers +### GetPeersAsync Gets a list of currently connected / unconnected nodes for this node, including IP address and port. ```c# -RpcPeers rpcPeers = client.GetPeers(); +RpcPeers rpcPeers = await client.GetPeersAsync().ConfigureAwait(false);; RpcPeer[] connected = rpcPeers.Connected; RpcPeer[] unconnected = rpcPeers.Unconnected; if (connected.Length > 0) @@ -198,39 +216,37 @@ if (connected.Length > 0) } ``` -### GetVersion +### GetVersionAsync Gets the version of the node receiving the RPC request: ```c# -RpcVersion rpcVersion = client.GetVersion(); +RpcVersion rpcVersion = await client.GetVersionAsync().ConfigureAwait(false); string version = rpcVersion.UserAgent; ``` -### SendRawTransaction +### SendRawTransactionAsync Sends and broadcasts the serialized transaction. ```c# -bool result = client.SendRawTransaction("80000001195876cb34364dc38b730077156c6bc3a7fc570044a66fbfeeea56f71327e8ab0000029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500c65eaf440000000f9a23e06f74cf86b8827a9108ec2e0f89ad956c9b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50092e14b5e00000030aab52ad93f6ce17ca07fa88fc191828c58cb71014140915467ecd359684b2dc358024ca750609591aa731a0b309c7fb3cab5cd0836ad3992aa0a24da431f43b68883ea5651d548feb6bd3c8e16376e6e426f91f84c58232103322f35c7819267e721335948d385fae5be66e7ba8c748ac15467dcca0693692dac"); +UInt256 txHash = await client.SendRawTransactionAsync("80000001195876cb34364dc38b730077156c6bc3a7fc570044a66fbfeeea56f71327e8ab0000029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500c65eaf440000000f9a23e06f74cf86b8827a9108ec2e0f89ad956c9b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50092e14b5e00000030aab52ad93f6ce17ca07fa88fc191828c58cb71014140915467ecd359684b2dc358024ca750609591aa731a0b309c7fb3cab5cd0836ad3992aa0a24da431f43b68883ea5651d548feb6bd3c8e16376e6e426f91f84c58232103322f35c7819267e721335948d385fae5be66e7ba8c748ac15467dcca0693692dac").ConfigureAwait(false); ``` -When `result` is `true` the transaction is broadcast successfully. +Or broadcasts the transaction (tx) over the blockchain: -When `result` is `false` the transaction broadcast fails due to double costs, incomplete signatures, etc. +```c# +UInt256 txHash = await client.SendRawTransactionAsync(transaction).ConfigureAwait(false); +``` -### SubmitBlock +### SubmitBlockAsync Sends and broadcasts the serialized block: ```c# -bool result = client.SubmitBlock("000000000000000000000000000000000000000000000000000000000000000000000000845c34e7c1aed302b1718e914da0c42bf47c476ac4d89671f278d8ab6d27aa3d65fc8857000000001dac2b7c00000000be48d3a3f5d10013ab9ffee489706078714f1ea2010001510400001dac2b7c00000000400000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000400001445b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e5b881227d2c7b226c616e67223a22656e222c226e616d65223a22416e74436f696e227d5d0000c16ff286230008009f7fd096d37ed2c0e3f7f0cfc924beef4ffceb680000000001000000019b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50000c16ff2862300be48d3a3f5d10013ab9ffee489706078714f1ea201000151"); +UInt256 blockHash = await client.SubmitBlockAsync("000000000000000000000000000000000000000000000000000000000000000000000000845c34e7c1aed302b1718e914da0c42bf47c476ac4d89671f278d8ab6d27aa3d65fc8857000000001dac2b7c00000000be48d3a3f5d10013ab9ffee489706078714f1ea2010001510400001dac2b7c00000000400000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000400001445b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e5b881227d2c7b226c616e67223a22656e222c226e616d65223a22416e74436f696e227d5d0000c16ff286230008009f7fd096d37ed2c0e3f7f0cfc924beef4ffceb680000000001000000019b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc50000c16ff2862300be48d3a3f5d10013ab9ffee489706078714f1ea201000151").ConfigureAwait(false); ``` -When `result` is `true` the block is broadcast successfully. - -When `result` is `false` the block broadcast fails with exception. - ## Smart contract -### InvokeFunction +### InvokeFunctionAsync Invokes the specific method of the smart contract through the specified smart contract script hash, method name, and parameters, and returns the result after running in the virtual machine. ```c# @@ -240,7 +256,7 @@ RpcStack rpcStack = new RpcStack() Value = "91b83e96f2a7c4fdf0c1688441ec61986c7cae26" }; UInt160 scriptHashesForVerifying = UInt160.Parse("0x20e22e16cfbcfdd29f347268427b76863b7679fa"); -RpcInvokeResult rpcInvokeResult = client.InvokeFunction("af7c7328eee5a275a3bcaee2bf0cf662b5e739be", "balanceOf", new RpcStack[] { rpcStack },scriptHashesForVerifying); +RpcInvokeResult rpcInvokeResult = await client.InvokeFunctionAsync("af7c7328eee5a275a3bcaee2bf0cf662b5e739be", "balanceOf", new RpcStack[] { rpcStack },scriptHashesForVerifying).ConfigureAwait(false); string script = rpcInvokeResult.Script; string engineState = rpcInvokeResult.State; long gasConsumed = long.Parse(rpcInvokeResult.GasConsumed); @@ -253,22 +269,32 @@ foreach (var item in resultStacks) string transaction = rpcInvokeResult.Tx; ``` -### InvokeScript +### InvokeScriptAsync Returns the result after running the specified script in the virtual machine. ```c# byte[] script = "00046e616d656724058e5e1b6008847cd662728549088a9ee82191".HexToBytes(); UInt160 scriptHashesForVerifying = UInt160.Parse("0x20e22e16cfbcfdd29f347268427b76863b7679fa"); -RpcInvokeResult rpcInvokeResult = client.InvokeScript(script,scriptHashesForVerifying); +RpcInvokeResult rpcInvokeResult = await client.InvokeScriptAsync(script, scriptHashesForVerifying).ConfigureAwait(false); +``` + +### GetUnclaimedGasAsync + +Gets amount of unclaimed GAS at the specified address. + +```c# +RpcUnclaimedGas unclaimedGas = await client.GetUnclaimedGasAsync("NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM").ConfigureAwait(false); +BigInteger unclaimed = unclaimedGas.Unclaimed; +string address = unclaimedGas.Address; ``` ## Tools -### ListPlugins +### ListPluginsAsync Lists all the plugins loaded in the node. ```c# -RpcPlugin[] rpcPlugins = client.ListPlugins(); +RpcPlugin[] rpcPlugins = await client.ListPluginsAsync().ConfigureAwait(false); foreach (var item in rpcPlugins) { string name = item.Name; @@ -276,11 +302,12 @@ foreach (var item in rpcPlugins) } ``` -### ValidateAddress +### ValidateAddressAsync Validates if the specified address is a valid Neo address. ```c# -RpcValidateAddressResult result = client.ValidateAddress("AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i"); +RpcValidateAddressResult result = await client.ValidateAddressAsync("AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i").ConfigureAwait(false); +string address = result.Address; bool isValid = result.IsValid; ``` @@ -289,66 +316,67 @@ The node local wallet interface contains the function of accessing the local wal This method is disabled by default in the node configuration file for preventing high security risks. -### CloseWallet +### OpenWalletAsync + +Opens the wallet file in the machine running the node. + +```c# +string path = "D:/temp/123.json"; +string password = "Password***"; +bool result = await client.OpenWalletAsync(path, password).ConfigureAwait(false); +``` + +### CloseWalletAsync Closes the wallet and clears the wallet information in memory. ```c# -bool result = client.CloseWallet(); +bool result = await client.CloseWalletAsync().ConfigureAwait(false); ``` -### DumpPrivKey +### DumpPrivKeyAsync Exports the private key of the specified address. ```c# -string wif = client.DumpPrivKey("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"); +string wif = await client.DumpPrivKeyAsync("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ").ConfigureAwait(false); ``` -### GetBalance +### GetBalanceAsync Returns balance of the specified asset in the wallet by the asset id. This method is applicable to the native contract assets and NEP-5 compliant assets. ```c# -BigInteger balance = client.GetBalance(NativeContract.NEO.Hash.ToString()); +BigDecimal balance = await client.GetWalletBalanceAsync(NativeContract.NEO.Hash.ToString()).ConfigureAwait(false); ``` -### GetNewAddress +### GetNewAddressAsync Creates a new account in the wallet and returns the corresponding address. ```c# -string address = client.GetNewAddress(); +string address = await client.GetNewAddressAsync().ConfigureAwait(false); ``` -### GetUnclaimedGas +### GetUnclaimedGasAsync Displays amount of the unclaimed GAS in the wallet. ```c# -BigInteger amount = client.GetUnclaimedGas(); +BigInteger amount = await client.GetWalletUnclaimedGasAsync().ConfigureAwait(false); ``` -### ImportPrivKey +### ImportPrivKeyAsync Imports the private key into the wallet. ```c# string wif = "KyoYyZpoccbR6KZ25eLzhMTUxREwCpJzDsnuodGTKXSG8fDW9t7x"; -RpcAccount account = client.ImportPrivKey(wif); +RpcAccount account = await client.ImportPrivKeyAsync(wif).ConfigureAwait(false); ``` -### ListAddress +### ListAddressAsync Lists all the addresses in the wallet. ```c# -List acoounts = client.ListAddress(); -``` - -### OpenWallet -Opens the wallet file in the machine where the node is located: - -```c# -string path = "D:/temp/123.json"; -string pass = "Password***"; -bool result = client.OpenWallet(path, pass); +List acoounts = await client.ListAddressAsync().ConfigureAwait(false); ``` -### SendFrom +### SendFromAsync Transfers asset from a specified address to another address. ```c# @@ -356,7 +384,7 @@ string assetId = NativeContract.NEO.Hash.ToString(); string fromAddress = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; string toAddress= "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; string amount = "100"; -JObject result = client.SendFrom(assetId, fromAddress, toAddress, amount); +JObject result = await client.SendFromAsync(assetId, fromAddress, toAddress, amount).ConfigureAwait(false); ``` If the JSON transaction information is returned the transaction was sent successfully, or the transaction failed to be sent. @@ -364,7 +392,7 @@ If the signature is incomplete transaction to be signed is returned. If the balance is insufficient an error is returned. -### SendMany +### SendManyAsync Transfers assets to multiple addresses. You can specify the sending address. ```c# @@ -381,7 +409,7 @@ outs.Add(new RpcTransferOut ScriptHash = Utility.GetScriptHash("NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"), Value = "100.12345678" }); -JObject result = client.SendMany("", outs); +JObject result = await client.SendManyAsync("", outs).ConfigureAwait(false); ``` If the JSON transaction information is returned the transaction was sent successfully, or the transaction failed to be sent. @@ -389,14 +417,14 @@ If the signature is incomplete transaction to be signed is returned. If the balance is insufficient an error is returned. -### SendToAddress +### SendToAddressAsync Transfers asset to the specified address. ```c# string assetId = NativeContract.NEO.Hash.ToString(); string toAddress = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; string amount = "100"; -JObject result = client.SendToAddress(assetId, toAddress,amount); +JObject result = await client.SendToAddressAsync(assetId, toAddress, amount).ConfigureAwait(false); ``` If the JSON transaction information is returned the transaction was sent successfully, or the transaction failed to be sent. @@ -406,23 +434,31 @@ If the balance is insufficient an error is returned. ## Plugins -### GetApplicationLog +### GetApplicationLogAsync Gets the contract log by the specific transaction ID. The plugin ApplicationLogs is required for invoking this method. ```c# string txHash = "0x23bf33766d00b4bb3314185f1ff0c2c85182d4d5e4e96f7c2df7506e7f99098b"; -RpcApplicationLog log = client.GetApplicationLog(txHash); +RpcApplicationLog log = await client.GetApplicationLogAsync(txHash).ConfigureAwait(false); +``` + +Or gets the contract log based on the specified transaction ID and trigger type + +```c# +string txHash = "0x23bf33766d00b4bb3314185f1ff0c2c85182d4d5e4e96f7c2df7506e7f99098b"; +RpcApplicationLog log = await client.GetApplicationLogAsync(txHash, TriggerType.Application).ConfigureAwait(false); ``` -### GetNep5Balances +### GetNep5BalancesAsync + Returns all NEP-5 assets balance at the specified address. The plugin RpcNep5Tracker is required for invoking this method. ```c# string address = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; -RpcNep5Balances balances = client.GetNep5Balances(address); +RpcNep5Balances balances = await client.GetNep5BalancesAsync(address).ConfigureAwait(false); ``` -### GetNep5Transfers +### GetNep5TransfersAsync Returns all NEP-5 transaction records at the specific address. The plugin RpcNep5Tracker is required for invoking this method. If start and end timestamps are specified, transactions occurred in the time range is returned. @@ -431,5 +467,5 @@ If no parameter is specified transactions in the past seven days are returned. ```c# string address = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; -RpcNep5Transfers transfers = client.GetNep5Transfers(address, 0); +RpcNep5Transfers transfers = await client.GetNep5TransfersAsync(address, 0).ConfigureAwait(false); ``` diff --git a/docs/en-us/develop/write/nep5.md b/docs/en-us/develop/write/nep5.md index d30db0342..9b0a82d93 100644 --- a/docs/en-us/develop/write/nep5.md +++ b/docs/en-us/develop/write/nep5.md @@ -1,8 +1,8 @@ -# NEP-5 +# NEP-17 -The NEP-5 proposal outlines a token standard for the Neo blockchain that will provide systems with a generalized interaction mechanism for tokenized Smart Contracts. +The NEP-17 proposal is a replacement of the original NEP5 proposal, which outlines a token standard for the Neo blockchain that will provide systems with a generalized interaction mechanism for tokenized Smart Contracts. -NEP5 assets are recorded in the contract storage area, through updating account balance in the storage area, to complete the transaction. +NEP17 assets are recorded in the contract storage area, through updating account balance in the storage area, to complete the transaction. In the method definitions below, we provide both the definitions of the functions as they are defined in the contract as well as the invoke parameters. @@ -14,22 +14,17 @@ public static BigInteger totalSupply() Returns the total token supply deployed in the system. -**name** -```c# -public static string name() -``` - -Returns the name of the token. e.g. "MyToken". - -This method MUST always return the same value every time it is invoked. - **symbol** ```c# public static string symbol() ``` -Returns a short string symbol of the token managed in this contract. e.g. "MYT". This symbol SHOULD be short (3-8 characters is recommended), with no whitespace characters or new-lines and SHOULD be limited to the uppercase latin alphabet (i.e. the 26 letters used in English). +Returns a short string symbol of the token managed in this contract. e.g. "MYT". + +This symbol must be a valid ASCII string, with no whitespace characters or new-lines, and should be short (3-8 characters is recommended) uppercase latin alphabet (i.e. the 26 letters used in English). + +This method MUST always return the same value every time it is invoked. **decimals** @@ -49,9 +44,9 @@ public static BigInteger balanceOf(byte[] account) Returns the token balance of the `account`. -The parameter `account` SHOULD be a 20-byte address. If not, this method SHOULD throw an exception. +The parameter `account` must be a 20-byte address. If not, this method should throw an exception. -If the `account` is an unused address, this method MUST return 0. +If the `account` is an unused address, this method must return 0. **transfer** @@ -59,22 +54,19 @@ If the `account` is an unused address, this method MUST return 0. public static bool transfer(byte[] from, byte[] to, BigInteger amount) ``` -Transfers an amount of tokens from the from account to the to account.
- -The parameters from and to SHOULD be 20-byte addresses. If not, this method SHOULD throw an exception.
+The parameters `from` and `to` should be 20-byte addresses. If not, this method should throw an exception.
-The parameter amount MUST be greater than or equal to 0. If not, this method SHOULD throw an exception.
+The parameter amount must be greater than or equal to 0. If not, this method should throw an exception.
-The function MUST return false if the from account balance does not have enough tokens to spend.
+The function must return false if the `from` account balance does not have enough tokens to spend.
-If the method succeeds, it MUST fire the transfer event, and MUST return true, even if the amount is 0, or from and to are the same address.
+If the method succeeds, it must fire the `Transfer` event, and must return `true`, even if the `amount` is 0, or `from` and `to` are the same address.
-The function SHOULD check whether the from address equals the caller contract hash. If so, the transfer SHOULD be processed; If not, the function SHOULD use the SYSCALL `Neo.Runtime.CheckWitness` to verify the transfer.
+The function SHOULD check whether the `from` address equals the caller contract hash. If so, the transfer SHOULD be processed; If not, the function SHOULD use the SYSCALL `Neo.Runtime.CheckWitness` to verify the transfer.
-If the to address is a deployed contract, the function SHOULD check the payable flag of this contract to decide whether it should transfer the tokens to this contract.
- -If the transfer is not processed, the function SHOULD return false. +If the transfer is not processed successfully, the function must return `false`. +If `to` is the address hash of a deployed contract, the function must invoke the `onPayment` method of the contract after triggering the `Transfer` event. If the contract `to` does not want to receive the transfer, it must invoke the opcode `ABORT`. **Transfer Event** @@ -82,11 +74,11 @@ If the transfer is not processed, the function SHOULD return false. public static event transfer(byte[] from, byte[] to, BigInteger amount) ``` -MUST trigger when tokens are transferred, including zero value transfers.
+This event MUST be triggered when tokens are transferred, including the case where `amount` is 0 and `from` and `to` are the same address.
-A token contract which creates new tokens MUST trigger a `transfer` event with the from address set to null when tokens are created.
+A token contract which creates new tokens MUST trigger a `Transfer` event with the `from` address set to null when tokens are created.
-A token contract which burns tokens MUST trigger a `transfer` event with the to address set to null when tokens are burned. +A token contract which burns tokens MUST trigger a `Transfer` event with the `to` address set to null when tokens are burned. Here is the complete [NEP-5 contract code](https://github.com/neo-ngd/Neo3-Smart-Contract-Examples/blob/master/NEP5/Contract1.cs): @@ -103,7 +95,7 @@ namespace NEP5 [Features(ContractFeatures.HasStorage)] public class NEP5 : SmartContract { - [DisplayName("transfer")] + [DisplayName("Transfer")] public static event Action Transferred; private static readonly BigInteger TotalSupplyValue = 10000000000000000; @@ -159,17 +151,16 @@ namespace NEP5 public static BigInteger BalanceOf(byte[] account) { if (account.Length != 20) - throw new InvalidOperationException("The parameter account SHOULD be 20-byte addresses."); + throw new InvalidOperationException("The parameter account SHOULD be 20-byte non-zero addresses."); return asset.Get(account).TryToBigInteger(); } [DisplayName("decimals")] public static byte Decimals() => 8; - private static bool IsPayable(byte[] to) + private static void onPayment(BigInteger amount) { - var c = Blockchain.GetContract(to); - return c == null || c.IsPayable; + SmartContract.Abort(); } [DisplayName("name")] @@ -199,8 +190,6 @@ namespace NEP5 throw new InvalidOperationException("The parameters from and to SHOULD be 20-byte addresses."); if (amount <= 0) throw new InvalidOperationException("The parameter amount MUST be greater than 0."); - if (!IsPayable(to)) - return false; if (!Runtime.CheckWitness(from) && from.TryToBigInteger() != callscript.TryToBigInteger()) return false; var fromAmount = asset.Get(from).TryToBigInteger(); @@ -220,6 +209,9 @@ namespace NEP5 asset.Put(to, toAmount + amount); Transferred(from, to, amount); + + // Validate payable + if (Blockchain.GetContract(to) != null) Contract.Call(to, "onPayment", new object[] { amount }); return true; } } diff --git a/docs/en-us/intro/glossary.md b/docs/en-us/intro/glossary.md index b76e04291..c6361cae6 100644 --- a/docs/en-us/intro/glossary.md +++ b/docs/en-us/intro/glossary.md @@ -26,7 +26,7 @@ A script is a piece of code that consists of opcodes and operands. Each account ``` PUSHDATA1 03ac765294075da6f7927c96bfe3d3f64ae3680c5eb50f82f55170a9f1bea59dad -SYSCALL Neo.Crypto.ECDsaVerify +SYSCALL Neo.Crypto.VerifyWithECDsaSecp256r1 ``` #### Script Hash @@ -51,15 +51,15 @@ The NEP-5 proposal outlines a token standard for the Neo blockchain that will pr #### SysCall -The system call is a special operation code, through which you can call the interoperable service layer interface. By calling the interoperable service layer interface, NeoVM can access data such as block, transaction , contract, and asset information that are required for running smart contracts. For more information refer to the files in [Neo smart contract module](https://github.com/neo-project/neo/tree/master/src/neo/SmartContract) starting with `InteropService.` , such as `InteropService.Binary.cs`, `InteropService.Blockchain.cs`. +The system call is a special operation code, through which you can call the interoperable service layer interface. By calling the interoperable service layer interface, NeoVM can access data such as block, transaction , contract, and asset information that are required for running smart contracts. For more information refer to the files in [Neo smart contract module](https://github.com/neo-project/neo/tree/master/src/neo/SmartContract) starting with `ApplicationEngine.` , such as `ApplicationEngine.Contract.cs`, `ApplicationEngine.Blockchain.cs`. #### Dynamic Call -A special system call that invokes another contract within a contract. It can be wrote as `Contract.Call(scriptHash, method, params)`. For more information refer to [Invoking Smart Contracts](sc/deploy/invoke). +A special system call that invokes another contract within a contract. It can be wrote as `Contract.Call(scriptHash, method, params)`. For more information refer to [Invoking Smart Contracts](../develop/deploy/invoke.md). #### Storage -Each smart contract deployed on the Neo blockchain has a private storage area for storing application data. When creating a smart contract or transaction to use this contract, the contract code needs to read and write its storage. Each contract can declare a storage area. For more information refer to [Storage](../develop/sample/storage.md). +Each smart contract deployed on the Neo blockchain has a private storage area for storing application data. When creating a smart contract or transaction to use this contract, the contract code needs to read and write its storage. Each contract can declare a storage area. For more information refer to [Storage](../reference/scapi/fw/dotnet/neo/storage.md). #### NEF diff --git a/docs/en-us/intro/introduction.md b/docs/en-us/intro/introduction.md index 914d5897f..4ed0a2b7a 100644 --- a/docs/en-us/intro/introduction.md +++ b/docs/en-us/intro/introduction.md @@ -6,15 +6,15 @@ A smart contract is a set of commitments which are defined in digital form, incl ## What are the characteristics of Neo smart contracts? -Neo Smart Contract 2.0 includes the following features: certainty, high performance, and expandability. +Neo Smart Contract includes the following features: certainty, high performance, and expandability. -From the performance point of view, Neo uses the lightweight NeoVM (Neo Virtual Machine) as its intelligent contract execution environment. It starts very fast and occupies a small amount of resources and is suitable for short procedures like smart contracts. Static compilation and caching of hotspot contracts can be significantly enhanced by JIT (real-time compiler) technology. The instruction set of the Neo virtual machine includes a series of cryptographic instructions to optimize the execution efficiency of cryptographic algorithms in smart contracts. In addition, data manipulation instructions provide direct support for arrays and complex data structures. All of the above will enhance the execution performance for Neo Smart Contract 2.0. +From the performance point of view, Neo uses the lightweight NeoVM (Neo Virtual Machine) as its intelligent contract execution environment. It starts very fast and occupies a small amount of resources and is suitable for short procedures like smart contracts. Static compilation and caching of hotspot contracts can be significantly enhanced by JIT (real-time compiler) technology. The instruction set of the Neo virtual machine includes a series of cryptographic instructions to optimize the execution efficiency of cryptographic algorithms in smart contracts. In addition, data manipulation instructions provide direct support for arrays and complex data structures. All of the above will enhance the execution performance for Neo Smart Contract. -Neo Smart Contract 2.0 improves its scalability through a combination of high concurrency and dynamic partitioning, along with its low coupling design. The low coupling contract procedure is executed in a virtual machine (Neo virtual machine) and communicates with the outside through the interactive service layer. Therefore, the majority of the smart contract function upgrades can be achieved through API of the interactive service layer. +Neo Smart Contract improves its scalability through a combination of high concurrency and dynamic partitioning, along with its low coupling design. The low coupling contract procedure is executed in a virtual machine (Neo virtual machine) and communicates with the outside through the interactive service layer. Therefore, the majority of the smart contract function upgrades can be achieved through API of the interactive service layer. ## Write smart contracts in any language -From the language point of view, the difference between Neo Smart Contract 2.0 and Ethereum is more intuitive: unlike the original Solidity language in Ethereum, the Neo smart contract can be created directly in almost any high-level programming language. The first supported languages ​​are C#, VB.Net, F#, Java, and Kotlin. Neo provides compilers and plugins for these languages, which are used to compile high-level languages ​​into instruction sets supported by Neo virtual machines. The compiler is working on MSIL (Microsoft intermediate language), so theoretically any .Net language and any language that can be translated into MSIL will be immediately supported. +From the language point of view, the difference between Neo Smart Contract and Ethereum is more intuitive: unlike the original Solidity language in Ethereum, the Neo smart contract can be created directly in almost any high-level programming language. The first supported languages ​​are C#, VB.Net, F#, Java, and Kotlin. Neo provides compilers and plugins for these languages, which are used to compile high-level languages ​​into instruction sets supported by Neo virtual machines. The compiler is working on MSIL (Microsoft intermediate language), so theoretically any .Net language and any language that can be translated into MSIL will be immediately supported. The languages that are currently supported are: @@ -34,7 +34,7 @@ Additionally, traditional smart contracts are difficult to debug and test given ## Smart contract triggers -Neo Smart Contract 2.0 include four types of triggers: System Trigger, Verification Trigger, Application Trigger, and All Trigger (containing the first three types). The commonly used types are Verification Trigger and Application Trigger. +Neo Smart Contracts include six types of triggers: OnPersist, PostPersist, Verification, Application, System (containing OnPersist and PostPersist), and All (containing the first five types). The commonly used types are Verification Trigger and Application Trigger. The above two trigger types determine the two ways to trigger smart contracts: @@ -47,13 +47,13 @@ A smart contract can support multiple trigger types. Since the contract triggere NeoVM is the virtual machine that executes the Neo smart contract code. The concept of virtual machine here is in a more narrow scope. It's not a simulation of a physical machine under the assistance of the operating system, like VMware or Hyper-V. It's a virtual machine for a specific kind of machine code. -For example, in JVM or .NET CLR, source code will be compiled into the relevant bytecode and then run on the corresponding virtual machine. The JVM or CLR will run the bytecode, which is similar to running instructions on a real physical machine. Notably, the corresponding binary instructions are still run on a physical machine. The physical machine fetches instructions from memory, transfers it to the CPU via the bus, then decodes, executes, and stores the result. For more infomation, refer to [NeoVM Instructions](../../reference/neo_vm.md). +For example, in JVM or .NET CLR, source code will be compiled into the relevant bytecode and then run on the corresponding virtual machine. The JVM or CLR will run the bytecode, which is similar to running instructions on a real physical machine. Notably, the corresponding binary instructions are still run on a physical machine. The physical machine fetches instructions from memory, transfers it to the CPU via the bus, then decodes, executes, and stores the result. For more infomation, refer to [NeoVM Instructions](../reference/neo_vm.md). ## Charging Model A smart contract can be programmed to charge a certain amount of fee, including deployment costs and execution costs. -Deployment costs refers to the fee which a developer needs to pay to deploy a smart contract on the block chain (100~1000 GAS). Execution costs refers to the fee the user pays for execution of the smart contract. All operations have a costs, with most operations defaulting to 0.001 GAS. The first 10 GAS is free. Priority processing can be achieved by manually increasing the execution fee. For more information, refer to [Smart Contract Fees](../fees.md). +Deployment costs refers to the fee which a developer needs to pay to deploy a smart contract on the block chain (100~1000 GAS). Execution costs refers to the fee the user pays for execution of the smart contract. All operations have a costs, with most operations defaulting to 0.001 GAS. The first 10 GAS is free. Priority processing can be achieved by manually increasing the execution fee. For more information, refer to [Smart Contract Fees](../reference/fees.md). ## Some simple smart contracts (C#) diff --git a/docs/en-us/toc.yml b/docs/en-us/toc.yml index 38701c990..a03237972 100644 --- a/docs/en-us/toc.yml +++ b/docs/en-us/toc.yml @@ -175,6 +175,8 @@ href: /v3/docs/en-us/reference/rpc/latest-version/api/getstorage.md - name: gettransactionheight href: /v3/docs/en-us/reference/rpc/latest-version/api/gettransactionheight.md + - name: getunclaimedgas + href: /v3/docs/en-us/reference/rpc/latest-version/api/getunclaimedgas.md - name: getwalletunclaimedgas href: /v3/docs/en-us/reference/rpc/latest-version/api/getwalletunclaimedgas.md - name: getcommittee diff --git a/docs/zh-cn/develop/tool/sdk/contract.md b/docs/zh-cn/develop/tool/sdk/contract.md index 4901b8170..9b4fbcfb0 100644 --- a/docs/zh-cn/develop/tool/sdk/contract.md +++ b/docs/zh-cn/develop/tool/sdk/contract.md @@ -10,7 +10,7 @@ `ContractClient` 中提供了合约部署交易的构建方法 `CreateDeployContractTxAsync`, 参数为合约脚本,manifest 和支付系统费和网络费的账户密钥对,其中合约脚本和 manifest 可通过编译获取,账户中需要有足够的 GAS 支付所需费用。 -1. 读取合约 nef 和 manifest.json 文件: +读取合约 nef 和 manifest.json 文件: ```C# // read nefFile & manifestFile @@ -193,7 +193,7 @@ Nep5API nep5API = new Nep5API(client); Transaction tx = await nep5API.CreateTransferTxAsync(scriptHash, sendKey, receiver, 1).ConfigureAwait(false); ``` -此外 `Nep5API` 还提供了以下6种读取方法: +此外 `Nep5API` 还提供了以下读取方法: ```c# // get nep5 name diff --git a/docs/zh-cn/develop/tool/sdk/rpc.md b/docs/zh-cn/develop/tool/sdk/rpc.md index e37d6d27f..76b71dd7c 100644 --- a/docs/zh-cn/develop/tool/sdk/rpc.md +++ b/docs/zh-cn/develop/tool/sdk/rpc.md @@ -286,6 +286,7 @@ bool isValid = result.IsValid; ## 节点本地钱包 节点本地钱包接口包含可以访问节点本地钱包文件的功能,使用该部分的方法之前需要先通过 `openwallet` 方法打开钱包。 + 节点的配置文件默认禁用此方法,因为有很高的安全风险。 ### 打开钱包 diff --git a/docs/zh-cn/develop/write/nep5.md b/docs/zh-cn/develop/write/nep5.md index 00f9bbc28..c11065847 100644 --- a/docs/zh-cn/develop/write/nep5.md +++ b/docs/zh-cn/develop/write/nep5.md @@ -1,6 +1,6 @@ # NEP-17 -NEP17 协议是 Neo 补充协议中的第17号协议,替代了原先的NEP5协议。其目的是为 Neo 建立标准的 token 化智能合约通用交互机制。NEP17资产是在合约存储区内记账,通过对存储区内不同账户 hash 所记录余额数值的变化,完成交易。 +NEP17 协议是 Neo 补充协议中的第17号协议,替代了原先的NEP5协议。其目的是为 Neo 建立标准的 token 化智能合约通用交互机制。NEP17资产是在合约存储区内记账,通过对存储区内不同账户 hash 记录余额数值的变化,完成交易。 参照 NEP17 协议的要求,在编写 NEP17 资产智能合约时必须实现以下方法: diff --git a/docs/zh-cn/toc.yml b/docs/zh-cn/toc.yml index 213db1ff8..92d3518c3 100644 --- a/docs/zh-cn/toc.yml +++ b/docs/zh-cn/toc.yml @@ -174,6 +174,8 @@ href: /v3/docs/zh-cn/reference/rpc/latest-version/api/getstorage.md - name: gettransactionheight href: /v3/docs/zh-cn/reference/rpc/latest-version/api/gettransactionheight.md + - name: getunclaimedgas + href: /v3/docs/zh-cn/reference/rpc/latest-version/api/getunclaimedgas.md - name: getwalletunclaimedgas href: /v3/docs/zh-cn/reference/rpc/latest-version/api/getwalletunclaimedgas.md - name: getcommittee From 735495f96748abb509d51335a946152638e56c8b Mon Sep 17 00:00:00 2001 From: Celia18305 Date: Tue, 1 Dec 2020 17:53:06 +0800 Subject: [PATCH 12/15] follow up --- docs/en-us/develop/tool/sdk/transaction.md | 243 ++++++++++++--------- docs/en-us/develop/tool/sdk/wallet.md | 47 ++-- 2 files changed, 160 insertions(+), 130 deletions(-) diff --git a/docs/en-us/develop/tool/sdk/transaction.md b/docs/en-us/develop/tool/sdk/transaction.md index 844f61696..df860675a 100644 --- a/docs/en-us/develop/tool/sdk/transaction.md +++ b/docs/en-us/develop/tool/sdk/transaction.md @@ -2,6 +2,10 @@ Neo RPC SDK encapsulates the transaction construction module, which allows you to construct transactions in Neo3 with specific parameters and methods to personalize your functions. This document introduces the relevant methods. +> [!Note] +> +> If you use SDK to construct transactions with signature-related methods, you need to maintain a protocol.json file of the current Neo-CLI in the program running directory, such as \bin or \publish directory to ensure that the SDK uses consistent `Magic` with the blockchain, otherwise the transaction constructed by the SDK will not be able to pass verification in the blockchain. + ## Transaction construction process 1. Construct a transaction script to determine what functions the transaction will perform, such as a transfer transaction: @@ -12,24 +16,17 @@ Neo RPC SDK encapsulates the transaction construction module, which allows you t byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); ``` -2. Initialize `TransactionManager` with `RpcClient ` and `ScriptHash ` of the sending account. +2. Construct `TransactionManagerFactory` with the parameters `RpcClient ` and `Magic `; Construct `TransactionManager` with the parameters `Script` and`Signers`: ```c# - // initialize the TransactionManager with rpc client and the sender scripthash - TransactionManager txManager = new TransactionManager(client, sender); + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); ``` -3. Invoke `MakeTransaction` and pass in transaction script, attributes, and cosigners. - - ```c# - // fill the script, attributes and cosigners - txManager.MakeTransaction(script, null, cosigners); - ``` - -4. Add signature (single or multiple signatures) and use `KeyPair` of the account as the parameter. +3. Add signature (single or multiple signatures) and use `KeyPair` of the account as the parameter. - single signature - + ```c# // add signature for the transaction with sendKey txManager.AddSignature(sendKey); @@ -42,31 +39,30 @@ Neo RPC SDK encapsulates the transaction construction module, which allows you t txManager.AddMultiSig(key2, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); ``` - multi-signature contract - - The nature of multi-signature comes from multi-signature contracts. You need to construct a multi-signature contract before you can obtain the multi-signature address and transfer assets. The following example uses 3 accounts to create a multi-signature contract which requires at least 2 account signatures for signing. + The nature of multi-signature comes from multi-signature contracts. You need to construct a multi-signature contract before you can obtain the multi-signature address and transfer assets. The following example uses 3 accounts to create a multi-signature contract which requires at least 2 account signatures for signing. + ```c# - // create a multi-signature contract + // create a multi-signature contract, which needs at least 2 of 3 KeyPairs to sign Contract multiContract = Contract.CreateMultiSigContract(2, sendKey.PublicKey, key2.PublicKey, key3.PublicKey); // get the scripthash of the multi-signature contract UInt160 multiAccount = multiContract.Script.ToScriptHash(); ``` - + 5. Verify signatures and add `Witness` to the transaction body. If there are not enough signatures or fees an exception will be thrown. ```c# // sign the transaction with the added signatures - txManager.Sign(); - Transaction tx = txManager.Tx; + Transaction tx = await txManager.SignAsync().ConfigureAwait(false); ``` ## Transaction Construction Examples ### Constructing an NEP5 transfer transaction -The following example implements a function that transfers 1 NEO from the sender account to the receiver account. You need to pay attention to the difference between the script and the signature in a transaction for constructing different transactions. +The following example implements a function that transfers 1024 NEO from the sender account to the receiver account. You need to pay attention to the difference between the script and the signature in a transaction for constructing different transactions. ```c# using Neo; @@ -77,7 +73,6 @@ using Neo.SmartContract.Native; using Neo.VM; using Neo.Wallets; using System; -using Utility = Neo.Network.RPC.Utility; namespace ConsoleApp1 { @@ -85,55 +80,91 @@ namespace ConsoleApp1 { static void Main(string[] args) { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + TestNep5Transfer().GetAwaiter().GetResult(); + Console.Read(); + } + private static async Task TestNep5Transfer() + { + // choose a neo node with rpc opened + RpcClient client = new RpcClient("http://127.0.0.1:10332"); // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); + KeyPair sendKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; - // add Cosigners, which is a collection of scripthashs that need to be signed - Cosigner[] cosigners = new[] { new Cosigner { Scopes = WitnessScope.CalledByEntry, Account = sender } }; + // add Signers, which is a collection of scripthashs that need to be signed + Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } }; // get the scripthash of the account you want to transfer to - UInt160 receiver = Utility.GetScriptHash("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"); + UInt160 receiver = Utility.GetScriptHash("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); - // construct the script, in this example, we will transfer 1 NEO to receiver + // construct the script, in this example, we will transfer 1024 NEO to receiver UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); - - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, sender) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add signature for the transaction with sendKey - .AddSignature(sendKey) - // sign transaction with the added signature - .Sign() - .Tx; + byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1024); + + // initialize the TransactionManagerFactory with rpc client and magic + // fill in the TransactionManager with the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddSignature(sendKey).SignAsync().ConfigureAwait(false); // broadcasts the transaction over the Neo network. - client.SendRawTransaction(tx); + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) + await neoAPI.WaitTransactionAsync(tx) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); } } } - - ``` `WalletAPI` encapsulates the above process, so you can simplify the NEP5 transfer as follows: ```c# -WalletAPI walletAPI = new WalletAPI(client); -Transaction tx = walletAPI.Transfer(NativeContract.NEO.Hash, sendKey, receiver, 1); +using Neo; +using Neo.Network.P2P.Payloads; +using Neo.Network.RPC; +using Neo.SmartContract; +using Neo.SmartContract.Native; +using Neo.VM; +using Neo.Wallets; +using System; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + TestNep5Transfer().GetAwaiter().GetResult(); + Console.Read(); + } + + private static async Task TestNep5Transfer() + { + // choose a neo node with rpc opened + RpcClient client = new RpcClient("http://127.0.0.1:10332"); + // get the KeyPair of your account, which will pay the system and network fee + KeyPair sendKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + + // get the scripthash of the account you want to transfer to + UInt160 receiver = Utility.GetScriptHash("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); + + // use WalletAPI to create and send the transfer transaction + WalletAPI walletAPI = new WalletAPI(client); + Transaction tx = await walletAPI.TransferAsync(NativeContract.NEO.Hash, sendKey, receiver, 1024).ConfigureAwait(false); + + // print a message after the transaction is on chain + WalletAPI neoAPI = new WalletAPI(client); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} ``` ### Constructing a transaction to transfer to multi-signature account @@ -157,59 +188,58 @@ namespace ConsoleApp1 { static void Main(string[] args) { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + TestToMultiTransfer().GetAwaiter().GetResult(); + Console.Read(); + } + private static async Task TestToMultiTransfer() + { + // choose a neo node with rpc opened + RpcClient client = new RpcClient("http://127.0.0.1:10332"); // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); + KeyPair sendKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; // get the KeyPair of your accounts - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); + KeyPair key2 = Utility.GetKeyPair("L1bQBbZWnKbPkpHM3jXWD3E5NwK7nui2eWHYXVZPy3t8jSFF1Qj3"); + KeyPair key3 = Utility.GetKeyPair("KwrJfYyc7KWfZG5h97SYfcCQyW4jRw1njmHo48kZhZmuQWeTtUHM"); - // create multi-signatures contract + // create multi-signatures contract, this contract needs at least 2 of 3 KeyPairs to sign Contract multiContract = Contract.CreateMultiSigContract(2, sendKey.PublicKey, key2.PublicKey, key3.PublicKey); // get the scripthash of the multi-signature Contract UInt160 multiAccount = multiContract.Script.ToScriptHash(); - // construct the script, in this example, we will transfer 10 GAS to multi-sign account + // construct the script, in this example, we will transfer 1024 GAS to multi-sign account // in contract parameter, the amount type is BigInteger, so we need to muliply the contract factor UInt160 scriptHash = NativeContract.GAS.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, multiAccount, 10 * NativeContract.GAS.Factor); - - // add Cosigners, this is a collection of scripthashs which need to be signed - Cosigner[] cosigners = new[] { new Cosigner { Scopes = WitnessScope.CalledByEntry, Account = sender } }; - - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, sender) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add signature for the transaction with sendKey - .AddSignature(sendKey) - // sign transaction with the added signature - .Sign() - .Tx; - - // broadcasts transaction over the NEO network. - client.SendRawTransaction(tx); + byte[] script = scriptHash.MakeScript("transfer", sender, multiAccount, 1024 * NativeContract.GAS.Factor); + + // add Signers, which is a collection of scripthashs that need to be signed + Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } }; + + // initialize the TransactionManager with rpc client and magic + // fill the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddSignature(sendKey).SignAsync().ConfigureAwait(false); + + // broadcasts the transaction over the Neo network. + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) + await neoAPI.WaitTransactionAsync(tx) .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); } } } - ``` ### Constructing a transaction to transfer from multi-signature account -The following example implements a function that transfers 1 GAS from a multi-signature account. The scripthash of the multi-signature account is obtained from the scripthash of the multi-signature contract. To transfer assets from a multi-signature account, you need to add signatures required by the multi-signature contract. +The following example implements a function that transfers 1024 GAS from a multi-signature account. The scripthash of the multi-signature account is obtained from the scripthash of the multi-signature contract. To transfer assets from a multi-signature account, you need to add signatures required by the multi-signature contract. ```c# using Neo; @@ -227,51 +257,54 @@ namespace ConsoleApp1 class Program { static void Main(string[] args) + { + TestFromMultiTransfer().GetAwaiter().GetResult(); + Console.Read(); + } + + private static async Task TestFromMultiTransfer() { // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); + RpcClient client = new RpcClient("http://127.0.0.1:10332"); // get the KeyPair of your account - KeyPair receiverKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); + KeyPair receiverKey = Utility.GetKeyPair("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + KeyPair key2 = Utility.GetKeyPair("L1bQBbZWnKbPkpHM3jXWD3E5NwK7nui2eWHYXVZPy3t8jSFF1Qj3"); + KeyPair key3 = Utility.GetKeyPair("KwrJfYyc7KWfZG5h97SYfcCQyW4jRw1njmHo48kZhZmuQWeTtUHM"); // create multi-signature contract, this contract needs at least 2 of 3 KeyPairs to sign Contract multiContract = Contract.CreateMultiSigContract(2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); - - // construct the script, in this example, we will transfer 10 GAS to receiver - UInt160 scriptHash = NativeContract.GAS.Hash; + // get the scripthash of the multi-signature Contract UInt160 multiAccount = multiContract.Script.ToScriptHash(); + UInt160 receiver = Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash; - byte[] script = scriptHash.MakeScript("transfer", multiAccount, receiver, 10 * NativeContract.GAS.Factor); - - // add Cosigners, this is a collection of scripthashs which need to be signed - Cosigner[] cosigners = new[] { new Cosigner { Scopes = WitnessScope.CalledByEntry, Account = multiAccount } }; - - // initialize the TransactionManager with rpc client and sender scripthash - Transaction tx = new TransactionManager(client, multiAccount) - // fill the script, attributes and cosigners - .MakeTransaction(script, null, cosigners) - // add multi-signature for the transaction with sendKey - .AddMultiSig(receiverKey, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey) - .AddMultiSig(key2, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey) - // sign the transaction with the added signature - .Sign() - .Tx; - - // broadcast the transaction over the NEO network. - client.SendRawTransaction(tx); + + // construct the script, in this example, we will transfer 1024 GAS to multi-sign account + // in contract parameter, the amount type is BigInteger, so we need to muliply the contract factor + UInt160 scriptHash = NativeContract.GAS.Hash; + byte[] script = scriptHash.MakeScript("transfer", multiAccount, receiver, 1024 * NativeContract.GAS.Factor); + + // add Signers, which is a collection of scripthashs that need to be signed + Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = multiAccount } }; + + // initialize the TransactionManager with rpc client and magic + // fill the script and cosigners + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + // add signature and sign transaction with the added signature + Transaction tx = await txManager.AddMultiSig(new KeyPair[]{receiverKey, key2}, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey) + .SignAsync().ConfigureAwait(false); + + // broadcasts the transaction over the Neo network. + await client.SendRawTransactionAsync(tx).ConfigureAwait(false); Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); // print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) - .ContinueWith(async (p) => Console.WriteLine($"Transaction is on block {(await p).BlockHash}")); - - Console.ReadKey(); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); } } } - ``` diff --git a/docs/en-us/develop/tool/sdk/wallet.md b/docs/en-us/develop/tool/sdk/wallet.md index 8b11de192..1490ba54f 100644 --- a/docs/en-us/develop/tool/sdk/wallet.md +++ b/docs/en-us/develop/tool/sdk/wallet.md @@ -126,7 +126,7 @@ Initializing `WalletAPI`: ```c# // choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); +RpcClient client = new RpcClient("http://127.0.0.1:10332"); WalletAPI walletAPI = new WalletAPI(client); ``` @@ -142,27 +142,27 @@ Inquiry NEP-5 asset balance using the string parameter: // get the neo balance of account string tokenHash = NativeContract.NEO.Hash.ToString(); string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; -BigInteger balance = walletAPI.GetTokenBalance(tokenHash, address); +BigInteger balance = await walletAPI.GetTokenBalanceAsync(tokenHash, address).ConfigureAwait(false); ``` or using the parameter of ScriptHash type: ```c# -// get the neo balance of account +// Get the NEO balance of account UInt160 tokenScriptHash = Utility.GetScriptHash(tokenHash); UInt160 accountHash = Utility.GetScriptHash(address); Nep5API nep5API = new Nep5API(client); -BigInteger balance = nep5API.BalanceOf(tokenScriptHash, accountHash); +BigInteger balance = await nep5API.BalanceOfAsync(tokenScriptHash, accountHash).ConfigureAwait(false); ``` In Neo 3 NEO and GAS are both NEP5 assets with the fixed scripthash. Here we provide a simpler interface: ```c# -// get the neo balance -uint neoBalance = walletAPI.GetNeoBalance(address); +// Get the NEO balance +uint neoBalance = await walletAPI.GetNeoBalanceAsync(address).ConfigureAwait(false); -// get the neo balance -decimal gasBalance = walletAPI.GetGasBalance(address); +// Get the GAS balance +decimal gasBalance = await walletAPI.GetGasBalanceAsync(address).ConfigureAwait(false); ``` ## Claiming GAS @@ -172,30 +172,30 @@ In Neo3 GAS is automatically claimed when NEO is transferred. You can construct 1. First check the claimable GAS amount at current address: ```c# - // get the claimable GAS of one address + // Get the claimable GAS of one address string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; - decimal gasAmount = walletAPI.GetUnclaimedGas(address); + decimal gasAmount = await walletAPI.GetUnclaimedGasAsync(address).ConfigureAwait(false); ``` or use ScriptHash of the account to check: ```c# string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; UInt160 accountHash = Utility.GetScriptHash(address); - decimal gasAmount = walletAPI.GetUnclaimedGas(accountHash); + decimal gasAmount = await walletAPI.GetUnclaimedGasAsync(accountHash).ConfigureAwait(false); ``` 2. Construct a transaction sending NEO to yourself: ```c# - // claiming gas needs the KeyPair of account. You can also use wif or private key hex string + // Claiming GAS needs the KeyPair of account. You can also use wif or private key hex string string wif = "L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"; - Transaction transaction = walletAPI.ClaimGas(wif); + Transaction transaction = await walletAPI.ClaimGasAsync(wif).ConfigureAwait(false); ``` or use `KeyPair`: ```c# KeyPair keyPair = Utility.GetKeyPair(wif); - Transaction transaction = walletAPI.ClaimGas(keyPair); + Transaction transaction = await walletAPI.ClaimGasAsync(keyPair).ConfigureAwait(false); ``` ## Asset Transfer @@ -209,13 +209,13 @@ string tokenHash = NativeContract.NEO.Hash.ToString(); string wif = "L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"; string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; -// transfer 10 NEO from wif to address -walletAPI.Transfer(tokenHash, wif, address, 10); +// Transfer 10 NEO from wif to address +await walletAPI.TransferAsync(tokenHash, wif, address, 10).ConfigureAwait(false); -// print a message after the transaction is on chain +// Print a message after the transaction is on chain WalletAPI neoAPI = new WalletAPI(client); -neoAPI.WaitTransaction(transaction) - .ContinueWith(async (p) => Console.WriteLine($"Transaction is on block {(await p).BlockHash}")); +await neoAPI.WaitTransactionAsync(transaction) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); ``` or use `KeyPair` and `UInt160` (ScriptHash): @@ -226,8 +226,8 @@ string address = "NZs2zXSPuuv9ZF6TDGSWT1RBmE8rfGj7UW"; KeyPair sender = Utility.GetKeyPair(wif); UInt160 receiver = Utility.GetScriptHash(address); -// transfer 10 NEO from wif to address -walletAPI.Transfer(NativeContract.NEO.Hash, sender, receiver, 10); +// Transfer 10 NEO from wif to address +await walletAPI.TransferAsync(NativeContract.NEO.Hash, sender, receiver, 10).ConfigureAwait(false); ``` NEP5 transfer from multi-signature account: @@ -240,10 +240,7 @@ KeyPair keyPair3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5 KeyPair keyPair4 = Utility.GetKeyPair("L3Ke1RSBycXmRukv27L6o7sQWzDwDbFcbfR9oBBwXbCKHdBvb4ZM"); //make transaction -Transaction tx = walletAPI.CreateTransferTx(gas, 3, new ECPoint[] { keyPair1.PublicKey, keyPair2.PublicKey, keyPair3.PublicKey, keyPair4.PublicKey }, new KeyPair[] { keyPair1, keyPair2, keyPair3 }, Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash, new BigInteger(10)); - -//broadcast -RpcClient.SendRawTransaction(tx); +Transaction tx = await walletAPI.TransferAsync(NativeContract.GAS.Hash, 3, new ECPoint[] { keyPair1.PublicKey, keyPair2.PublicKey, keyPair3.PublicKey, keyPair4.PublicKey }, new KeyPair[] { keyPair1, keyPair2, keyPair3 }, Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash, new BigInteger(10 * NativeContract.GAS.Factor)).ConfigureAwait(false); ``` From 8f06e544f65ea21c7d7bf2b037f8bbe4c25acd9b Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Wed, 9 Dec 2020 18:31:38 +0800 Subject: [PATCH 13/15] update scapi --- .../scapi/fw/dotnet/neo/Designation.md | 25 +++++++++ .../neo/Designation/GetDesignatedByRole.md | 55 +++++++++++++++++++ .../reference/scapi/fw/dotnet/neo/Gas.md | 6 +- .../scapi/fw/dotnet/neo/Gas/BalanceOf.md | 18 +++++- .../scapi/fw/dotnet/neo/Gas/Transfer.md | 24 ++++++-- .../reference/scapi/fw/dotnet/neo/Neo.md | 14 ++--- .../scapi/fw/dotnet/neo/Neo/BalanceOf.md | 19 ++++++- .../scapi/fw/dotnet/neo/Neo/GetCandidates.md | 28 +++++++++- .../scapi/fw/dotnet/neo/Neo/GetCommittee.md | 22 +++++++- .../scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md | 15 +++++ .../dotnet/neo/Neo/GetNextBlockValidators.md | 21 ++++++- .../fw/dotnet/neo/Neo/RegisterCandidate.md | 26 +++++++-- .../scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md | 19 +++++++ .../scapi/fw/dotnet/neo/Neo/TotalSupply.md | 15 +++++ .../scapi/fw/dotnet/neo/Neo/Transfer.md | 23 +++++++- .../fw/dotnet/neo/Neo/UnRegisterCandidate.md | 26 +++++++-- .../scapi/fw/dotnet/neo/Neo/UnclaimedGas.md | 18 +++++- .../reference/scapi/fw/dotnet/neo/Neo/Vote.md | 30 ++++++++-- .../reference/scapi/fw/dotnet/neo/Oracle.md | 2 +- .../reference/scapi/fw/dotnet/neo/Policy.md | 8 +-- .../fw/dotnet/neo/Policy/BlockAccount.md | 22 +++++++- .../fw/dotnet/neo/Policy/GetFeePerByte.md | 17 +++++- .../fw/dotnet/neo/Policy/GetMaxBlockSize.md | 15 +++++ .../dotnet/neo/Policy/GetMaxBlockSystemFee.md | 14 +++++ .../neo/Policy/GetMaxTransactionsPerBlock.md | 16 +++++- .../scapi/fw/dotnet/neo/Policy/IsBlocked.md | 21 ++++++- .../fw/dotnet/neo/Policy/SetFeePerByte.md | 18 ++++++ .../fw/dotnet/neo/Policy/SetMaxBlockSize.md | 19 +++++++ .../dotnet/neo/Policy/SetMaxBlockSystemFee.md | 19 +++++++ .../neo/Policy/SetMaxTransactionsPerBlock.md | 18 ++++++ .../fw/dotnet/neo/Policy/UnblockAccount.md | 23 +++++++- 31 files changed, 558 insertions(+), 58 deletions(-) create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation.md create mode 100644 docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation.md new file mode 100644 index 000000000..2324cd6ab --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation.md @@ -0,0 +1,25 @@ +# Designation 类 + +提供了原生合约Designation的一系列方法,合约哈希为`0x7062149f9377e3a110a343f811b9e406f8ef7824`。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public class Oracle +``` + +## 属性 + +| 名称 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Name | 合约名称 | + +## 方法 + +| 名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [GetDesignatedByRole(DesignationRole role, uint index)](Designation/GetDesignatedByRole.md) | 发起Oracle请求 | \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md new file mode 100644 index 000000000..8ee232e37 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md @@ -0,0 +1,55 @@ +# GetDesignatedByRole 方法 (DesignationRole, uint ) + +发起Oracle请求。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern ECPoint[] GetDesignatedByRole(DesignationRole role, uint index); +``` + +参数: + +- role: 系统角色; +- index: 区块高度; + +其中,DesignationRole为枚举类型,有以下两种类型: +1. StateValidator:代表验证人节点 +2. Oracle:代表Oracle节点 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static void Main() + { + ECPoint[] oracles = Designation.GetDesignatedByRole(DesignationRole.Oracle, 1000); + return oracles; + } +} +``` + +响应正文: + +```json +[{ + "type": "Array", + "value": [{ + "type": "ByteString", + "value": "Auj/F8Vn1i8nT\u002BJHzIhKKmzTuP0Nd5qMWFYomlYKzKy0" + }] +}] +``` + +响应说明: + +- Array类型:Oracle节点列表。 + +- 其他:失败。 + +[返回上级](../Designation.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md index c21c668aa..c94bfdbcc 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md @@ -1,6 +1,6 @@ # GAS 类 -提供了原生合约GasToken的一系列属性与方法。 +提供了原生合约GasToken的一系列属性与方法,合约哈希为`0x36a019d836d964c438c573f78badf79b9e7eebdd`。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) @@ -25,5 +25,5 @@ public class GAS | 名称 | 说明 | | ------------------------------------------------------------ | ------------------------------------------------------------ | | [TotalSupply()](Gas/TotalSupply.md) | 获取GAS总发行量 | -| [BalanceOf(byte\[\] account)](Gas/BalanceOf.md) | 获取余额 | -| [Transfer(byte\[\] from, byte\[\] to, BigInteger amount)](Gas/Transfer.md) | 转账 | \ No newline at end of file +| [BalanceOf(UInt160 account)](Gas/BalanceOf.md) | 获取余额 | +| [Transfer(UInt160 from, UInt160 to, BigInteger amount)](Gas/Transfer.md) | 转账 | \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md index 9df0d95e8..212e2e17c 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern BigInteger BalanceOf(byte[] account); +public static extern BigInteger BalanceOf(UInt160 account); ``` 参数: @@ -21,7 +21,7 @@ public static extern BigInteger BalanceOf(byte[] account); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { @@ -30,5 +30,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +响应说明: + +- Integer类型:成功获取该账户的余额。 + +- 其他:失败。 [返回上级](../Gas.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md index 041708acb..e23fb73ff 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md @@ -9,7 +9,7 @@ GAS转账。 ## 语法 ```c# -public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); ``` 参数: @@ -23,16 +23,30 @@ public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); - private static readonly byte[] to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); public static object Main() { - BigInterger value = 1000; - bool result = GAS.Transfer(from, to, value); + bool result = GAS.Transfer(from, to, 1000); return result; } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示成功转账。 + +- 其他:失败。 + [返回上级](../Gas.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md index 9d62ac763..802113e34 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md @@ -1,6 +1,6 @@ # Neo 类 -提供了原生合约NeoToken的一系列属性与方法。 +提供了原生合约NeoToken的一系列属性与方法,合约哈希为`0xe22f9134cef8b03e53f71b3f960a20a65cddc972`。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) @@ -25,14 +25,14 @@ public class NEO | 名称 | 说明 | | ------------------------------------------------------------ | ------------------------------------------------------------ | | [TotalSupply()](Neo/TotalSupply.md) | 获取NEO总发行量 | -| [BalanceOf(byte\[\] account)](Neo/BalanceOf.md) | 获取余额 | -| [Transfer(byte\[\] from, byte\[\] to, BigInteger amount)](Neo/Transfer.md) | 转账 | +| [BalanceOf(UInt160 account)](Neo/BalanceOf.md) | 获取余额 | +| [Transfer(UInt160 from, UInt160 to, BigInteger amount)](Neo/Transfer.md) | 转账 | | [SetGasPerBlock(BigInteger gasPerBlock)](Neo/SetGasPerBlock.md) | 设置每出一个区块所产生的GAS数 | | [GetGasPerBlock()](Neo/GetGasPerBlock.md) | 获取当前每个区块可产生的GAS数 | -| [UnclaimedGas(byte\[\] account, uint end)](Neo/UnclaimedGas.md) | 获取未领取的Gas数 | -| [RegisterCandidate(byte\[\] pubkey)](Neo/RegisterCandidate.md) | 注册为候选人 | -| [UnRegisterCandidate(byte\[\] pubkey)](Neo/UnRegisterCandidate.md) | 取消注册为候选人 | -| [Vote(byte\[\] account, byte\[\] voteTo)](Neo/Vote.md) | 投票 | +| [UnclaimedGas(UInt160 account, uint end)](Neo/UnclaimedGas.md) | 获取未领取的Gas数 | +| [RegisterCandidate(ECPoint pubkey)](Neo/RegisterCandidate.md) | 注册为候选人 | +| [UnRegisterCandidate(ECPoint pubkey)](Neo/UnRegisterCandidate.md) | 取消注册为候选人 | +| [Vote(UInt160 account, ECPoint voteTo)](Neo/Vote.md) | 投票 | | [GetCandidates()](Neo/GetCandidates.md) | 获取候选人列表 | | [GetCommittee()](Neo/GetCommittee.md) | 获取委员会成员列表 | | [GetNextBlockValidators()](Neo/GetNextBlockValidators.md) | 获取下个区块的验证人列表 | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md index 5ae27daa6..305eb7788 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern BigInteger BalanceOf(byte[] account); +public static extern BigInteger BalanceOf(UInt160 account); ``` 参数: @@ -21,7 +21,7 @@ public static extern BigInteger BalanceOf(byte[] account); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { @@ -31,4 +31,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +响应说明: + +- Integer类型:成功获取该账户的余额。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md index 574a15705..c26ef67e4 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern (string, BigInteger)[] GetCandidates(); +public static extern (ECPoint, BigInteger)[] GetCandidates(); ``` ## 示例 @@ -19,10 +19,34 @@ public class Contract1 : SmartContract.Framework.SmartContract { public static object Main() { - (string, BigInteger)[] result = NEO.GetCandidates(); + (ECPoint, BigInteger)[] result = NEO.GetCandidates(); return result; } } ``` +响应正文: + +```json +[{ + "type": "Array", + "value": [{ + "type": "Struct", + "value": [{ + "type": "ByteString", + "value": "Apls6R4n/uoL7MTn/cB3Llj8G\u002BuLJ7LUyL/JWBQg4I0y" + }, { + "type": "Integer", + "value": "10000" + }] + }] +}] +``` + +响应说明: + +- Array类型:成功获取候选人列表。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md index e8ad43f97..f94e5cc72 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern string[] GetCommittee(); +public static extern ECPoint[] GetCommittee(); ``` ## 示例 @@ -19,10 +19,28 @@ public class Contract1 : SmartContract.Framework.SmartContract { public static object Main() { - string[] result = NEO.GetCommittee(); + ECPoint[] result = NEO.GetCommittee(); return result; } } ``` +响应正文: + +```json +[{ + "type": "Array", + "value": [{ + "type": "ByteString", + "value": "Auj/F8Vn1i8nT\u002BJHzIhKKmzTuP0Nd5qMWFYomlYKzKy0" + }] +}] +``` + +响应说明: + +- Array类型:成功获取委员会成员。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md index b24dbf780..e586b3b70 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +响应说明: + +- Integer类型:每区块可产生的GAS数。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md index c28ead9ed..6bce94a07 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern string[] GetNextBlockValidators(); +public static extern ECPoint[] GetNextBlockValidators(); ``` ## 示例 @@ -19,10 +19,27 @@ public class Contract1 : SmartContract.Framework.SmartContract { public static object Main() { - string[] result = NEO.GetNextBlockValidators(); + ECPoint[] result = NEO.GetNextBlockValidators(); return result; } } ``` +响应正文: + +```json +[{ + "type": "Array", + "value": [{ + "type": "ByteString", + "value": "Auj/F8Vn1i8nT\u002BJHzIhKKmzTuP0Nd5qMWFYomlYKzKy0" + }] +}] +``` + +响应说明: + +- Array类型:成功获取下轮共识节点成员。 + +- 其他:失败。 [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md index 092146815..4b6dfa221 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md @@ -6,10 +6,14 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 注册候选人需要验证候选人地址的签名,即只有候选人自己才能执行注册/注销操作。 + ## 语法 ```c# -public static extern bool RegisterCandidate(byte[] pubkey); +public static extern bool RegisterCandidate(ECPoint pubkey); ``` 参数: @@ -21,15 +25,29 @@ public static extern bool RegisterCandidate(byte[] pubkey); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] pubkey = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, - 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); public static object Main() { - bool result = NEO.RegisterCandidate(pubkey); + bool result = NEO.RegisterCandidate((ECPoint)pubkey); return result; } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示注册候选人成功。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md index 6d68b13f9..af4478007 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md @@ -6,6 +6,10 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# @@ -30,4 +34,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示成功转账。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md index 4e4c976d8..cf81605be 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +响应说明: + +- Integer类型:成功获取Token当前流通量。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md index 3cddd1ca8..d0271ddbe 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -6,10 +6,14 @@ NEO转账。 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要校验付款人的签名,方法调用者是否为付款人,收款人是否能够收款,以及付款人余额是否充足。 + ## 语法 ```c# -public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); ``` 参数: @@ -23,8 +27,8 @@ public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); - private static readonly byte[] to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); public static object Main() { @@ -34,5 +38,18 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示成功转账。 +- 其他:失败。 [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md index c709137b4..1a96b2112 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md @@ -6,10 +6,14 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 注销候选人需要验证候选人地址的签名,即只有候选人自己才能执行注册/注销操作。 + ## 语法 ```c# -public static extern bool UnRegisterCandidate(byte[] pubkey); +public static extern bool UnRegisterCandidate(ECPoint pubkey); ``` 参数: @@ -21,15 +25,29 @@ public static extern bool UnRegisterCandidate(byte[] pubkey); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] pubkey = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, - 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); public static object Main() { - bool result = NEO.UnRegisterCandidate(pubkey); + bool result = NEO.UnRegisterCandidate((ECPoint)pubkey); return result; } } ``` +响应正文: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示注销候选人成功。 + +- 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md index 6833f9bd6..239ae94f9 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern BigInteger UnclaimedGas(byte[] account, uint end); +public static extern BigInteger UnclaimedGas(UInt160 account, uint end); ``` 参数: @@ -22,7 +22,7 @@ public static extern BigInteger UnclaimedGas(byte[] account, uint end); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { @@ -31,5 +31,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "Type":"Integer", + "value":"100000" +} +``` + +响应说明: + +- Integer类型:成功获取该账户未领取GAS。 + +- 其他:失败。 [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md index ff15ba21b..547f6c65e 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md @@ -6,10 +6,15 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> - 投给非候选人的地址的票数会被统计但不会被计入票数,只有当该地址注册为候选人投票才会生效。 +> - 投票需要验证投票者的签名。 + ## 语法 ```c# -public static extern bool Vote(byte[] account, byte[] voteTo); +public static extern bool Vote(UInt160 account, ECPoint voteTo); ``` 参数: @@ -22,16 +27,29 @@ public static extern bool Vote(byte[] account, byte[] voteTo); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); - private static readonly byte[] voteTo = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, - 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; - + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + public static object Main() { - bool result = NEO.Vote(account, voteTo); + bool result = NEO.Vote(account, (ECPoint)pubkey); return result; } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示给候选人投票成功。 + +- 其他:失败。 [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md index ee734b033..39dae1b6f 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md @@ -1,6 +1,6 @@ # Oracle 类 -提供了原生合约Oracle的一系列方法。 +提供了原生合约Oracle的一系列方法,合约哈希为`0x35e4fc2e69a4d04d1db4d755c4150c50aff2e9a9`。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md index 72887e047..b129a43e7 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md @@ -1,6 +1,6 @@ # Policy 类 -提供了原生合约Policy的一系列方法。 +提供了原生合约Policy的一系列方法,合约哈希为`0x1ca594b36b6b6b3f05efce8b106c824053d18713`。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../neo.md) @@ -21,10 +21,10 @@ public class Policy | [GetMaxBlockSize()](Policy/GetMaxBlockSize.md) | 获取区块最大大小 | | [GetMaxBlockSystemFee()](Policy/GetMaxBlockSystemFee.md) | 获取区块最大的系统费 | | [GetFeePerByte()](Policy/GetFeePerByte.md) | 获取每字节手续费 | -| [IsBlocked(byte\[\] account)](Policy/IsBlocked.md) | 验证是否为黑名单账户 | +| [IsBlocked(UInt160 account)](Policy/IsBlocked.md) | 验证是否为黑名单账户 | | [SetMaxBlockSize(uint value)](Policy/SetMaxBlockSize.md) | 设置最大区块大小 | | [SetMaxTransactionsPerBlock(uint value)](Policy/SetMaxTransactionsPerBlock.md) | 设置每区块最大交易数 | | [SetMaxBlockSystemFee(long value)](Policy/SetMaxBlockSystemFee.md) | 设置区块最大系统手续费 | | [SetFeePerByte(long value)](Policy/SetFeePerByte.md) | 设置每字节手续费 | -| [BlockAccount(byte\[\] account)](Policy/BlockAccount.md) | 将指定账户加入黑名单 | -| [UnblockAccount(byte\[\] account)](Policy/UnblockAccount.md) | 将指定账户解除黑名单 | +| [BlockAccount(UInt160 account)](Policy/BlockAccount.md) | 将指定账户加入黑名单 | +| [UnblockAccount(UInt160 account)](Policy/UnblockAccount.md) | 将指定账户解除黑名单 | diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md index aa6db0ac6..3529fc416 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md @@ -6,10 +6,14 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# -public static extern bool BlockAccount(byte[] account); +public static extern bool BlockAccount(UInt160 account); ``` 参数: @@ -21,7 +25,7 @@ public static extern bool BlockAccount(byte[] account); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); public static object Main() { @@ -30,5 +34,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示新增屏蔽地址成功。 + +- 其他:失败。 [返回上级](../Policy.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md index 855041fa5..ea20c7102 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md @@ -1,6 +1,6 @@ # GetFeePerByte 方法 () -获取每字节手续费。 +获取交易每字节网络费。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Integer", + "value":"300" +} +``` + +响应说明: + +- Integer类型:成功获取交易每字节网络费。 + +- 其他:失败。 + [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md index dd1e05e73..109f9c5aa 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Integer", + "value":"500" +} +``` + +响应说明: + +- Integer类型:成功获取区块最大大小。 + +- 其他:失败。 + [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md index adfb80a55..efc2e77f9 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md @@ -24,5 +24,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "type":"Integer", + "value":"900000000000" +} +``` + +响应说明: + +- Integer类型:成功获取区块最大手续费。 + +- 其他:失败。 [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md index 57b2d8218..18e0f4caf 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md @@ -1,6 +1,6 @@ # GetMaxTransactionsPerBlock 方法 () -获取每区块最大交易数。 +获取区块包含最大交易数。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) @@ -25,4 +25,18 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Integer", + "value":"500" +} +``` + +响应说明: + +- Integer类型:成功获取区块包含最大交易量。 +- 其他:失败。 + [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md index 697b0b1d8..f4d92ee8c 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md @@ -9,7 +9,7 @@ ## 语法 ```c# -public static extern string[] IsBlocked(byte[] account); +public static extern string[] IsBlocked(UInt160 account); ``` 参数: @@ -21,14 +21,29 @@ public static extern string[] IsBlocked(byte[] account); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { - string[] result = Policy.IsBlocked(account); + bool result = Policy.IsBlocked(account); return result; } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"false" +} +``` + +响应说明: + +- Boolean类型:true表示账户已被屏蔽。 + +- 其他:失败。 + [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md index dff670f66..fab4b62df 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md @@ -6,6 +6,10 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# @@ -28,5 +32,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示设置交易每字节网络费成功。 + +- 其他:失败。 [返回上级](../Policy.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md index 4c9777676..06f2c3d2b 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md @@ -6,6 +6,10 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# @@ -29,4 +33,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示设置区块最大大小成功。 + +- 其他:失败。 + [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md index 50e65db4f..622d5bb68 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md @@ -6,6 +6,10 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# @@ -29,6 +33,21 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示设置区块最大系统手续费成功。 + +- 其他:失败。 + [返回上级](../Policy.md) >注:设置的手续费值应不小于4007600。 \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md index 7af61ea71..23cb07572 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md @@ -6,6 +6,10 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# @@ -28,5 +32,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示设置区块包含最大交易量成功。 + +- 其他:失败。 [返回上级](../Policy.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md index 25b3756fc..2273398b7 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md @@ -6,10 +6,14 @@ 程序集:Neo.SmartContract.Framework +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + ## 语法 ```c# -public static extern bool UnblockAccount(byte[] account); +public static extern bool UnblockAccount(UInt160 account); ``` 参数: @@ -21,7 +25,7 @@ public static extern bool UnblockAccount(byte[] account); ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); public static object Main() { @@ -31,4 +35,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示解除屏蔽地址成功。 + +- 其他:失败。 + [返回上级](../Policy.md) From 4ba31e45cd2e31814272acf22331e15fe553d986 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 10 Dec 2020 11:53:53 +0800 Subject: [PATCH 14/15] update method descriptors --- docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md | 2 +- docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md | 2 +- docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md | 2 +- .../reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md | 2 +- .../reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md | 2 +- .../scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md | 2 +- .../scapi/fw/dotnet/neo/Neo/RegisterCandidate.md | 2 +- docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md | 2 +- .../scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md | 2 +- .../reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md | 2 +- docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md | 4 ++-- docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md | 8 ++++++++ .../reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md | 2 +- .../reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md | 2 +- .../scapi/fw/dotnet/neo/Policy/UnblockAccount.md | 2 +- 15 files changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md index 212e2e17c..c69ecd918 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md @@ -1,4 +1,4 @@ -# BalanceOf 方法 (byte[]) +# BalanceOf 方法 (UInt160) 获取账户的GAS余额。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md index e23fb73ff..2412b763b 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md @@ -1,4 +1,4 @@ -# Transfer 方法 (byte[], byte[], BigInteger) +# Transfer 方法 (UInt160, UInt160, BigInteger) GAS转账。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md index 305eb7788..cec2632bb 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md @@ -1,4 +1,4 @@ -# BalanceOf 方法 (byte[]) +# BalanceOf 方法 (UInt160) 获取账户的NEO余额。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md index c26ef67e4..2e8ef2cec 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -1,6 +1,6 @@ # GetCandidates 方法 () -获取候选人列表。 +获取候选人列表。由于账户NEO余额会随交易而不断变化,而且投票和注册的候选人也在不断变化,因此在每个区块都会根据以上变化更新候选人及相应投票结果。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md index f94e5cc72..59ca6a008 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -1,6 +1,6 @@ # GetCommittee 方法 () -获取委员会成员列表。 +获取委员会成员列表。将候选人根据票数多少排序,取最前面的一定数量候选人(默认21个)作为委员会。委员会名单将在每个区块根据最新投票更新。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md index 6bce94a07..e78880bfc 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -1,6 +1,6 @@ # GetNextBlockValidators 方法 () -获取下个区块的验证人列表。 +获取下个区块的验证人列表。将候选人根据票数多少排序,取最前面的一定数量候选人(默认7个)作为共识节点。与委员会类似,共识节点名单将在每个区块根据最新投票更新。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md index 4b6dfa221..ef4f57522 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md @@ -1,4 +1,4 @@ -# RegisterCandidate 方法 (byte[]) +# RegisterCandidate 方法 (ECPoint) 注册成为候选人。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md index d0271ddbe..43e5858d9 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -1,4 +1,4 @@ -# Transfer 方法 (byte[], byte[], BigInteger) +# Transfer 方法 (UInt160, UInt160, BigInteger) NEO转账。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md index 1a96b2112..3345ff032 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md @@ -1,4 +1,4 @@ -# UnRegisterCandidate 方法 (byte[]) +# UnRegisterCandidate 方法 (ECPoint) 取消注册为候选人。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md index 239ae94f9..99cccccb0 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md @@ -1,4 +1,4 @@ -# UnclaimedGas 方法 (byte[], uint) +# UnclaimedGas 方法 (UInt160, uint) 获取未领取的Gas数. diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md index 547f6c65e..cc6998d40 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md @@ -1,6 +1,6 @@ -# Vote 方法 (byte[], byte[]) +# Vote 方法 (UInt160, ECPoint) -投票。 +每个地址均有投票给一个地址的权利,候选人票数为所有向该账户投票的地址的NEO余额之和。初始块所有默认候选人均会向自己投票。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md index b129a43e7..3d1f45c18 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md @@ -6,6 +6,14 @@ 程序集:Neo.SmartContract.Framework +委员会可以通过投票的方式对Neo网络的一些参数进行修改,目前包括以下内容: + +* 设置区块最大大小 +* 设置区块最大系统费 +* 设置区块包含最大交易量 +* 设置交易每字节网络费 +* 地址屏蔽/解除屏蔽 + ## 语法 ```c# diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md index 3529fc416..2bc8b4916 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md @@ -1,4 +1,4 @@ -# BlockAccount 方法 (byte[]) +# BlockAccount 方法 (UInt160) 将指定账户加入黑名单。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md index f4d92ee8c..1a4937fdb 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md @@ -1,4 +1,4 @@ -# IsBlocked 方法 (byte[]) +# IsBlocked 方法 (UInt160) 验证是否为黑名单账户。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md index 2273398b7..3dad34099 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md @@ -1,4 +1,4 @@ -# UnblockAccount 方法 (byte[]) +# UnblockAccount 方法 (UInt160) 将指定账户解除黑名单。 From 7893b6064b2562de70473cc7e607fe05d334eaa3 Mon Sep 17 00:00:00 2001 From: Celia18305 Date: Fri, 18 Dec 2020 18:01:59 +0800 Subject: [PATCH 15/15] updated --- docs/en-us/reference/governance_api.md | 38 ++++++------- .../reference/scapi/fw/dotnet/neo/Crypto.md | 2 +- .../scapi/fw/dotnet/neo/Designation.md | 25 +++++++++ .../neo/Designation/GetDesignatedByRole.md | 56 +++++++++++++++++++ .../reference/scapi/fw/dotnet/neo/Gas.md | 6 +- .../scapi/fw/dotnet/neo/Gas/BalanceOf.md | 17 +++++- .../scapi/fw/dotnet/neo/Gas/Transfer.md | 26 +++++++-- .../reference/scapi/fw/dotnet/neo/Neo.md | 14 ++--- .../scapi/fw/dotnet/neo/Neo/BalanceOf.md | 24 ++++++-- .../scapi/fw/dotnet/neo/Neo/GetCandidates.md | 28 +++++++++- .../scapi/fw/dotnet/neo/Neo/GetCommittee.md | 20 ++++++- .../scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md | 17 +++++- .../dotnet/neo/Neo/GetNextBlockValidators.md | 18 ++++++ .../fw/dotnet/neo/Neo/RegisterCandidate.md | 28 ++++++++-- .../scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md | 26 ++++++++- .../scapi/fw/dotnet/neo/Neo/TotalSupply.md | 15 +++++ .../scapi/fw/dotnet/neo/Neo/Transfer.md | 27 +++++++-- .../fw/dotnet/neo/Neo/UnRegisterCandidate.md | 28 ++++++++-- .../scapi/fw/dotnet/neo/Neo/UnclaimedGas.md | 21 ++++++- .../reference/scapi/fw/dotnet/neo/Neo/Vote.md | 33 ++++++++--- .../reference/scapi/fw/dotnet/neo/Oracle.md | 2 +- .../reference/scapi/fw/dotnet/neo/Policy.md | 8 +-- .../fw/dotnet/neo/Policy/BlockAccount.md | 25 ++++++++- .../fw/dotnet/neo/Policy/GetFeePerByte.md | 15 +++++ .../fw/dotnet/neo/Policy/GetMaxBlockSize.md | 15 +++++ .../dotnet/neo/Policy/GetMaxBlockSystemFee.md | 15 +++++ .../neo/Policy/GetMaxTransactionsPerBlock.md | 15 +++++ .../scapi/fw/dotnet/neo/Policy/IsBlocked.md | 15 +++++ .../fw/dotnet/neo/Policy/SetFeePerByte.md | 19 +++++++ .../fw/dotnet/neo/Policy/SetMaxBlockSize.md | 19 +++++++ .../dotnet/neo/Policy/SetMaxBlockSystemFee.md | 19 +++++++ .../neo/Policy/SetMaxTransactionsPerBlock.md | 19 +++++++ .../fw/dotnet/neo/Policy/UnblockAccount.md | 21 ++++++- docs/zh-cn/reference/governance_api.md | 37 ++++++------ .../scapi/fw/dotnet/neo/Neo/GetCandidates.md | 2 +- .../scapi/fw/dotnet/neo/Neo/GetCommittee.md | 2 +- .../dotnet/neo/Neo/GetNextBlockValidators.md | 2 +- .../scapi/fw/dotnet/neo/Neo/Transfer.md | 1 + .../reference/scapi/fw/dotnet/neo/Policy.md | 8 --- .../dotnet/neo/Policy/SetMaxBlockSystemFee.md | 6 +- 40 files changed, 620 insertions(+), 114 deletions(-) create mode 100644 docs/en-us/reference/scapi/fw/dotnet/neo/Designation.md create mode 100644 docs/en-us/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md diff --git a/docs/en-us/reference/governance_api.md b/docs/en-us/reference/governance_api.md index 2e4b7b0cc..01cf4e206 100644 --- a/docs/en-us/reference/governance_api.md +++ b/docs/en-us/reference/governance_api.md @@ -36,8 +36,8 @@ An address can be registered as candidate or unregistered afterwards. Correspond | Method | Parameters | Fee in GAS | | ---- | ------------------------------------ | ---- | -| [`registerCandidate`](govapi/registerCandidate.md) | byte[] publicKey | 0.05 | -| [`unregisterCandidate`](govapi/unregisterCandidate.md) | byte[] publicKey | 0.05 | +| [`RegisterCandidate`](scapi/fw/dotnet/neo/Neo/RegisterCandidate.md) | UInt160 publicKey | 0.05 | +| [`UnregisterCandidate`](scapi/fw/dotnet/neo/Neo/UnregisterCandidate.md) | UInt160 publicKey | 0.05 | > [!Note] > @@ -51,7 +51,7 @@ Voting contract method is as follows. Please not that voter's signature will be | Method | Parameters | Fee in GAS | | ---- | ------------------------------------ | ---- | -| [`vote`](govapi/vote.md) | byte[] account, byte[] voteTo | 5 | +| [`Vote`](scapi/fw/dotnet/neo/Neo/Vote.md) | UInt160 account, byte[] voteTo | 5 | As voters' votes & held NEO, as well as registered candidates keep changing, candidate set and their votes are re-calculated in every block. @@ -59,7 +59,7 @@ As voters' votes & held NEO, as well as registered candidates keep changing, can | Method | Parameters | Fee in GAS | | ---- | ------------------------------------ | ---- | -| [`getCandidates`](govapi/getCandidates.md) | null | 1 | +| [`GetCandidates`](scapi/fw/dotnet/neo/Neo/GetCandidates.md) | null | 1 | ### Committee @@ -76,11 +76,11 @@ Method definition and corresponding fee are defined in PolicyContract as shown b | Method | Parameters | Fee in GAS | | ---- | ------------------------------------ | ---- | -| [`setMaxBlockSize`](govapi/setMaxBlockSize.md) | uint blockSize | 0.03 | -| [`setMaxTransactionsPerBlock`](govapi/setMaxTransactionsPerBlock.md) | uint maxTransactions | 0.03 | -| [`setFeePerByte`](govapi/setFeePerByte.md) | long feePerByte | 0.03 | -| [`blockAccount`](govapi/blockAccount.md) | byte[] account | 0.03 | -| [`unblockAccount`](govapi/unblockAccount.md) | byte[] account | 0.03 | +| [`SetMaxBlockSize`](scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md) | uint blockSize | 0.03 | +| [`SetMaxTransactionsPerBlock`](scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md) | uint maxTransactions | 0.03 | +| [`SetFeePerByte`](scapi/fw/dotnet/neo/Policy/SetFeePerByte.md) | long feePerByte | 0.03 | +| [`BlockAccount`](scapi/fw/dotnet/neo/Policy/BlockAccount.md) | UInt160 account | 0.03 | +| [`UnblockAccount`](scapi/fw/dotnet/neo/Policy/UnblockAccount.md) | UInt160 account | 0.03 | To bring such modification into effect, committee members should send a transaction which calls corresponding method & includes enough signatures on chain. This transaction is executed as long as it's signed by more than half of the committee members. @@ -88,9 +88,9 @@ Furthermore, PolicyContract also supports corresponding reading methods: | Method | Parameters | Fee in GAS | | ---- | ------------------------------------ | ---- | -| [`getMaxBlockSize`](govapi/getMaxBlockSize.md) | null | 0.01 | -| [`getMaxTransactionsPerBlock`](govapi/getMaxTransactionsPerBlock.md) | null | 0.01 | -| [`getFeePerByte`](govapi/getFeePerByte.md) | null | 0.01 | +| [`GetMaxBlockSize`](scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md) | null | 0.01 | +| [`GetMaxTransactionsPerBlock`](scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md) | null | 0.01 | +| [`GetFeePerByte`](scapi/fw/dotnet/neo/Policy/GetFeePerByte.md) | null | 0.01 | | [`getBlockedAccounts`](govapi/getBlockedAccounts.md) | null | 0.01 | #### How Are Committee Members Elected @@ -103,7 +103,7 @@ Committee members will be refreshed every block. | Method | Parameters | Fee in GAS | Return value | | ---- | ------------------------------------ | ---- | ---- | -| [`getCommittee`](govapi/getCommittee.md) | null | 1 | Current committee members in format of Array | +| [`GetCommittee`](scapi/fw/dotnet/neo/Neo/GetCommittee.md) | null | 1 | Current committee members in format of Array | ### Validator @@ -122,7 +122,7 @@ Similar to committee members, validators will be refreshed every block. | Method | Parameters | Fee in GAS | Return value | | ---- | ------------------------------------ | ---- | ---- | | [`getValidators`](govapi/getValidators.md) | null | 1 | Current validators in format of Array | -| [`getNextBlockValidators`](govapi/getNextBlockValidators.md) | null | 1 | Validators by persisting block in format of Array | +| [`GetNextBlockValidators`](scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md) | null | 1 | Validators by persisting block in format of Array | ## Token Distribution @@ -134,7 +134,7 @@ Half of total NEO amount, or 50 million tokens are distributed in genesis block 3. Remaining half is distributed to standby validators' multi-signature address - All interactions in Neo are performed through transactions. Sending a transaction on chain requires paying GAS tokens as fee, including system fee and network fee. System fee will be burnt as resource consumption for transaction execution, while network fee will be distributed to the speaker (the validator who start a new-block proposal) of the block where corresponding transaction is included. + All interactions in Neo are performed through transactions. Sending a transaction on chain requires paying GAS tokens as fee, including system fee and network fee. System fee will be burnt as resource consumption for transaction execution, while network fee will be distributed to the speaker (the validator who start a new-block proposal) of the block where corresponding transaction is included. ## Nep5 Contract method @@ -145,9 +145,9 @@ NEO and GAS are [Nep5](https://github.com/neo-project/proposals/blob/master/nep- | [`name`](govapi/name.md) | null | 0 | Token name in String | | [`symbol`](govapi/symbol.md) | null | 0 | Token symbol in String | | [`decimals`](govapi/decimals.md) | null | 0.01 | Token decimals in UInt | -| [`totalSupply`](govapi/totalSupply.md) | null | 0.01 | Token total supply in BigInteger | -| [`balanceOf`](govapi/balanceOf.md) | byte[] account | 0.01 | account balance in BigInteger | -| [`transfer`](govapi/transfer.md) | byte[] from, byte[] to, BigInteger amount | 0.08 | Send specified amount of token from Address *from* to Address *to*. Please note that it will check *from*'s signature, whether caller is *from*, whether *to* is payable, whether *from*'s balance is enough | +| [`TotalSupply`](scapi/fw/dotnet/neo/Neo/TotalSupply.md) | null | 0.01 | Token total supply in BigInteger | +| [`BalanceOf`](scapi/fw/dotnet/neo/Neo/BalanceOf.md) | UInt160 account | 0.01 | account balance in BigInteger | +| [`Transfer`](scapi/fw/dotnet/neo/Neo/Transfer.md) | UInt160 from, UInt160 to, BigInteger amount | 0.08 | Send specified amount of token from Address *from* to Address *to*. Please note that it will check *from*'s signature, whether caller is *from*, whether *to* is payable, whether *from*'s balance is enough | | [`onPersist`](govapi/onPersist.md) | null | 0 | Manually perform actions this Nep5 contract will do upon block persisting | | [`supportedStandards`](govapi/supportedStandards.md) | null | 0 | Supported NEP standards in String[] | @@ -155,4 +155,4 @@ Contract methods by NEO: | Method | Parameters | Fee in GAS | Return value | | ---- | ------------------------------------ | ---- | ---- | -| [`unclaimedGas`](govapi/unclaimedGas.md) | byte[] account | 0.03 | unclaimed GAS amount of this address in uint | +| [`UnclaimedGas`](scapi/fw/dotnet/neo/Neo/UnclaimedGas.md) | UInt160 account | 0.03 | unclaimed GAS amount of this address in uint | diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Crypto.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Crypto.md index aa84aeebd..98bee4b32 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Crypto.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Crypto.md @@ -2,7 +2,7 @@ Static class, which provides a method to verify signatures by ECDsa -Namespace:[Neo.SmartContract.Framework.Services.Neo](../neo.md) +Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) Assembly: Neo.SmartContract.Framework diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Designation.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Designation.md new file mode 100644 index 000000000..9e5c4ec99 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Designation.md @@ -0,0 +1,25 @@ +# Designation Class + +Provides a set of methods of the native contract Designation, which hash is `0x7062149f9377e3a110a343f811b9e406f8ef7824`. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public class Oracle +``` + +## Methods + +| Name | Description | +| ---- | ------------- | +| Name | Contract name | + +## Constructor + +| Name | Description | +| ------------------------------------------------------------ | --------------------------- | +| [GetDesignatedByRole(DesignationRole role, uint index)](Designation/GetDesignatedByRole.md) | Initiates an Oracle request | \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md new file mode 100644 index 000000000..61169ba39 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Designation/GetDesignatedByRole.md @@ -0,0 +1,56 @@ +# GetDesignatedByRole Method (DesignationRole, uint ) + +Initiates an Oracle request. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern ECPoint[] GetDesignatedByRole(DesignationRole role, uint index); +``` + +Parameters: + +- role: system role +- index: block height + +`DesignationRole`, the enumeration type, which can be: + +- `StateValidator`: the validator node +- `Oracle`: the Oracle node + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static void Main() + { + ECPoint[] oracles = Designation.GetDesignatedByRole(DesignationRole.Oracle, 1000); + return oracles; + } +} +``` + +Response body: + +```json +[{ + "type": "Array", + "value": [{ + "type": "ByteString", + "value": "Auj/F8Vn1i8nT\u002BJHzIhKKmzTuP0Nd5qMWFYomlYKzKy0" + }] +}] +``` + +Response description: + +- Array type: Oracle nodes list + +- Other: failed. + + diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Gas.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas.md index 8a54afc8d..dff83abfc 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Gas.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas.md @@ -1,6 +1,6 @@ # GAS Class -Provides a series of attributes and methods of the native contract GasToken. +Provides a series of attributes and methods of the native contract GasToken, which contract hash is 0x36a019d836d964c438c573f78badf79b9e7eebdd. Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) @@ -25,5 +25,5 @@ public class GAS | Name | Description | | ------------------------------------------------------------ | ---------------------------- | | [TotalSupply()](Gas/TotalSupply.md) | Gets the total supply of GAS | -| [BalanceOf(byte\[\] account)](Gas/BalanceOf.md) | Gets the balance | -| [Transfer(byte\[\] from, byte\[\] to, BigInteger amount)](Gas/Transfer.md) | Transfers GAS | \ No newline at end of file +| [BalanceOf(UInt160 account)](Gas/BalanceOf.md) | Gets the balance | +| [Transfer(UInt160 from, UInt160 to, BigInteger amount)](Gas/Transfer.md) | Transfers GAS | \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md index 6586ea71e..9909692b9 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md @@ -21,7 +21,7 @@ Parameters: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { @@ -31,4 +31,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +Response description + +- Integer type: The account balance obtained successfully. + +- Other: failed. + [Back](../Gas.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/Transfer.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/Transfer.md index aa16300ec..84fe8b39c 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/Transfer.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/Transfer.md @@ -1,4 +1,4 @@ -# Transfer Method (byte[], byte[], BigInteger) +# Transfer Method (UInt160, UInt160, BigInteger) Transfers GAS @@ -9,7 +9,7 @@ Assembly: Neo.SmartContract.Framework ## Syntax ```c# -public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); ``` Parameters: @@ -23,16 +23,30 @@ Parameters: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); - private static readonly byte[] to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); public static object Main() { - BigInterger value = 1000; - bool result = GAS.Transfer(from, to, value); + bool result = GAS.Transfer(from, to, 1000); return result; } } ``` +Respond: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Respond description: + +- Boolean type: true means assets are transferred successfully. + +- Others: failed. + [Back](../Gas.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo.md index cb1375503..939865c60 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo.md @@ -1,6 +1,6 @@ # Neo Class -Provides a series of attributes and methods of the native contract NeoToken. +Provides a series of attributes and methods of the native contract NeoToken, which contract hash is 0xe22f9134cef8b03e53f71b3f960a20a65cddc972. Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) @@ -25,14 +25,14 @@ public class NEO | Name | Description | | ------------------------------------------------------------ | ----------------------------------------------- | | [TotalSupply()](Neo/TotalSupply.md) | Gets the total supply of NEO | -| [BalanceOf(byte\[\] account)](Neo/BalanceOf.md) | Gets the balance | -| [Transfer(byte\[\] from, byte\[\] to, BigInteger amount)](Neo/Transfer.md) | Transfers NEO | +| [BalanceOf(UInt160 account)](Neo/BalanceOf.md) | Gets the balance | +| [Transfer(UInt160 from, UInt160 to, BigInteger amount)](Neo/Transfer.md) | Transfers NEO | | [SetGasPerBlock(BigInteger gasPerBlock)](Neo/SetGasPerBlock.md) | Sets the number of GAS generated for each block | | [GetGasPerBlock()](Neo/GetGasPerBlock.md) | Gets the number of GAS generated for each block | -| [UnclaimedGas(byte\[\] account, uint end)](Neo/UnclaimedGas.md) | Gets the number of unclaimed GAS | -| [RegisterCandidate(byte\[\] pubkey)](Neo/RegisterCandidate.md) | Registers as a candidate | -| [UnRegisterCandidate(byte\[\] pubkey)](Neo/UnRegisterCandidate.md) | Unregisters as a candidate | -| [Vote(byte\[\] account, byte\[\] voteTo)](Neo/Vote.md) | Votes for candidates | +| [UnclaimedGas(UInt160 account, uint end)](Neo/UnclaimedGas.md) | Gets the number of unclaimed GAS | +| [RegisterCandidate(ECPoint pubkey)](Neo/RegisterCandidate.md) | Registers as a candidate | +| [UnRegisterCandidate(ECPoint pubkey)](Neo/UnRegisterCandidate.md) | Unregisters as a candidate | +| [Vote(UInt160 account, ECPoint voteTo)](Neo/Vote.md) | Votes for candidates | | [GetCandidates()](Neo/GetCandidates.md) | Gets candidates list | | [GetCommittee()](Neo/GetCommittee.md) | Gets committee members list | | [GetNextBlockValidators()](Neo/GetNextBlockValidators.md) | Gets validators list for the next block | diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md index 76054a676..3acb262e7 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md @@ -1,4 +1,4 @@ -# BalanceOf Method (byte[]) +# BalanceOf Method (UInt160) Gets the NEO balance in the account. @@ -9,7 +9,7 @@ Assembly: Neo.SmartContract.Framework ## Syntax ```c# -public static extern BigInteger BalanceOf(byte[] account); +public static extern BigInteger BalanceOf(UInt160 account); ``` Parameters: @@ -21,7 +21,7 @@ Parameters: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { @@ -31,4 +31,20 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` -[Back](../Neo.md) \ No newline at end of file +Response body: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +Response description: + +- Integer type: The account balance is obtained successfully. + +- Others: failed. + +[Back](../Neo.md) + diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md index f6937aec4..73226b942 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -9,7 +9,7 @@ Assembly: Neo.SmartContract.Framework ## Syntax ```c# -public static extern (string, BigInteger)[] GetCandidates(); +public static extern (ECPoint, BigInteger)[] GetCandidates(); ``` ## Example @@ -19,11 +19,35 @@ public class Contract1 : SmartContract.Framework.SmartContract { public static object Main() { - (string, BigInteger)[] result = NEO.GetCandidates(); + (ECPoint, BigInteger)[] result = NEO.GetCandidates(); return result; } } ``` +Response description: + +```json +[{ + "type": "Array", + "value": [{ + "type": "Struct", + "value": [{ + "type": "ByteString", + "value": "Apls6R4n/uoL7MTn/cB3Llj8G\u002BuLJ7LUyL/JWBQg4I0y" + }, { + "type": "Integer", + "value": "10000" + }] + }] +}] +``` + +Response description: + +- Array type: candidates are successfully requested. + +- Others: failed. + [Back](../Neo.md) diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md index fd47c558a..2021f8018 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -1,6 +1,6 @@ # GetCommittee Method () -Gets the list of committee members +Gets the list of committee members. Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) @@ -25,4 +25,22 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +[{ + "type": "Array", + "value": [{ + "type": "ByteString", + "value": "Auj/F8Vn1i8nT\u002BJHzIhKKmzTuP0Nd5qMWFYomlYKzKy0" + }] +}] +``` + +Respond description: + +- Array type: committee members are successfully requested. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md index cd529791e..348df966e 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md @@ -1,6 +1,6 @@ # GetGasPerBlock Method () -Gets the number of GAS generated for each block. +Gets the number of GAS generated in each block. Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +Response description: + +- Integer type: the number of GAS generated in each block + +- Others: failed + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md index bf131f7c1..8ad76f720 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -25,4 +25,22 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +[{ + "type": "Array", + "value": [{ + "type": "ByteString", + "value": "Auj/F8Vn1i8nT\u002BJHzIhKKmzTuP0Nd5qMWFYomlYKzKy0" + }] +}] +``` + +Response description: + +- Array type: validators by persisting block are successfully requested. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md index 99df7254c..fcc96b5fc 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md @@ -1,4 +1,4 @@ -# RegisterCandidate Method (byte[]) +# RegisterCandidate Method (ECPoint) Registers as a candidate. @@ -6,10 +6,14 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> Candidate registration requires the candidate's signature. It means candidate registering is only self-determined. + ## Syntax ```c# -public static extern bool RegisterCandidate(byte[] pubkey); +public static extern bool RegisterCandidate(ECPoint pubkey); ``` Parameter: @@ -21,15 +25,29 @@ Parameter: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] pubkey = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, - 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); public static object Main() { - bool result = NEO.RegisterCandidate(pubkey); + bool result = NEO.RegisterCandidate((ECPoint)pubkey); return result; } } ``` +Response body: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Response description: + +- Boolean type: true means candidate registration is succeeded. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md index e1c93309e..4ab0160e4 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md @@ -1,11 +1,15 @@ # SetGasPerBlock Method (BigInteger) -Sets the number of GAS generated for each block +Sets the number of GAS generated in each block Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method needs to check muti-signature of committee members, and it is executed as long as it's signed by more than half of the committee members. + ## Syntax ```c# @@ -14,7 +18,7 @@ public static extern bool SetGasPerBlock(BigInteger gasPerBlock); Parameter: -- gasPerBlock: the number of GAS generated for each block +- gasPerBlock: the number of GAS generated in each block. ## Example @@ -30,4 +34,20 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` -[Back](../Neo.md) \ No newline at end of file +Response body: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Response description: + +- Boolean type: true means transfer is succeeded. + +- Others: failed + +[Back](../Neo.md) + diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md index ecdffed98..e1a802896 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Integer", + "value":"100000000" +} +``` + +Response description: + +- Integer type: token total supply is successfully requested. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Transfer.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Transfer.md index d1566433d..8eec59a6e 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Transfer.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -1,4 +1,4 @@ -# Transfer Method (byte[], byte[], BigInteger) +# Transfer Method (UInt160, UInt160, BigInteger) Transfers NEO. @@ -6,10 +6,14 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method will check sender's signature, whether caller is sender, whether receiver is payable, and whether sender's balance is enough. + ## Syntax ```c# -public static extern bool Transfer(byte[] from, byte[] to, BigInteger amount); +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); ``` Parameters: @@ -23,8 +27,8 @@ Parameters: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); - private static readonly byte[] to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); public static object Main() { @@ -35,4 +39,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: assets are transferred successfully. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md index 8ae5f5f01..fbc5c7008 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md @@ -1,4 +1,4 @@ -# UnRegisterCandidate Method (byte[]) +# UnRegisterCandidate Method (ECPoint) Unregisters as a candidate. @@ -6,10 +6,14 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> Unregistering candidate requires the candidate's signature. It means candidate unregistering is only self-determined. + ## Syntax ```c# -public static extern bool UnRegisterCandidate(byte[] pubkey); +public static extern bool UnRegisterCandidate(ECPoint pubkey); ``` Parameter: @@ -21,15 +25,29 @@ Parameter: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] pubkey = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, - 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); public static object Main() { - bool result = NEO.UnRegisterCandidate(pubkey); + bool result = NEO.UnRegisterCandidate((ECPoint)pubkey); return result; } } ``` +Response body: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: The candidate is successfully unregistered. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md index 5f05355ff..a9312c5b8 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md @@ -1,4 +1,4 @@ -# UnclaimedGas Method (byte[], uint) +# UnclaimedGas Method (UInt160, uint) Gets the number of unclaimed GAS. @@ -9,7 +9,7 @@ Assembly: Neo.SmartContract.Framework ## Syntax ```c# -public static extern BigInteger UnclaimedGas(byte[] account, uint end); +public static extern BigInteger UnclaimedGas(UInt160 account, uint end); ``` Parameters @@ -22,7 +22,7 @@ Parameters ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); public static object Main() { @@ -32,4 +32,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Integer", + "value":"100000" +} +``` + +Response description: + +- Integer type: unclaimed GAS amount of this address is successfully requested. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Vote.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Vote.md index 57b14a5f5..ec6f3c124 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Vote.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Vote.md @@ -1,4 +1,4 @@ -# Vote Method (byte[], byte[]) +# Vote Method (UInt160, ECPoint) Votes for the candidates. @@ -6,10 +6,15 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> - Voting towards non-candidate is recorded but not taken into account in committee & validator election. However, such votes will be effective as soon as the voted address becomes a candidate. +> - Voter's signature will be checked. + ## Syntax ```c# -public static extern bool Vote(byte[] account, byte[] voteTo); +public static extern bool Vote(UInt160 account, ECPoint voteTo); ``` Parameters: @@ -22,16 +27,30 @@ Parameters: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); - private static readonly byte[] voteTo = new byte[] { 0x02, 0xe8, 0xff, 0x17, 0xc5, 0x67, 0xd6, 0x2f, 0x27, 0x4f, 0xe2, - 0x47, 0xcc, 0x88, 0x4a, 0x2a, 0x6c, 0xd3, 0xb8, 0xfd, 0x0d, 0x77, 0x9a, 0x8c, 0x58, 0x56, 0x28, 0x9a, 0x56, 0x0a, 0xcc, 0xac, 0xb4 }; - + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + public static object Main() { - bool result = NEO.Vote(account, voteTo); + bool result = NEO.Vote(account, (ECPoint)pubkey); return result; } } ``` +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Respond description: + +- Boolean type: voted successfully. + +- Others: failed. + [Back](../Neo.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle.md index 470fc177a..2baa7be72 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle.md @@ -1,6 +1,6 @@ # Oracle Class -Provides a series of methods of the native contract Oracle. +Provides a series of methods of the native contract Oracle, which contract hash is `0x35e4fc2e69a4d04d1db4d755c4150c50aff2e9a9`. Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md index ed7ff3e76..568d0a593 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md @@ -1,6 +1,6 @@ # Policy Class -Provides a series of methods of the native contract Policy. +Provides a series of methods of the native contract Policy, which contract hash is `0x1ca594b36b6b6b3f05efce8b106c824053d18713`. Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) @@ -21,10 +21,10 @@ public class Policy | [GetMaxBlockSize()](Policy/GetMaxBlockSize.md) | Gets max block size | | [GetMaxBlockSystemFee()](Policy/GetMaxBlockSystemFee.md) | Gets the maximum system fee for the block | | [GetFeePerByte()](Policy/GetFeePerByte.md) | Gets fee per byte | -| [IsBlocked(byte\[\] account)](Policy/IsBlocked.md) | Verifies whether the account is blocked | +| [IsBlocked(UInt160 account)](Policy/IsBlocked.md) | Verifies whether the account is blocked | | [SetMaxBlockSize(uint value)](Policy/SetMaxBlockSize.md) | Sets the max block size | | [SetMaxTransactionsPerBlock(uint value)](Policy/SetMaxTransactionsPerBlock.md) | Sets the maximum system fee for the block | | [SetMaxBlockSystemFee(long value)](Policy/SetMaxBlockSystemFee.md) | Sets max transaction per block | | [SetFeePerByte(long value)](Policy/SetFeePerByte.md) | Sets fee per byte | -| [BlockAccount(byte\[\] account)](Policy/BlockAccount.md) | Sets the blocked accounts | -| [UnblockAccount(byte\[\] account)](Policy/UnblockAccount.md) | Unblocks accounts | +| [BlockAccount(UInt160 account)](Policy/BlockAccount.md) | Sets the blocked accounts | +| [UnblockAccount(UInt160 account)](Policy/UnblockAccount.md) | Unblocks accounts | diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md index 1af861ac7..1efc32e09 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md @@ -1,4 +1,4 @@ -# BlockAccount Method (byte[]) +# BlockAccount Method (UInt160) Sets the blocked accounts @@ -6,10 +6,14 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method needs to check muti-signature of committee members, and it is executed as long as it's signed by more than half of the committee members. + ## Syntax ```c# -public static extern bool BlockAccount(byte[] account); +public static extern bool BlockAccount(UInt160 account); ``` Parameter @@ -21,7 +25,7 @@ Parameter ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); public static object Main() { @@ -31,4 +35,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: The account is blocked successfully. + +- Others: failed. + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md index ea07ec998..033371f34 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "type":"Integer", + "value":"300" +} +``` + +Response description: + +- Integer type: fee per byte for network transmission is successfully requested. + +- Others: failed. + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md index 7c3c477ff..8833a3c3f 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Integer", + "value":"500" +} +``` + +Response description: + +- Integer type: maximum block size is successfully requested. + +- Others: failed. + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md index eb6c80587..a9ac0c43a 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md @@ -25,4 +25,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +响应正文: + +```json +{ + "type":"Integer", + "value":"900000000000" +} +``` + +响应说明: + +- Integer type: Maximum system fee is obtained successfully. + +- Others: failed. + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md index 58c44be4d..6fde1c7c7 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md @@ -25,6 +25,21 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Integer", + "value":"500" +} +``` + +Response description: + +- Integer type: maximum transactions in a block are successfully requested. + +- Others: failed. + [Back](../Policy.md) diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md index f4b6d882e..acf47f405 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md @@ -31,4 +31,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "type":"Boolean", + "value":"false" +} +``` + +Response description: + +- Boolean type: true means the account is blocked. + +- Others: failed + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md index cd2367f54..6abf89644 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md @@ -6,6 +6,10 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method needs to check muti-signature of committee members, and it is executed as long as it's signed by more than half of the committee members. + ## Syntax ```c# @@ -29,4 +33,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +Respond description: + +- true: successfully set fee per byte for network transmission. + +- Others: failed. + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md index 37fcc79aa..ab49da478 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md @@ -6,6 +6,10 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method needs to check muti-signature of committee members, and it is executed as long as it's signed by more than half of the committee members. + ## Syntax ```c# @@ -29,5 +33,20 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Respond body: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +Respond description: + +- true: successfully set maximum block size. + +- Others: failed. + [Back](../Policy.md) diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md index 4d74aa171..47b195a5b 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md @@ -6,6 +6,10 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method needs to check muti-signature of committee members, and it is executed as long as it's signed by more than half of the committee members. + ## Syntax ```c# @@ -29,6 +33,21 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: successfully set the maximum system fee for the block + +- Others: failed. + >[!Note] > >The fee should not be less than 4007600. diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md index 6d91190ed..e2ff47195 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md @@ -6,6 +6,10 @@ Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) Assembly: Neo.SmartContract.Framework +> [!Note] +> +> The method needs to check muti-signature of committee members, and it is executed as long as it's signed by more than half of the committee members. + ## Syntax ```c# @@ -29,4 +33,19 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: successfully set maximum transactions in a block + +- Others: failed. + [Back](../Policy.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md index 3a4ffa472..e6ab01dd4 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md @@ -1,4 +1,4 @@ -# UnblockAccount Method (byte[]) +# UnblockAccount Method (UInt160) Unblocks accounts. @@ -9,7 +9,7 @@ Assembly: Neo.SmartContract.Framework ## Syntax ```c# -public static extern bool UnblockAccount(byte[] account); +public static extern bool UnblockAccount(UInt160 account); ``` Parameter: @@ -21,7 +21,7 @@ Parameter: ```c# public class Contract1 : SmartContract.Framework.SmartContract { - private static readonly byte[] account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); public static object Main() { @@ -31,5 +31,20 @@ public class Contract1 : SmartContract.Framework.SmartContract } ``` +Response body: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: The account is successfully unblocked. + +- Others: failed. + [Back](../Policy.md) diff --git a/docs/zh-cn/reference/governance_api.md b/docs/zh-cn/reference/governance_api.md index cff4a7d8f..1799c07af 100644 --- a/docs/zh-cn/reference/governance_api.md +++ b/docs/zh-cn/reference/governance_api.md @@ -36,8 +36,8 @@ GAS最小单位为10-8。GAS代表着Neo网络的使用权,可通 | 方法 | 参数 | 费用(GAS) | | ---- | ------------------------------------ | ---- | -| [`registerCandidate`](govapi/registerCandidate.md) | byte[] publicKey | 0.05 | -| [`unregisterCandidate`](govapi/unregisterCandidate.md) | byte[] publicKey | 0.05 | +| [`RegisterCandidate`](scapi/fw/dotnet/neo/Neo/RegisterCandidate.md) | UInt160 publicKey | 0.05 | +| [`UnregisterCandidate`](scapi/fw/dotnet/neo/Neo/UnregisterCandidate.md) | UInt160 publicKey | 0.05 | > [!Note] > @@ -51,13 +51,13 @@ GAS最小单位为10-8。GAS代表着Neo网络的使用权,可通 | 方法 | 参数 | 费用(GAS) | | ---- | ------------------------------------ | ---- | -| [`vote`](govapi/vote.md) | byte[] account, byte[] voteTo | 5 | +| [`Vote`](scapi/fw/dotnet/neo/Neo/Vote.md) | UInt160 account, byte[] voteTo | 5 | 由于账户NEO余额会随交易而不断变化,而且投票和注册的候选人也在不断变化,因此在每个区块都会根据以上变化更新候选人及相应投票结果。 | 方法 | 参数 | 费用(GAS) | | ---- | ------------------------------------ | ---- | -| [`getCandidates`](govapi/getCandidates.md) | null | 1 | +| [`GetCandidates`](scapi/fw/dotnet/neo/Neo/GetCandidates.md) | null | 1 | ### 委员会(Committee) @@ -74,11 +74,11 @@ GAS最小单位为10-8。GAS代表着Neo网络的使用权,可通 | 方法 | 参数 | 费用(GAS) | | ---- | ------------------------------------ | ---- | -| [`setMaxBlockSize`](govapi/setMaxBlockSize.md) | uint blockSize | 0.03 | -| [`setMaxTransactionsPerBlock`](govapi/setMaxTransactionsPerBlock.md) | uint maxTransactions | 0.03 | -| [`setFeePerByte`](govapi/setFeePerByte.md) | long feePerByte | 0.03 | -| [`blockAccount`](govapi/blockAccount.md) | byte[] account | 0.03 | -| [`unblockAccount`](govapi/unblockAccount.md) | byte[] account | 0.03 | +| [`SetMaxBlockSize`](scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md) | uint blockSize | 0.03 | +| [`SetMaxTransactionsPerBlock`](scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md) | uint maxTransactions | 0.03 | +| [`SetFeePerByte`](scapi/fw/dotnet/neo/Policy/SetFeePerByte.md) | long feePerByte | 0.03 | +| [`BlockAccount`](scapi/fw/dotnet/neo/Policy/BlockAccount.md) | UInt160 account | 0.03 | +| [`UnblockAccount`](scapi/fw/dotnet/neo/Policy/UnblockAccount.md) | UInt160 account | 0.03 | 委员会可以通过发送包含多签的,调用相应合约方法的交易上链使投票生效。投票数超过委员会数量的一半的向上取整即为有效投票,相应操作将被执行生效。 @@ -86,9 +86,9 @@ GAS最小单位为10-8。GAS代表着Neo网络的使用权,可通 | 方法 | 参数 | 费用(GAS) | | ---- | ------------------------------------ | ---- | -| [`getMaxBlockSize`](govapi/getMaxBlockSize.md) | null | 0.01 | -| [`getMaxTransactionsPerBlock`](govapi/getMaxTransactionsPerBlock.md) | null | 0.01 | -| [`getFeePerByte`](govapi/getFeePerByte.md) | null | 0.01 | +| [`GetMaxBlockSize`](scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md) | null | 0.01 | +| [`GetMaxTransactionsPerBlock`](scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md) | null | 0.01 | +| [`GetFeePerByte`](scapi/fw/dotnet/neo/Policy/GetFeePerByte.md) | null | 0.01 | | [`getBlockedAccounts`](govapi/getBlockedAccounts.md) | null | 0.01 | #### 产生方式 @@ -99,7 +99,7 @@ GAS最小单位为10-8。GAS代表着Neo网络的使用权,可通 | 方法 | 参数 | 费用(GAS) | 返回结果 | | ---- | ------------------------------------ | ---- | ---- | -| [`getCommittee`](govapi/getCommittee.md) | null | 1 | 返回当前委员会(Array) | +| [`GetCommittee`](scapi/fw/dotnet/neo/Neo/GetCommittee.md) | null | 1 | 返回当前委员会(Array) | ### 共识节点(Validator) @@ -116,7 +116,7 @@ GAS最小单位为10-8。GAS代表着Neo网络的使用权,可通 | 方法 | 参数 | 费用(GAS) | 返回结果 | | ---- | ------------------------------------ | ---- | ---- | | [`getValidators`](govapi/getValidators.md) | null | 1 | 返回当前共识节点(Array) | -| [`getNextBlockValidators`](govapi/getNextBlockValidators.md) | null | 1 | 返回下个块(正在持久化的块)的共识节点(Array) | +| [`GetNextBlockValidators`](scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md) | null | 1 | 返回下个块(正在持久化的块)的共识节点(Array) | ## Token分配 @@ -139,9 +139,9 @@ NEO及GAS均为[Nep5](https://github.com/neo-project/proposals/blob/master/nep-5 | [`name`](govapi/name.md) | null | 0 | 返回Token名称(String)| | [`symbol`](govapi/symbol.md) | null | 0 | 返回Token标志(String) | | [`decimals`](govapi/decimals.md) | null | 0.01 | 返回Token精度(UInt) | -| [`totalSupply`](govapi/totalSupply.md) | null | 0.01 | 返回Token当前流通量(BigInteger) | -| [`balanceOf`](govapi/balanceOf.md) | byte[] account | 0.01 | 返回该账户的余额(BigInteger) | -| [`transfer`](govapi/transfer.md) | byte[] from, byte[] to, BigInteger amount | 0.08 | 将指定数额的Token从from转往to,注意这里需要校验from的签名,方法调用者是否为from,to是否能够收款,以及from余额是否充足 | +| [`TotalSupply`](scapi/fw/dotnet/neo/Neo/TotalSupply.md) | null | 0.01 | 返回Token当前流通量(BigInteger) | +| [`BalanceOf`](scapi/fw/dotnet/neo/Neo/BalanceOf.md) | UInt160 account | 0.01 | 返回该账户的余额(BigInteger) | +| [`Transfer`](scapi/fw/dotnet/neo/Neo/Transfer.md) | UInt160 from, UInt160 to, BigInteger amount | 0.08 | 将指定数额的Token从from转往to,注意这里需要校验from的签名,方法调用者是否为from,to是否能够收款,以及from余额是否充足 | | [`onPersist`](govapi/onPersist.md) | null | 0 | 手动执行Nep5在持久化区块时进行的操作 | | [`supportedStandards`](govapi/supportedStandards.md) | null | 0 | 返回支持的NEP标准(String[]) | @@ -149,4 +149,5 @@ NEO扩展的合约方法如下: | 方法 | 参数 | 费用(GAS) | 返回结果 | | ---- | ------------------------------------ | ---- | ---- | -| [`unclaimedGas`](govapi/unclaimedGas.md) | byte[] account | 0.03 | 返回该账户未提取的GAS(uint) | +| [`UnclaimedGas`](scapi/fw/dotnet/neo/Neo/UnclaimedGas.md) | UInt160 account | 0.03 | 返回该账户未提取的GAS(uint) | + diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md index 2e8ef2cec..6b8544107 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -44,7 +44,7 @@ public class Contract1 : SmartContract.Framework.SmartContract 响应说明: -- Array类型:成功获取候选人列表。 +- Array 类型:成功获取候选人列表。 - 其他:失败。 diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md index 59ca6a008..c846fc8af 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -1,6 +1,6 @@ # GetCommittee 方法 () -获取委员会成员列表。将候选人根据票数多少排序,取最前面的一定数量候选人(默认21个)作为委员会。委员会名单将在每个区块根据最新投票更新。 +获取委员会成员列表。候选人将根据得票数排序,最前面一定数量的候选人(默认21个)成为委员会成员。委员会名单将在每个区块根据最新投票更新。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md index e78880bfc..d7925ac0a 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -1,6 +1,6 @@ # GetNextBlockValidators 方法 () -获取下个区块的验证人列表。将候选人根据票数多少排序,取最前面的一定数量候选人(默认7个)作为共识节点。与委员会类似,共识节点名单将在每个区块根据最新投票更新。 +获取下个区块的验证人列表。候选人将根据得票数排序,取最前面一定数量的候选人(默认7个)作为共识节点。与委员会类似,共识节点名单将在每个区块根据最新投票更新。 命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md index 43e5858d9..e96ffa374 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -52,4 +52,5 @@ public class Contract1 : SmartContract.Framework.SmartContract - Boolean类型:true表示成功转账。 - 其他:失败。 + [返回上级](../Neo.md) \ No newline at end of file diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md index 3d1f45c18..b129a43e7 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md @@ -6,14 +6,6 @@ 程序集:Neo.SmartContract.Framework -委员会可以通过投票的方式对Neo网络的一些参数进行修改,目前包括以下内容: - -* 设置区块最大大小 -* 设置区块最大系统费 -* 设置区块包含最大交易量 -* 设置交易每字节网络费 -* 地址屏蔽/解除屏蔽 - ## 语法 ```c# diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md index 622d5bb68..f37287630 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md @@ -48,6 +48,8 @@ public class Contract1 : SmartContract.Framework.SmartContract - 其他:失败。 -[返回上级](../Policy.md) +> [!Note] +> +> 设置的手续费值应不小于4007600。 ->注:设置的手续费值应不小于4007600。 \ No newline at end of file +[返回上级](../Policy.md) \ No newline at end of file