diff --git a/config.json b/config.json index e6f811cc1..02b8cc6df 100644 --- a/config.json +++ b/config.json @@ -16,22 +16,6 @@ "webRoot": "wwwroot", "git": "https://github.com/neo-project/docs/blob/new-release-neo3/docs/en-us/" }, - { - "origin": "tutorial\\zh-cn", - "template": "template", - "destination": "..\\docs\\wwwroot\\v3\\tutorial\\zh-cn", - "catalog": "tutorial\\zh-cn\\toc.yml", - "webRoot": "wwwroot", - "git": "https://github.com/neo-project/docs/blob/new-release-neo3/tutorial/zh-cn/" - }, - { - "origin": "tutorial\\en-us", - "template": "template", - "destination": "..\\docs\\wwwroot\\v3\\tutorial\\en-us", - "catalog": "tutorial\\en-us\\toc.yml", - "webRoot": "wwwroot", - "git": "https://github.com/neo-project/docs/blob/new-release-neo3/tutorial/en-us/" - }, { "origin": "faq\\zh-cn", "template": "template", diff --git a/docs/en-us/advanced/assets/oracle.png b/docs/en-us/advanced/assets/oracle.png new file mode 100644 index 000000000..ebe62cc74 Binary files /dev/null and b/docs/en-us/advanced/assets/oracle.png differ diff --git a/docs/en-us/advanced/oracle.md b/docs/en-us/advanced/oracle.md new file mode 100644 index 000000000..935f4a399 --- /dev/null +++ b/docs/en-us/advanced/oracle.md @@ -0,0 +1,84 @@ +# Oracles + +Oracle solutions enable the Blockchain to obtain external data from the outside network. As a gateway for smart contracts to communicate with the outside network, Oracles open a window to the outside world for the blockchain. For data requested outside the Blockchain, Oracles guarantee the truthfulness or reliability of the results through multi-party verification, and store the results in the form of blocks on the chain for the smart contract to get access to this data. + +## Neo Oracles + +Neo provides a built-in Oracle service with native contracts, which can be invoked by other contracts. In order to get the data outside the blockchain, the contract first needs to construct an Oracle request transaction, and after it is deployed on the chain, the Neo Oracle service can be invoked. + +Oracle nodes elected by the committee and other nodes in the network assist in the operation of transactions. When the Oracle transaction is broadcast, each node stores the currently unverified transaction as a known hash in its memory pool and pass it to other nodes. Through this process, the Oracle node of the Oracle transaction uses the URL and filters to complete all included requests. Then, by appending the result to the TransactionAttribute part of the Oracle transaction, these nodes reach a consensus on the response data that returned. + +Once enough signatures are collected, the Oracle transaction is regarded as verified and stored in a block by the consensus node, which can be accessed by the contract after the block is on the chain. + +Oracle nodes charge a certain amount of transaction fees. You can pay GAS for Oracle transactions on Neo blockchain. + +![](assets/oracle.png) + +## Oracle requests + +| Field | Bytes | Description | +| ---------------- | --------- | ------------------------------------------------------------ | +| Url | string | Url of the request | +| Filter | string | Filter, used to filter useless data | +| CallbackContract | 20 bytes | Callback the contract | +| CallbackMethod | string | The callback method name | +| UserData | var bytes | Extra data provided by the user | +| GasForResponse | long | The fee for getting the response, which is set by the contract that calls the Oracle service | + +### GasForResponse + +The fee for getting the response. `GasForResponse` should not be less than 0.1 GAS, otherwise the Oracle request cannot be initiated. + +### Filter + +Filters are used to filter out useful information in the results returned from the data source, where the Filter field is a `JSONPath` expression. For more information, click [Here](https://github.com/json-path/JsonPath). + +## Oracle response + +When constructing the `Response` transaction, the `finish` method of the Oracle contract is called to execute the callback function `CallbackMethod`. The callback function is defined in the request transaction contract. The callback function usually requires the following fields: + +| Field | Bytes | Description | +| -------- | --------- | ------------------------------- | +| Url | string | Url of the request | +| UserData | var bytes | Extra data provided by the user | +| Code | byte | Oracle response code | +| Result | var bytes | Response result | + +### Code +The Code field defines the execution result of response transactions. It includes the following five types: + +| Value | Response | Description | Type | +| ------ | ----------- | ---------------------------------- | ------ | +| `0x00` | `Success` | Executed successfully. | `byte` | +| `0x01` | `NotFound` | The requested message is not found | `byte` | +| `0x12` | `Timeout` | Execution timeout | `byte` | +| `0x14` | `Forbidden` | No execution permission | `byte` | +| `0xff` | `Error` | Execution error | `byte` | + +## An Oracle contract example + +```C# + public class OracleDemo : SmartContract + { + public static void DoRequest() + { + 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); + } + } +``` \ No newline at end of file diff --git a/docs/en-us/tooldev/concept/blockchain/block.md b/docs/en-us/basic/concept/blockchain/block.md similarity index 100% rename from docs/en-us/tooldev/concept/blockchain/block.md rename to docs/en-us/basic/concept/blockchain/block.md diff --git a/docs/en-us/tooldev/concept/blockchain/token_model.md b/docs/en-us/basic/concept/blockchain/token_model.md similarity index 100% rename from docs/en-us/tooldev/concept/blockchain/token_model.md rename to docs/en-us/basic/concept/blockchain/token_model.md diff --git a/docs/en-us/tooldev/concept/charging_model.md b/docs/en-us/basic/concept/charging_model.md similarity index 95% rename from docs/en-us/tooldev/concept/charging_model.md rename to docs/en-us/basic/concept/charging_model.md index 02e8efeb9..96b95a3b0 100644 --- a/docs/en-us/tooldev/concept/charging_model.md +++ b/docs/en-us/basic/concept/charging_model.md @@ -11,4 +11,4 @@ Network fee is the fee to pack transactions into a block. Users can define the a ### System Fee System fees are the cost of resources consumed by the transaction execution in NeoVM. The total fee depends on the number and type of instructions executed in the smart contract script. -Additionally, when running a smart contract, system calls or instructions executed by NeoVM also incur system fees. For details, refer to [Fees](../../sc/fees.md). +Additionally, when running a smart contract, system calls or instructions executed by NeoVM also incur system fees. For details, refer to [Fees](../../reference/fees.md). diff --git a/docs/en-us/tooldev/concept/cryptography/encode_algorithm.md b/docs/en-us/basic/concept/cryptography/encode_algorithm.md similarity index 100% rename from docs/en-us/tooldev/concept/cryptography/encode_algorithm.md rename to docs/en-us/basic/concept/cryptography/encode_algorithm.md diff --git a/docs/en-us/tooldev/concept/cryptography/encryption_algorithm.md b/docs/en-us/basic/concept/cryptography/encryption_algorithm.md similarity index 100% rename from docs/en-us/tooldev/concept/cryptography/encryption_algorithm.md rename to docs/en-us/basic/concept/cryptography/encryption_algorithm.md diff --git a/docs/en-us/tooldev/concept/cryptography/hash_algorithm.md b/docs/en-us/basic/concept/cryptography/hash_algorithm.md similarity index 100% rename from docs/en-us/tooldev/concept/cryptography/hash_algorithm.md rename to docs/en-us/basic/concept/cryptography/hash_algorithm.md diff --git a/docs/en-us/tooldev/concept/endian.md b/docs/en-us/basic/concept/endian.md similarity index 97% rename from docs/en-us/tooldev/concept/endian.md rename to docs/en-us/basic/concept/endian.md index e9bb9e1f9..8b0b26b9b 100644 --- a/docs/en-us/tooldev/concept/endian.md +++ b/docs/en-us/basic/concept/endian.md @@ -16,10 +16,9 @@ Let's look at a standard wallet address and corresponding scripthash strings in - Big endian:0x946d6caa602a2b85fbeb7cf05335b2c3b124f1e4 - Little endian:e4f124b1c3b23553f07cebfb852b2a60aa6c6d94 -To convert between the wallet address and scripthash, or between big endian and little endian byte order, use one of the following: +To convert between the wallet address and scripthash, or between big endian and little endian byte order, use the following: - [DataTransformationTools](https://peterlinx.github.io/DataTransformationTools/) -- Neo SDK (See [Data Conversion](../sdk/conversion.md)) ### The contract scripthash When a contract has been deployed a scripthash is generated as a unified identifier of the contract. The contract scripthash can be converted into the standard 20-byte address for receiving assets from transfer transactions. In that case the contract scripthash is used in big endian format. For example: diff --git a/docs/en-us/tooldev/transaction/transaction.md b/docs/en-us/basic/concept/transaction.md similarity index 97% rename from docs/en-us/tooldev/transaction/transaction.md rename to docs/en-us/basic/concept/transaction.md index 2af271184..7cb198a2c 100644 --- a/docs/en-us/tooldev/transaction/transaction.md +++ b/docs/en-us/basic/concept/transaction.md @@ -53,15 +53,15 @@ Scopes defines the effective range of the signature, including these types: The system fee is calculated by opcodes to be executed by the Neo virtual machine. The 10 GAS free system fee is canceled in Neo3. The total fee is subject to the quantity and type of instructions in the contract script. The calculation formula is as follows: -![](../../../zh-cn/tooldev/images/transaction/system_fee.png) +![](../../../zh-cn/basic/images/transaction/system_fee.png) -where *OpcodeSet* is opcode set, *OpcodePricei* is the cost of opcode i, *ni* is the execution times of instruction i in the contract script. For each opcode fee refer to [Fees for Instructions](../../sc/fees.md#fees-for-instructions). +where *OpcodeSet* is opcode set, *OpcodePricei* is the cost of opcode i, *ni* is the execution times of instruction i in the contract script. For each opcode fee refer to [Fees for Instructions](../../reference/fees.md#fees-for-instructions). ### netfee The network fee is charged when the user submits a transactions to Neo blockchain as a reward for consensus nodes generating blocks. There is a base fee for each transaction. The transaction is only executed if the fee paid by the user is greater than or equal to the base fee; otherwise, the transaction will be treated as invalid. The calculation formula is as follows: -![network fee](../../../zh-cn/tooldev/images/transaction/network_fee.png) +![network fee](../../../zh-cn/basic/images/transaction/network_fee.png) where *VerificationCost* is the fee for instructions executed by NeoVM to verify transaction signatures, *tx.Length* is the transaction data byte length, and *FeePerByte* is transaction fee per byte, currently 0.00001 GAS. @@ -97,7 +97,7 @@ By repeating this step, the invocation script can push multiple signatures for t #### VerificationScript -Verification script, commonly known as address script, includes normal address script and multi-signature address script. The address script can be directly obtained from the wallet account. For information about the construction refer to [Wallets](../wallets.md#address). +Verification script, commonly known as address script, includes normal address script and multi-signature address script. The address script can be directly obtained from the wallet account. For information about the construction refer to [Wallets](wallets.md#address). It can also be used as a custom authentication contract script. diff --git a/docs/en-us/tooldev/wallets.md b/docs/en-us/basic/concept/wallets.md similarity index 98% rename from docs/en-us/tooldev/wallets.md rename to docs/en-us/basic/concept/wallets.md index 548e35fe1..e3ecdfc49 100644 --- a/docs/en-us/tooldev/wallets.md +++ b/docs/en-us/basic/concept/wallets.md @@ -8,7 +8,7 @@ You can redesign and modify Neo wallets following your own thoughts, but the bel In Neo, the account is the smart contract and the address represents a contract script. The below flow diagram shows how to derive the public key from the private key and then to the address: -![](images\wallets\privatekey-2-publickey-address.png) +![](../images/wallets/privatekey-2-publickey-address.png) ### Private Key @@ -24,7 +24,7 @@ There are two main encoding formats for private keys in Neo: The wif format is to add prefix `0x80` and suffix `0x01` in the original 32-byte data, and get the string after Base58Check encoding. -![](images\wallets\wif_format.png) +![](../images/wallets\wif_format.png) Example: @@ -70,7 +70,7 @@ Address is a string of numbers and letters after a series of transformations of 0x0C + 0x21 + Public Key(Compressed 33 bytes) + 0x0B + 0x41 + 0x0a906ad4 ``` - ![](images\wallets\account_address_script_checksign.png) + ![](..\images\wallets\account_address_script_checksign.png) 2. Calculate script hash of the contract (20 bytes, make once SHA256 and RIPEMD160 of the script). @@ -231,7 +231,7 @@ An NEP6 wallet uses scrypt algorithm as the core method of wallet encryption and #### Encryption steps -![](images\wallets\nep2key.png) +![](..\images\wallets\nep2key.png) 1. The address is derived from the public key, and the address hash is the first four bytes of `SHA256(SHA256(Address))` @@ -358,7 +358,7 @@ Example: The full-node wallet is a complete backup of blockchain data, which saves all the onchain data and participates in p2p network, therefore it needs a large storage space. -Neo-CLI and Neo-GUI are all full-node wallet. For more information refer to [Neo node](../node/introduction.md). +Neo-CLI and Neo-GUI are all full-node wallet. For more information refer to [Neo node](../../node/introduction.md). ### SPV wallet diff --git a/docs/en-us/tooldev/consensus/consensus_algorithm.md b/docs/en-us/basic/consensus/consensus_algorithm.md similarity index 94% rename from docs/en-us/tooldev/consensus/consensus_algorithm.md rename to docs/en-us/basic/consensus/consensus_algorithm.md index c0069d387..b8c82845f 100644 --- a/docs/en-us/tooldev/consensus/consensus_algorithm.md +++ b/docs/en-us/basic/consensus/consensus_algorithm.md @@ -1,7 +1,5 @@ # dBFT 2.0 Algorithm -Neo proposes dBFT (delegated Byzantine Fault Tolerance) consensus algorithm based on the PBFT (Practical Byzantine Fault Tolerance) algorithm. The dBFT algorithm determines the next-consensus-round validators based on real-time blockchain voting, which effectively enhances the efficiency of the algorithm, and saves block time and transaction confirmation time. dBFT2.0, as an upgraded version, was released in March, 2019, which improves robustness and safety by introducing the 3-stage consensus mechanism as well as a recovery mechanism. - ## Terms | **Term** | **Definition** | diff --git a/docs/en-us/tooldev/consensus/consensus_protocol.md b/docs/en-us/basic/consensus/consensus_protocol.md similarity index 100% rename from docs/en-us/tooldev/consensus/consensus_protocol.md rename to docs/en-us/basic/consensus/consensus_protocol.md diff --git a/docs/en-us/basic/technology/dbft.md b/docs/en-us/basic/consensus/dbft.md similarity index 96% rename from docs/en-us/basic/technology/dbft.md rename to docs/en-us/basic/consensus/dbft.md index 673af04b0..1425ffea4 100644 --- a/docs/en-us/basic/technology/dbft.md +++ b/docs/en-us/basic/consensus/dbft.md @@ -34,7 +34,7 @@ A new block will be generated with each round of consensus, with at least N − ### General Procedures -![](../../tooldev/images/consensus/1.png) +![](../../basic/images/consensus/1.png) A round of consensus consists of 4 steps, as shown in the Figure above. @@ -72,11 +72,3 @@ Hence the success of block generation means: - The rest of the validators are insufficient to produce another different block. Therefore, the finality of the new block can be guaranteed at a given height. - -## Further Reading - -[Consensus Algorithm](../../tooldev/consensus/consensus_algorithm.md) - -[Consensus Protocol](../../tooldev/consensus/consensus_protocol.md) - -[Voting](../../tooldev/consensus/vote_validator.md) \ No newline at end of file diff --git a/docs/en-us/tooldev/consensus/vote_validator.md b/docs/en-us/basic/consensus/vote_validator.md similarity index 100% rename from docs/en-us/tooldev/consensus/vote_validator.md rename to docs/en-us/basic/consensus/vote_validator.md diff --git a/docs/en-us/tooldev/images/blockchain/account_scripthash.jpg b/docs/en-us/basic/images/blockchain/account_scripthash.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/account_scripthash.jpg rename to docs/en-us/basic/images/blockchain/account_scripthash.jpg diff --git a/docs/en-us/tooldev/images/blockchain/account_scripthash_en.jpg b/docs/en-us/basic/images/blockchain/account_scripthash_en.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/account_scripthash_en.jpg rename to docs/en-us/basic/images/blockchain/account_scripthash_en.jpg diff --git a/docs/en-us/tooldev/images/blockchain/blockchain.jpg b/docs/en-us/basic/images/blockchain/blockchain.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/blockchain.jpg rename to docs/en-us/basic/images/blockchain/blockchain.jpg diff --git a/docs/en-us/tooldev/images/blockchain/economic_model.jpg b/docs/en-us/basic/images/blockchain/economic_model.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/economic_model.jpg rename to docs/en-us/basic/images/blockchain/economic_model.jpg diff --git a/docs/en-us/tooldev/images/blockchain/gas-distribution-en.jpg b/docs/en-us/basic/images/blockchain/gas-distribution-en.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/gas-distribution-en.jpg rename to docs/en-us/basic/images/blockchain/gas-distribution-en.jpg diff --git a/docs/en-us/tooldev/images/blockchain/gas-distribution.jpg b/docs/en-us/basic/images/blockchain/gas-distribution.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/gas-distribution.jpg rename to docs/en-us/basic/images/blockchain/gas-distribution.jpg diff --git a/docs/en-us/tooldev/images/blockchain/nextconsensus_script.jpg b/docs/en-us/basic/images/blockchain/nextconsensus_script.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/nextconsensus_script.jpg rename to docs/en-us/basic/images/blockchain/nextconsensus_script.jpg diff --git a/docs/en-us/tooldev/images/blockchain/nextconsensus_script_en.jpg b/docs/en-us/basic/images/blockchain/nextconsensus_script_en.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/nextconsensus_script_en.jpg rename to docs/en-us/basic/images/blockchain/nextconsensus_script_en.jpg diff --git a/docs/en-us/tooldev/images/blockchain/nextconsensus_witness.jpg b/docs/en-us/basic/images/blockchain/nextconsensus_witness.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/nextconsensus_witness.jpg rename to docs/en-us/basic/images/blockchain/nextconsensus_witness.jpg diff --git a/docs/en-us/tooldev/images/blockchain/nextconsensus_witness_en.jpg b/docs/en-us/basic/images/blockchain/nextconsensus_witness_en.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/nextconsensus_witness_en.jpg rename to docs/en-us/basic/images/blockchain/nextconsensus_witness_en.jpg diff --git a/docs/en-us/tooldev/images/blockchain/system1.jpg b/docs/en-us/basic/images/blockchain/system1.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/system1.jpg rename to docs/en-us/basic/images/blockchain/system1.jpg diff --git a/docs/en-us/tooldev/images/blockchain/system1_em.jpg b/docs/en-us/basic/images/blockchain/system1_em.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/system1_em.jpg rename to docs/en-us/basic/images/blockchain/system1_em.jpg diff --git a/docs/en-us/tooldev/images/blockchain/tx.jpg b/docs/en-us/basic/images/blockchain/tx.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/tx.jpg rename to docs/en-us/basic/images/blockchain/tx.jpg diff --git a/docs/en-us/tooldev/images/blockchain/utxo.jpg b/docs/en-us/basic/images/blockchain/utxo.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/utxo.jpg rename to docs/en-us/basic/images/blockchain/utxo.jpg diff --git a/docs/en-us/tooldev/images/blockchain/utxo_en.jpg b/docs/en-us/basic/images/blockchain/utxo_en.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain/utxo_en.jpg rename to docs/en-us/basic/images/blockchain/utxo_en.jpg diff --git a/docs/en-us/tooldev/images/blockchain/wallets/privateKey-wif-en.png b/docs/en-us/basic/images/blockchain/wallets/privateKey-wif-en.png similarity index 100% rename from docs/en-us/tooldev/images/blockchain/wallets/privateKey-wif-en.png rename to docs/en-us/basic/images/blockchain/wallets/privateKey-wif-en.png diff --git a/docs/en-us/tooldev/images/blockchain/wallets/privateKey-wif.png b/docs/en-us/basic/images/blockchain/wallets/privateKey-wif.png similarity index 100% rename from docs/en-us/tooldev/images/blockchain/wallets/privateKey-wif.png rename to docs/en-us/basic/images/blockchain/wallets/privateKey-wif.png diff --git a/docs/en-us/tooldev/images/blockchain_paradigm/.gitignore b/docs/en-us/basic/images/blockchain_paradigm/.gitignore similarity index 100% rename from docs/en-us/tooldev/images/blockchain_paradigm/.gitignore rename to docs/en-us/basic/images/blockchain_paradigm/.gitignore diff --git a/docs/en-us/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png b/docs/en-us/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png similarity index 100% rename from docs/en-us/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png rename to docs/en-us/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png diff --git a/docs/en-us/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png b/docs/en-us/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png similarity index 100% rename from docs/en-us/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png rename to docs/en-us/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png diff --git a/docs/en-us/tooldev/images/blockchain_paradigm/MerkleTree01-en.png b/docs/en-us/basic/images/blockchain_paradigm/MerkleTree01-en.png similarity index 100% rename from docs/en-us/tooldev/images/blockchain_paradigm/MerkleTree01-en.png rename to docs/en-us/basic/images/blockchain_paradigm/MerkleTree01-en.png diff --git a/docs/en-us/tooldev/images/blockchain_paradigm/MerkleTree01.png b/docs/en-us/basic/images/blockchain_paradigm/MerkleTree01.png similarity index 100% rename from docs/en-us/tooldev/images/blockchain_paradigm/MerkleTree01.png rename to docs/en-us/basic/images/blockchain_paradigm/MerkleTree01.png diff --git a/docs/en-us/tooldev/images/blockchain_paradigm/formula_ecdsa.jpg b/docs/en-us/basic/images/blockchain_paradigm/formula_ecdsa.jpg similarity index 100% rename from docs/en-us/tooldev/images/blockchain_paradigm/formula_ecdsa.jpg rename to docs/en-us/basic/images/blockchain_paradigm/formula_ecdsa.jpg diff --git a/docs/en-us/tooldev/images/consensus/1.png b/docs/en-us/basic/images/consensus/1.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/1.png rename to docs/en-us/basic/images/consensus/1.png diff --git a/docs/en-us/tooldev/images/consensus/10.png b/docs/en-us/basic/images/consensus/10.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/10.png rename to docs/en-us/basic/images/consensus/10.png diff --git a/docs/en-us/tooldev/images/consensus/11.png b/docs/en-us/basic/images/consensus/11.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/11.png rename to docs/en-us/basic/images/consensus/11.png diff --git a/docs/en-us/tooldev/images/consensus/2.png b/docs/en-us/basic/images/consensus/2.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/2.png rename to docs/en-us/basic/images/consensus/2.png diff --git a/docs/en-us/tooldev/images/consensus/3.png b/docs/en-us/basic/images/consensus/3.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/3.png rename to docs/en-us/basic/images/consensus/3.png diff --git a/docs/en-us/tooldev/images/consensus/4.png b/docs/en-us/basic/images/consensus/4.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/4.png rename to docs/en-us/basic/images/consensus/4.png diff --git a/docs/en-us/tooldev/images/consensus/5.png b/docs/en-us/basic/images/consensus/5.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/5.png rename to docs/en-us/basic/images/consensus/5.png diff --git a/docs/en-us/tooldev/images/consensus/6.png b/docs/en-us/basic/images/consensus/6.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/6.png rename to docs/en-us/basic/images/consensus/6.png diff --git a/docs/en-us/tooldev/images/consensus/7.png b/docs/en-us/basic/images/consensus/7.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/7.png rename to docs/en-us/basic/images/consensus/7.png diff --git a/docs/en-us/tooldev/images/consensus/8.png b/docs/en-us/basic/images/consensus/8.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/8.png rename to docs/en-us/basic/images/consensus/8.png diff --git a/docs/en-us/tooldev/images/consensus/9.png b/docs/en-us/basic/images/consensus/9.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/9.png rename to docs/en-us/basic/images/consensus/9.png diff --git a/docs/en-us/tooldev/images/consensus/consensus_msg_seq.jpg b/docs/en-us/basic/images/consensus/consensus_msg_seq.jpg similarity index 100% rename from docs/en-us/tooldev/images/consensus/consensus_msg_seq.jpg rename to docs/en-us/basic/images/consensus/consensus_msg_seq.jpg diff --git a/docs/en-us/tooldev/images/consensus/vote_candidate.png b/docs/en-us/basic/images/consensus/vote_candidate.png similarity index 100% rename from docs/en-us/tooldev/images/consensus/vote_candidate.png rename to docs/en-us/basic/images/consensus/vote_candidate.png diff --git a/docs/en-us/tooldev/images/neo_cli_structure/.gitignore b/docs/en-us/basic/images/neo_cli_structure/.gitignore similarity index 100% rename from docs/en-us/tooldev/images/neo_cli_structure/.gitignore rename to docs/en-us/basic/images/neo_cli_structure/.gitignore diff --git a/docs/en-us/tooldev/images/neo_cli_structure/neo-cli.png b/docs/en-us/basic/images/neo_cli_structure/neo-cli.png similarity index 100% rename from docs/en-us/tooldev/images/neo_cli_structure/neo-cli.png rename to docs/en-us/basic/images/neo_cli_structure/neo-cli.png diff --git a/docs/en-us/tooldev/images/neo_cli_structure/neo-p2p-network.png b/docs/en-us/basic/images/neo_cli_structure/neo-p2p-network.png similarity index 100% rename from docs/en-us/tooldev/images/neo_cli_structure/neo-p2p-network.png rename to docs/en-us/basic/images/neo_cli_structure/neo-p2p-network.png diff --git a/docs/en-us/tooldev/images/neo_vm/.gitignore b/docs/en-us/basic/images/neo_vm/.gitignore similarity index 100% rename from docs/en-us/tooldev/images/neo_vm/.gitignore rename to docs/en-us/basic/images/neo_vm/.gitignore diff --git a/docs/en-us/tooldev/images/neo_vm/nvm.jpg b/docs/en-us/basic/images/neo_vm/nvm.jpg similarity index 100% rename from docs/en-us/tooldev/images/neo_vm/nvm.jpg rename to docs/en-us/basic/images/neo_vm/nvm.jpg diff --git a/docs/en-us/tooldev/images/neo_vm/nvm2.jpg b/docs/en-us/basic/images/neo_vm/nvm2.jpg similarity index 100% rename from docs/en-us/tooldev/images/neo_vm/nvm2.jpg rename to docs/en-us/basic/images/neo_vm/nvm2.jpg diff --git a/docs/en-us/tooldev/images/tx_execution/.gitignore b/docs/en-us/basic/images/tx_execution/.gitignore similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/.gitignore rename to docs/en-us/basic/images/tx_execution/.gitignore diff --git a/docs/en-us/tooldev/images/tx_execution/formula_gas.jpg b/docs/en-us/basic/images/tx_execution/formula_gas.jpg similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/formula_gas.jpg rename to docs/en-us/basic/images/tx_execution/formula_gas.jpg diff --git a/docs/en-us/tooldev/images/tx_execution/tx_claim_gas.jpg b/docs/en-us/basic/images/tx_execution/tx_claim_gas.jpg similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/tx_claim_gas.jpg rename to docs/en-us/basic/images/tx_execution/tx_claim_gas.jpg diff --git a/docs/en-us/tooldev/images/tx_execution/tx_flow_graph.jpg b/docs/en-us/basic/images/tx_execution/tx_flow_graph.jpg similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/tx_flow_graph.jpg rename to docs/en-us/basic/images/tx_execution/tx_flow_graph.jpg diff --git a/docs/en-us/tooldev/images/tx_execution/tx_p2p_flow.jpg b/docs/en-us/basic/images/tx_execution/tx_p2p_flow.jpg similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/tx_p2p_flow.jpg rename to docs/en-us/basic/images/tx_execution/tx_p2p_flow.jpg diff --git a/docs/en-us/tooldev/images/tx_execution/tx_process_flow.jpg b/docs/en-us/basic/images/tx_execution/tx_process_flow.jpg similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/tx_process_flow.jpg rename to docs/en-us/basic/images/tx_execution/tx_process_flow.jpg diff --git a/docs/en-us/tooldev/images/tx_execution/tx_process_flow_en.jpg b/docs/en-us/basic/images/tx_execution/tx_process_flow_en.jpg similarity index 100% rename from docs/en-us/tooldev/images/tx_execution/tx_process_flow_en.jpg rename to docs/en-us/basic/images/tx_execution/tx_process_flow_en.jpg diff --git a/docs/en-us/tooldev/images/wallets/account_address_script_checksign.png b/docs/en-us/basic/images/wallets/account_address_script_checksign.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/account_address_script_checksign.png rename to docs/en-us/basic/images/wallets/account_address_script_checksign.png diff --git a/docs/en-us/tooldev/images/wallets/account_address_script_multi_checksign.png b/docs/en-us/basic/images/wallets/account_address_script_multi_checksign.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/account_address_script_multi_checksign.png rename to docs/en-us/basic/images/wallets/account_address_script_multi_checksign.png diff --git a/docs/en-us/tooldev/images/wallets/nep2key.png b/docs/en-us/basic/images/wallets/nep2key.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/nep2key.png rename to docs/en-us/basic/images/wallets/nep2key.png diff --git a/docs/en-us/tooldev/images/wallets/privateKey-wif-en.png b/docs/en-us/basic/images/wallets/privateKey-wif-en.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/privateKey-wif-en.png rename to docs/en-us/basic/images/wallets/privateKey-wif-en.png diff --git a/docs/en-us/tooldev/images/wallets/privateKey-wif.png b/docs/en-us/basic/images/wallets/privateKey-wif.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/privateKey-wif.png rename to docs/en-us/basic/images/wallets/privateKey-wif.png diff --git a/docs/en-us/tooldev/images/wallets/privatekey-2-publickey-address.png b/docs/en-us/basic/images/wallets/privatekey-2-publickey-address.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/privatekey-2-publickey-address.png rename to docs/en-us/basic/images/wallets/privatekey-2-publickey-address.png diff --git a/docs/en-us/tooldev/images/wallets/wif_format.png b/docs/en-us/basic/images/wallets/wif_format.png similarity index 100% rename from docs/en-us/tooldev/images/wallets/wif_format.png rename to docs/en-us/basic/images/wallets/wif_format.png diff --git a/docs/en-us/basic/technology/neovm.md b/docs/en-us/basic/neovm.md similarity index 99% rename from docs/en-us/basic/technology/neovm.md rename to docs/en-us/basic/neovm.md index 72e0c1712..a407f3643 100644 --- a/docs/en-us/basic/technology/neovm.md +++ b/docs/en-us/basic/neovm.md @@ -14,7 +14,7 @@ In addition, NeoVM is highly decoupled from the upper-level code and customizabl The NeoVM architecture is mainly composed of the execution engine, stack, and interoperation service layer. -![](../../assets/neovm.png) +![](../assets/neovm.png) #### ExecutionEngine diff --git a/docs/en-us/basic/technology/neocontract.md b/docs/en-us/basic/technology/neocontract.md deleted file mode 100644 index 3c87e1498..000000000 --- a/docs/en-us/basic/technology/neocontract.md +++ /dev/null @@ -1,254 +0,0 @@ -# NeoContract White Paper - -## Preface - -Smart contracts refer to any computer program which can automatically execute the terms of its preprogrammed contract. The idea of smart contract was first proposed by the cryptographer Nick Szabo in 1994, making it as old as the Internet itself. Due to the lack of a reliable execution environment, smart contracts have not been widely used. - -In 2008, a man under the name of Satoshi Nakamoto released Bitcoin, and outlined the foundational concepts of a blockchain. Within the Bitcoin blockchain, Nakamoto uses a set of scripting languages to help users gain more flexibility in controlling their personal accounts and the transfer process, which eventually became the embryonic form of a chain-based, smart contract system. - -In 2014, a teenager called Vitalik Buterin released Ethereum, which provides a chain-based, Turing-complete, smart contract system that can be used to create a variety of decentralized blockchain applications. - -NEO blockchain is a digital asset and application platform, which provides a new smart contract system, NeoContract. At the core of the NEO platform, the network provides multiples functions such as digital asset capabilities, NeoAsset, and digital identity, NeoID, allowing users to easily engage in digital businesses, and are no longer limited to just the issuance of native tokens on the blockchain. - -## Features - -### Certainty - -If a program is running on different computers, or at different times on the same computer, the behavior of the program is deterministic if the same input is guaranteed to produce the same output. - -Blockchain is a multi-party storage, and computational method, where the data within this distributed system is the result of reliable calculations, that cannot be tampered with. Smart contracts operate within the multi-node, distributed blockchain network. If a smart contract is non-deterministic, the results of different nodes may be inconsistent. As a result, consensus between the nodes cannot be reached, and the network becomes stagnant. Therefore, in the design of a smart contract system, there is a need to rule out any factors which may lead to non-deterministic behavior. - -#### Time - -Obtaining system-time is a very common system function, that may be heavily applied in certain time-sensitive contract procedures. However, obtaining system-time is a non-deterministic system function, and it is difficult to obtain a unified, precise time in a distributed system, as the results of different nodes will be inconsistent. NeoContract provides a block-based system-call that treats the entire blockchain, as a timestamp server, and obtains the timestamp whenever a new block is generated. On average, NEO network generates a new block every 15 seconds, so the contract runs at approximately the same time as the latest block-time, plus-minus 15 seconds. - -#### Randomness - -Many smart contract programs, such as gambling contracts and small games, use random number functions. However, random number functions are a typical non-deterministic function, and each system-call will obtain different results. In a distributed system, there are many ways to solve this problem: Firstly, the same random seed can be used for all nodes, so that the return sequence of the entire random function is deterministic, but this method exposes the entire random result in advance, greatly reducing the practical value of the random number. Another possible solution, is to let all nodes communicate in a collaborative way to generate random numbers. This can be achieved by using cryptographic techniques to produce a fair random number, but the disadvantage lies in the very poor performance, and need for additional communication overhead. A centralized random number provider can be used to generate random numbers which guarantees consistency and performance, but the drawback of this approach is obvious; Users will have to unconditionally trust the centralized number provider. - -There are two ways to generate a random number in NEO: - -1. When each block is generated, the consensus node will reach a consensus on a random number, and fill it into the Nonce field of the new block. The contract program can easily obtain the random number of any block, by referencing the Nonce field - -2. The contract program can use the hash value of the block as a random number generator, because the block hash value has certain inherent randomness. This method can be used to obtain a weak random number - -#### Data Source - -If a program obtains data at run-time, it might become a non-deterministic program if the data source provides non-deterministic data. For example, using different search engines to obtain the top 10 search results for a particular keyword, may yield different results, in various sort orders, if different IP addresses are used. - -For smart contracts, NEO provides two types of deterministic data sources: - -- **Blockchain Ledger** - - The contract procedure can access all data on the entire chain through interoperable services, including complete blocks and transactions, and each of their fields. The data on the blocks are deterministic and consistent, so they can be securely accessed by smart contracts. - -- **Contract Storage Space** - - Each contract deployed on the NEO network, has a private storage area that can only be accessed by the contract itself. NEO consensus mechanism ensures consistency of the storage status, of each node in the network. - -For situations where access to non-blockchain data is required, NEO does not provide a direct way to interact with these data. Non-blockchain data will have to be transferred to the NEO blockchain using transactions, and subsequently translated into the either of the aforementioned data sources, in order to become accessible by the smart contracts. - -#### Contract Call - -Smart contracts in NeoContract can call each other, but not be recursively called. Recursion can be achieved within the contract, but it cannot cross the boundaries of the current contract. In addition, the call relationship between contracts must be static: The target cannot be specified at runtime. This allows the behavior of the program to be fully determined before execution, and its call relationship to be fully defined before it can run. Based on this, multiple contracts can be dynamically partitioned to achieve parallel execution. - -### High Performance - -The execution environment of a smart contract plays an integral role in its performance. When we analyze the performance of any execution environment, there are main two indicators which are critical: - -1. Execution speed of the instruction -2. Startup speed of the execution environment itself - -For smart contracts, the execution environment is often more important than the speed of execution of the instruction. Smart contracts are more involved in IO operation of the logic, to determine the instructions, where the implementation of these instructions can easily be optimized. Every time the smart contract is called, it must start up a new virtual machine / container. Therefore, the execution speed of the environment itself (starting a virtual machine / container) has greater impact on the performance of the smart contract system. - -NEO uses a lightweight NeoVM (NEO Virtual Machine) as its smart contract execution environment, which has a very fast start up and takes up very little resources, perfect for short programs like smart contracts. Using the compilation and caching of hotspot smart contracts with JIT (real-time compiler) can significantly improve the efficiency of virtual machines. - -### Scalability - -#### High concurrency and dynamic partitioning - -When discussing the scalability of a system, it involves two main areas: Vertical scaling and horizontal scaling. Vertical scaling refers to the optimization of the processing workflow, allowing the system to take full advantage of existing equipment capacity. With this approach, limits of the system are easily reached, as series-based processing capacity is based on the hardware limit of a single device. When we need to scale the system, is there a way to transform the series system into a parallel system? Theoretically, we will only need to increase the number of devices, and we will be able to achieve almost unlimited scalability. Could we possibly achieve unlimited scaling in distributed blockchain networks? In other words, can the blockchain execute programs in parallel? - -The blockchain is a distributed ledger, that records a variety of state data and the rules governing the changes in state of these data. Smart contracts are used as carriers, to record these rules. Blockchains can process programs in parallel, only if, multiple smart contracts can be executed concurrently and in a non-sequential manner. Basically, if contracts do not interact with each other, or if the contract does not modify the same state data, at the same time, their execution is non-sequential and can be executed concurrently. Otherwise, it can only execute in series, following a sequential order, and the network is unable to scale horizontally. - -Based on the analysis above, we can easily design "unlimited scaling" in smart contract systems. All we must do is to set up simple rules: - - * **A smart contract can only modify the state record of the contract that it belongs to** - - * **In the same transaction batch (block), a contract can only be running once** - -As a result, all the smart contracts can be processed in parallel as sequential order is irrelevant to the result. However, if a "smart contract can only modify the state record of the contract that it belongs to", it implies that the contract cannot call each other. Each contract, is an isolated island; if "In the same transaction batch (block), a contract can only be running once", this implies that a digital asset issued with a smart contract, can only handle one transaction per block. This is a world of difference with the original design goals of "smart" contracts, which cease to be "smart". After all, our design goals include both mutual call between contracts, and multiple execution of the same call, in the same block. - -Fortunately, smart contracts in NEO have a static call relationship, and the call target cannot be specified at run time. This allows the behavior of the program to be fully determined before execution, and its call relationship to be fully defined before it can run. We require that each contract explicitly indicate the contracts which are likely to be invoked, so that the operating environment can calculate the complete call tree before running the contract procedure, and partition execution of the contracts, based on the call tree. Contracts that may modify the same state record, are executed in a sequential manner within the same partition, whereby different partitions can then be executed in parallel. - -#### Low coupling - -Coupling is a measure of the dependency between two or more entities. NeoContract system uses a low-coupling design, which is executed in the NEOVM, and communicates with the non-blockchain data through the interoperable service layer. As a result, most upgrades to smart contract functions can be achieved by increasing the API of interoperable services. - -## Contract Use - -### Verification Contract - -Unlike the public-key account system used in Bitcoin, NEO's account system uses the contract account system. Each account in the NEO corresponds to a verification contract, and the hash value of the verification contract, is the account address; The program logic of the verification contract controls the ownership of the account. When transferring from an account, you firstly need to execute the verification contract for that account. A validation contract can accept a set of parameters (usually a digital signature or other criteria), and return a boolean value after verification, indicating the success of the verification to the system. - -The user can deploy the verification contract to the blockchain beforehand, or publish the contract content directly in the transaction during the transfer process. - -### Application Contract - -The application contract is triggered by a special transaction, which can access and modify the global state of the system, and the private state of the contract (storage area) at run time. For example, you can create a global digital asset in a contract, vote, save data, and even dynamically create a new contract, when the contract is running. - -The execution of the application contract requires charging by instruction. When the transaction fee is consumed, the contract will fail and stop execution, and all state changes will be rolled back. The success of the contract does not affect the validity of the transaction. - -### Function Contract - -The function contract is used to provide some public or commonly used functions, which can be called by other contracts. The smart contract code can be reused, so that developers are able to write increasingly complex business logic. Each function contract, when deployed, can choose to have a private storage area that is either read or written to data in a future contract, achieving state persistence. - -The function contract must be pre-deployed to the chain to be invoked, and removed from the chain by a "self-destructing" system function, which will no longer be used and its private storage will be destroyed. The old contract data can be automatically migrated to another subcontract before it is destroyed, using contract migration tools. - -## Virtual Machine - -### Virtual Hardware - -NEOVM provides a virtual hardware layer, to support the execution of smart contracts, including: - - * **CPU** - - CPU is responsible for reading and sequentially order the execution of instructions in the contract, according to the function of the instruction flow control, arithmetic operations, logic operations. The future of the CPU function can be extended, with the introduction of JIT (real-time compiler) function, thereby enhancing the efficiency instruction execution. - - * **Call Stack** - - The call stack is used to hold the context information of the program execution at each function call, so that it can continue to execute in the current context after the function has finished executing and returning. - - * **Calculate Stack** - - All NEOVM run-time data are stored in the calculation stack, when after the implementation of different instructions, the stack will be calculated on the corresponding data elements of the operation. For example, when additional instructions are executed, the two operations participating in the addition are ejected from the calculation stack, and the result of the addition is pushed to the top of the stack. Function call parameters must also be calculated from right to left, according to the order of the stack. After the function is successfully executed, the top of the stack fetch-function returns the value. - - * **Spare Stack** - - When you need to schedule or rearrange elements in the stack, you can temporarily store the elements in the spare stack and retrieve them in the future. - -### Instruction Set - -NEOVM provides a set of simple, and practical instructions for building smart contract programs. According to functions, the main categories are as follows: - - * Constant instruction - * Process control instruction - * Stack operation instruction - * String instruction - * Logic instruction - * Arithmetic operation instruction - * Cryptographic instruction - * Data operation instruction - -It is worth noting that the NeoVM instruction set provides a series of cryptographic instructions, such as ECDSA, SHA and other algorithms to optimize the implementation efficiency of cryptographic algorithms in smart contracts. In addition, data manipulation instructions directly support arrays and complex data structures. - -### Interoperable Service Layer - -The virtual machine where smart contract executes is a sandbox environment, that requires an interoperable service layer, in times when it needs to access data outside of the sandbox or to keep the run-time data persistent. Within the interoperable service layer, NEO contract can open a series of system function and services with the smart contract program, and these contracts can be called and accessed, like ordinary functions. All system functions are being conducted concurrently, so there is no need to worry about scalability. - -### Debugging Function - -Often, the development of smart contracts is very difficult, due to the lack of good debugging and testing methods. NeoVM provides program debugging support at the virtual machine level, where you can set the breakpoint on the contract code, or single-step, single-process execution. Thanks to the low coupling design between the virtual machine and the blockchain, it is easy to integrate NeoVM directly with various IDEs, to provide a test environment that is consistent with the final production environment. - -## High-level Languages - -### C#, VB.Net, F# - -Developers can use NeoContract for almost any high-level language they are good at. The first batch of supported languages ​​are C #, VB.Net, F #, etc. We provide compilers and plug-ins for these languages, ​​allowing compilation of these high-level language into the instruction set, supported by NeoVM. As the compiler focus on MSIL (Microsoft intermediate language) during compilation, so theoretically, any .NET language can be translated into MSIL language, and become directly supported. - -A huge number of developers are proficient in these languages, and the above languages have very strongly integrated development environments. Developers can develop, generate, test and debug, all within Visual Studio, where they are able to take full advantage of the smart contract development templates we provide, to gain a head start. - -### Java, Kotlin - -Java and Kotlin ​​forms the second batch of supported languages, where we provide compilers and IDE plugins for these languages, ​​to help developers use the JVM-based language to develop NEO's Smart Contract applications. - -Java is widely used, and Kotlin has recently become the official Google recommended, Android-development language. We believe that supporting these languages will help drastically increase the number of NEO smart contract developers. - -### Other Languages - -Afterwards, NeoContract will add support for other high-level languages, based on the degree of difficulty, in the complier development process. Some of the languages that may be supported, include: - - * C, C++, GO - * Python, JavaScript - -In the future, we will continue to add more high-level language support. Our goal is to see more than 90% of NEO developers developing with NeoContract, without needing to learn a new language, and even possibly transfer existing business system code directly onto the blockchain. - -## Service - -### Blockchain Ledger - -NEO Smart Contracts can obtain complete block data for the NEO blockchain, including complete blocks and transactions, and each of their fields, at runtime, through the system functions provided by the interoperable service. Specifically, you can query these data: - - * Height of the blockchain - * Block head, current block - * Transactions - * Type of transaction, attributes, input, output, etc. - -Through these data, you can develop some interesting applications, such as automatic payouts, smart contracts based upon proof of workload. - -### Digital Assets - -Through the interoperable services provided by the digital asset interface, smart contracts not only can query the NEO blockchain on properties and statistics of various digital assets, but also, create new digital assets during its run-time. Digital assets created by smart contracts can be issued, transferred, traded outside of the contract. They are the same as original assets on NEO, and can be managed with any NEO-compatible, wallet software. This specific interface includes: - - * Asset attribute inquiry - * Asset statistics query - * Asset life cycle management: create, modify, destroy, etc. - * Asset management: multi-language name, total change, precision change, changes in the administrator - -### Persistence - -Each smart contract program deployed on the NEO blockchain, will have a private storage area that can only be read and written by the contract itself. Smart contracts have full operational permissions on the data in its own store: can be read, written, modified, deleted. The data is stored in the form of key-value pairs and provides these interfaces: - - * Traverse all the records stored - * Return to a specific record according to the specified key - * Modify or write new records according to the specified key - * Delete the record according to the specified key - -In general, a contract can only read and write data from its own store, with one exception: when a contract is invoked, the invoked contract can access the caller's store through a cross-domain request, provided that the caller provides authorization. In addition, for a sub-contract that is dynamically created at the time of contract execution, the parent contract gets instant access to its store. - -Cross-domain requests enable NeoContract to implement rich library capabilities, that provide highly scalable data management capabilities for the callers. - -## Fees - -### Deployment Fee - -NEO's distributed architecture provides high redundancy of storage capacity, and the use of this capacity is not free. Deploying a smart contract on the NEO network requires a fee, which currently oscillates between 100 and 1000GAS depending on the capabilities required by the contract. This fee is collected by the system and recorded as a system gain. Future fees will be adjusted according to the actual operating cost in the system. The smart contract deployed on the blockchain can be used multiple times, until the contract is destroyed by the deployer. - -### Implementation Fee - -NEO provides a credible execution environment for smart contracts, and the execution of contracts requires the consumption of computing resources for each node, therefore users are required to pay for the execution of smart contracts. The fee is determined by the computational resources consumed with each execution, and the unit price is also in GAS. If the implementation of the smart contract fails due to lack of GAS, the cost of consumption will not be returned, and this prevents malicious attacks on the network power consumption. - -For most simple contracts, they can be executed for free, so long as the execution costs remain under 10 GAS, thus greatly reducing costs for the user. - -## Application Scenarios - -### Superconducting Transactions - -Digital assets on the blockchain inherently require some form of liquidity and usually point-to-point transactions cannot provide it sufficiently. Therefore, there is a need for exchanges to provide users with trading services. Digital asset exchanges can be broadly divided into two categories: - -1. **Central exchanges:** where the user needs to deposit the digital assets with the exchange, and subsequent place pending orders for trading, on the website -2. **Decentralized exchanges:** where its trading system is built into the blockchain, and the system provides the matching services. - -Centralized exchanges can provide very high performance and diversified services, but need to have a strong credit guarantee, otherwise there will be moral hazards; such as misappropriation of user funds, fraud, etc. Comparatively, decentralized exchange has no moral hazard, but the user experience is poor, and there is greater performance bottleneck. Is there a way to combine both solutions and achieve the best of both worlds? - -Superconducting transactions is a mechanism that can do this; Users do not need to deposit assets, where they are able to use their own assets on the blockchain in trading. Transaction settlement complete on the blockchain, but the process of matching orders occurs off-chain, by a central exchange that provides matching services. Since the matching is conducted off-chain, its efficiency is like centralized exchanges, but the assets remain under the control of the user. Exchanges uses the user's trading intent to carry out matching services, with no moral hazards involved, such as misappropriation of user funds, fraud, etc. - -At present, within the NEO community, development of smart contracts to achieve blockchain superconducting transactions has emerged, such as OTCGO. - -### Cross-chain Interoperability - -In the foreseeable future, there will be many public chains and thousands of alliance chains or private chains in existence worldwide. These isolated blockchain systems are islands of value and information, which are not interoperable with each other. Through the cross-chain interoperability mechanism, numerous isolated blockchains can be linked, so that the values in different blockchains can be exchanged with each other, to achieve the true value of the Internet. - -NeoContract provides support for the implementation of cross-chain interoperability, ensuring consistency within cross-chain asset exchange, cross-chain distributed transactions, and execution of smart contracts on different blockchains. - -### Oracle Machines - -The concept of oracles in folktale lies in the ability of a certain supernatural entity that can answer a particular set of questions. In the blockchain, oracle machines open the door to the outside world for smart contracts, making it possible for smart contracts to use real-world information as a condition for contract execution. - -NeoContract does not provide the ability to directly access external data, such as access to resources on the Internet, because this will introduce non-deterministic behavior, resulting in inconsistencies between nodes during contract execution. Implementing the oracle machine in NeoContract requires that external data be sent to the blockchain by a trusted third party, integrating these data feeds as part of the blockchain ledger, thereby eliminating non-determinism. - -The credible third party mentioned above, may be a person or institution that is co-trusted by both parties in the contract, or a decentralized data provider that is guaranteed by economic incentives. In this manner, NeoContract can be used in the implementation of such Oracle machines. - -### Ethereum DAPP - -Bitcoin created the era of blockchains and electronic cash, and Ethereum created the era of smart contracts. Ethereum, the pioneers of smart contract on the blockchain, has made great contributions to the design idea, economic model and technological realization of a smart contract system. At the same time, the Ethereum platform has seen many DAPPs (distributed applications), where functionalities including: gambling agreements, digital assets, electronic gold, gaming platform, medical insurance, marriage platform, with widespread use over many industries. In theory, all of these DAPPs can be easily transplanted onto the NeoContract platform, as a NEO application. diff --git a/docs/en-us/sc/assets/2017-05-10_13-45-48.jpg b/docs/en-us/develop/assets/2017-05-10_13-45-48.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_13-45-48.jpg rename to docs/en-us/develop/assets/2017-05-10_13-45-48.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_13-47-10.jpg b/docs/en-us/develop/assets/2017-05-10_13-47-10.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_13-47-10.jpg rename to docs/en-us/develop/assets/2017-05-10_13-47-10.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_15-38-46.jpg b/docs/en-us/develop/assets/2017-05-10_15-38-46.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_15-38-46.jpg rename to docs/en-us/develop/assets/2017-05-10_15-38-46.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_15-50-48.jpg b/docs/en-us/develop/assets/2017-05-10_15-50-48.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_15-50-48.jpg rename to docs/en-us/develop/assets/2017-05-10_15-50-48.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_16-08-48.jpg b/docs/en-us/develop/assets/2017-05-10_16-08-48.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_16-08-48.jpg rename to docs/en-us/develop/assets/2017-05-10_16-08-48.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_16-25-09.jpg b/docs/en-us/develop/assets/2017-05-10_16-25-09.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_16-25-09.jpg rename to docs/en-us/develop/assets/2017-05-10_16-25-09.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_16-27-40.jpg b/docs/en-us/develop/assets/2017-05-10_16-27-40.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_16-27-40.jpg rename to docs/en-us/develop/assets/2017-05-10_16-27-40.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_16-28-39.jpg b/docs/en-us/develop/assets/2017-05-10_16-28-39.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_16-28-39.jpg rename to docs/en-us/develop/assets/2017-05-10_16-28-39.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_16-31-55.jpg b/docs/en-us/develop/assets/2017-05-10_16-31-55.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_16-31-55.jpg rename to docs/en-us/develop/assets/2017-05-10_16-31-55.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_18-22-39.jpg b/docs/en-us/develop/assets/2017-05-10_18-22-39.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_18-22-39.jpg rename to docs/en-us/develop/assets/2017-05-10_18-22-39.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_18-37-05.jpg b/docs/en-us/develop/assets/2017-05-10_18-37-05.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_18-37-05.jpg rename to docs/en-us/develop/assets/2017-05-10_18-37-05.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_18-46-05.jpg b/docs/en-us/develop/assets/2017-05-10_18-46-05.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_18-46-05.jpg rename to docs/en-us/develop/assets/2017-05-10_18-46-05.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_18-48-11.jpg b/docs/en-us/develop/assets/2017-05-10_18-48-11.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_18-48-11.jpg rename to docs/en-us/develop/assets/2017-05-10_18-48-11.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_18-52-10.jpg b/docs/en-us/develop/assets/2017-05-10_18-52-10.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_18-52-10.jpg rename to docs/en-us/develop/assets/2017-05-10_18-52-10.jpg diff --git a/docs/en-us/sc/assets/2017-05-10_9-48-54.jpg b/docs/en-us/develop/assets/2017-05-10_9-48-54.jpg similarity index 100% rename from docs/en-us/sc/assets/2017-05-10_9-48-54.jpg rename to docs/en-us/develop/assets/2017-05-10_9-48-54.jpg diff --git a/docs/en-us/sc/assets/dyn02.PNG b/docs/en-us/develop/assets/dyn02.PNG similarity index 100% rename from docs/en-us/sc/assets/dyn02.PNG rename to docs/en-us/develop/assets/dyn02.PNG diff --git a/docs/en-us/sc/assets/dyn03.png b/docs/en-us/develop/assets/dyn03.png similarity index 100% rename from docs/en-us/sc/assets/dyn03.png rename to docs/en-us/develop/assets/dyn03.png diff --git a/docs/en-us/sc/assets/dyn04.png b/docs/en-us/develop/assets/dyn04.png similarity index 100% rename from docs/en-us/sc/assets/dyn04.png rename to docs/en-us/develop/assets/dyn04.png diff --git a/docs/en-us/sc/assets/dyncallx.png b/docs/en-us/develop/assets/dyncallx.png similarity index 100% rename from docs/en-us/sc/assets/dyncallx.png rename to docs/en-us/develop/assets/dyncallx.png diff --git a/docs/en-us/sc/assets/gasflow_en.png b/docs/en-us/develop/assets/gasflow_en.png similarity index 100% rename from docs/en-us/sc/assets/gasflow_en.png rename to docs/en-us/develop/assets/gasflow_en.png diff --git a/docs/en-us/sc/assets/mac2.png b/docs/en-us/develop/assets/mac2.png similarity index 100% rename from docs/en-us/sc/assets/mac2.png rename to docs/en-us/develop/assets/mac2.png diff --git a/docs/en-us/sc/assets/mac8.png b/docs/en-us/develop/assets/mac8.png similarity index 100% rename from docs/en-us/sc/assets/mac8.png rename to docs/en-us/develop/assets/mac8.png diff --git a/docs/en-us/sc/assets/migrate_m1.png b/docs/en-us/develop/assets/migrate_m1.png similarity index 100% rename from docs/en-us/sc/assets/migrate_m1.png rename to docs/en-us/develop/assets/migrate_m1.png diff --git a/docs/en-us/sc/assets/migrate_m2.png b/docs/en-us/develop/assets/migrate_m2.png similarity index 100% rename from docs/en-us/sc/assets/migrate_m2.png rename to docs/en-us/develop/assets/migrate_m2.png diff --git a/docs/en-us/sc/assets/migrate_m3.png b/docs/en-us/develop/assets/migrate_m3.png similarity index 100% rename from docs/en-us/sc/assets/migrate_m3.png rename to docs/en-us/develop/assets/migrate_m3.png diff --git a/docs/en-us/sc/assets/migrate_m4.png b/docs/en-us/develop/assets/migrate_m4.png similarity index 100% rename from docs/en-us/sc/assets/migrate_m4.png rename to docs/en-us/develop/assets/migrate_m4.png diff --git a/docs/en-us/sc/assets/migrate_m5.png b/docs/en-us/develop/assets/migrate_m5.png similarity index 100% rename from docs/en-us/sc/assets/migrate_m5.png rename to docs/en-us/develop/assets/migrate_m5.png diff --git a/docs/en-us/dapp/assets/structure.png b/docs/en-us/develop/dapp/assets/structure.png similarity index 100% rename from docs/en-us/dapp/assets/structure.png rename to docs/en-us/develop/dapp/assets/structure.png diff --git a/docs/en-us/dapp/integ.md b/docs/en-us/develop/dapp/integ.md similarity index 99% rename from docs/en-us/dapp/integ.md rename to docs/en-us/develop/dapp/integ.md index 0ab25c6fe..69de0b6d2 100644 --- a/docs/en-us/dapp/integ.md +++ b/docs/en-us/develop/dapp/integ.md @@ -89,6 +89,3 @@ These wallets or wallet plugins support DAPI: NEO·ONE provides comprehensive documentation, learning courses, and tutorials. For more information refer to [NEO·ONE website]( https://neo-one.io/ ). -## What's next? - -[A DApp Development Demo](demo.md) \ No newline at end of file diff --git a/docs/en-us/dapp/intro.md b/docs/en-us/develop/dapp/intro.md similarity index 83% rename from docs/en-us/dapp/intro.md rename to docs/en-us/develop/dapp/intro.md index 167c93edd..472146732 100644 --- a/docs/en-us/dapp/intro.md +++ b/docs/en-us/develop/dapp/intro.md @@ -9,22 +9,18 @@ Generally, the process of developing a DApp is: Given that development and deployment of smart contracts on Neo charges a certain amount of Gas fee, it is recommended that developers set up their own private chain or use test net where they can operate more flexibly with plenty of test tokens. You can choose one of the following way: - [Set up a Neo private chain](../network/private-chain/solo.md); - - [Use Neo-local to set up a local network](../network/private-chain/neolocal.md); - [Use Neo test net](../network/testnet.md) - + 2. Run a Neo node - Neo provides two nodes, command line and user interface, for different developers to choose. For more information, see [Neo nodes](../node/introduction.md) + Neo provides two nodes, command line and user interface, for different developers to choose. For more information, see [Neo nodes](../../node/introduction.md) 3. Develop your smart contract - Smart contracts implement the core function logic of DApp. Refer to [Smart Contract Development](../sc/gettingstarted/introduction.md) to complete your contracts. + Smart contracts implement the core function logic of DApp. Refer to [Smart Contract Development](../../gettingstarted/prerequisites.md) to complete your contracts. 4. Integrate your DApp with blockchain After completing the development, testing and deployment of your smart contract, you need to proceed with the front-end integration development to enable the interaction between DApp and the block chain. -## What's next - -[DApp Integration](integ.md) \ No newline at end of file diff --git a/docs/en-us/develop/deploy/Parameter.md b/docs/en-us/develop/deploy/Parameter.md new file mode 100644 index 000000000..5976eb594 --- /dev/null +++ b/docs/en-us/develop/deploy/Parameter.md @@ -0,0 +1,64 @@ +# Smart Contract Parameters and Return Values + +In the smart contract deployment or invocation, you need to specify the parameters of the smart contract. Smart contract parameters are byte types, defined as follows. + +```c# +/// +/// Indicates the parameter type of the smart contract +/// +public enum ContractParameterType : byte +{ + Any = 0x00, + + Boolean = 0x10, + /// + /// Integer + /// + Integer = 0x11, + /// + /// byte array + /// + ByteArray = 0x12, + String = 0x13, + /// + /// 160-bit hash value + /// + Hash160 = 0x14, + /// + /// 256-bit hash value + /// + Hash256 = 0x15, + PublicKey = 0x16, + /// + /// Signature + /// + Signature = 0x17, + + /// + /// object array + /// + Array = 0x20, + Map = 0x22, + + InteropInterface = 0x30, + + Void = 0xff + +} +``` + +For example, for the smart contract below: + +```c# +public class Lock : SmartContract +{ + public static bool Main(int a, bool b, byte[] pubkey, byte[] signature) + { + // more... + } +} +``` + +Using the enum above, int is represented as 0x11, bool as 0x10,public key as 0x16 and signature as 0x17. + +When filling in parameters through the Neo-GUI client, use 2 hexadecimal characters for each parameter. Thus, the arguments for the above function is written as : 11101617, return: 10. \ No newline at end of file diff --git a/docs/en-us/sc/deploy/deploy.md b/docs/en-us/develop/deploy/deploy.md similarity index 73% rename from docs/en-us/sc/deploy/deploy.md rename to docs/en-us/develop/deploy/deploy.md index 1bb7f312d..30ec9486d 100644 --- a/docs/en-us/sc/deploy/deploy.md +++ b/docs/en-us/develop/deploy/deploy.md @@ -1,22 +1,22 @@ # Deploying Smart Contracts -When a smart contract is deployed on the blockchain, it can be used by other users or invoked by other contracts. This section describes how to deploy and invoke the smart contract in the NEO blockchain using Neo-CLI or Neo-GUI. The instructions in this section are generic and applicable to all contract types including NEP-5 assets. +When a smart contract is deployed on the blockchain, it can be used by other users or invoked by other contracts. This section describes how to deploy and invoke the smart contract in the Neo blockchain using Neo-CLI or Neo-GUI. The instructions in this section are generic and applicable to all contract types including NEP-5 assets. ## What contracts need to be deployed? -When a smart contract needs to store data or to be invoked by another smart contract (called appcall) on the blockchain, it needs to be deployed. Contracts triggered only by the verification trigger, such as the lock contract and multi-signature contract, do not need to be deployed as they will not be invoked by other contracts. Contracts such as `return 1+1` do not need to be deployed as they do not require any input parameters. +When a smart contract needs to store data or to be invoked by another smart contract through syscall `System.Contract.Call` on the blockchain, it needs to be deployed. Contracts triggered only by the verification trigger, such as the lock contract and multi-signature contract, do not need to be deployed as they will not be invoked by other contracts. Contracts such as `return 1+1` do not need to be deployed as they do not require any input parameters. From the programming language perspective, only when a smart contract will be used as a class library, it needs to be deployed. For example: -- When a smart contract has variable incoming parameters, it must serve as a storage. The caller (Invocation transaction) or other smart contracts provide the parameters. +- When a smart contract has variable incoming parameters, it must serve as a storage. The caller or other smart contracts provide the parameters. - When a smart contract uses storage it must serve as a class library. - When a smart contract implements NEP-5 standard assets, the contract needs to be deployed on the blockchain. ### How to deploy? -Smart contracts are deployed by invoking API through an Invocation transaction. Usually we use Neo-CLI or Neo-GUI to deploy smart contracts. +Smart contracts are deployed by invoking APIs. Usually we use Neo-CLI or Neo-GUI to deploy smart contracts. -Deploying and invoking smart contracts will cost fees. For more information, refer to [Fees](../fees.md). +Deploying and invoking smart contracts cost fees. For more information, refer to [Fees](../../reference/fees.md). ## Before you start Make sure you have done the following: diff --git a/docs/en-us/sc/deploy/invoke.md b/docs/en-us/develop/deploy/invoke.md similarity index 94% rename from docs/en-us/sc/deploy/invoke.md rename to docs/en-us/develop/deploy/invoke.md index b51b53377..14a230e8b 100644 --- a/docs/en-us/sc/deploy/invoke.md +++ b/docs/en-us/develop/deploy/invoke.md @@ -4,7 +4,7 @@ After you deployed a smart contract on the blockchain, you can then invoke it by ## Querying the contract details -You can query a contract details using Neo-CLI or Neo-GUI, such as the contract general information, entry point, methods, notifications, etc. +You can query a contract details using Neo-CLI or Neo-GUI, such as the contract general information, methods, notifications, etc. ### Querying using Neo-CLI @@ -26,7 +26,7 @@ You can choose one of the following ways to invoke the contract using Neo-CLI: - Use the command invoke, which syntax is: ``` - invoke [contractParameters=null] [witnessAddress=null] + invoke [contractParameters=null] [sender=null] [signerAccounts=null] ``` For more information refer to [invoke](../../node/cli/cli.md#invoke). @@ -58,7 +58,7 @@ When `Runtime.CheckWitness (owner)` is written in the contract, the owner's sign In Neo-CLI, you can attach a signature using the invoke command. ``` -invoke [contractParameters=null] [witnessAddress=null] +invoke [contractParameters=null] [sender=null] [signerAccounts=null] ``` When invoking a contract in Neo-GUI, you can click `Cosignature` at the bottom of the page, choose `Public key`, and then click `Sign` to add the signature. diff --git a/docs/en-us/sc/devenv/getting-started-csharp-mac.md b/docs/en-us/develop/devenv/getting-started-csharp-mac.md similarity index 95% rename from docs/en-us/sc/devenv/getting-started-csharp-mac.md rename to docs/en-us/develop/devenv/getting-started-csharp-mac.md index 2755ac38e..36db96a1b 100644 --- a/docs/en-us/sc/devenv/getting-started-csharp-mac.md +++ b/docs/en-us/develop/devenv/getting-started-csharp-mac.md @@ -22,7 +22,7 @@ Download [Visual Studio for Mac](https://www.visualstudio.com/vs/mac/) and follo 4. Search for `neo.smart` and choose `Neo.SmartContract.Framework`, then click `Add Packge`. - ![](../../../zh-cn/sc/assets/mac5.jpg) + ![](../../../zh-cn/develop/assets/mac5.jpg) 5. Write the following sample code in your Class1.cs file. @@ -64,13 +64,11 @@ Download [Visual Studio for Mac](https://www.visualstudio.com/vs/mac/) and follo 4. Publish neon to the default path. After published, you can find neon.dll is generated under the path. - - ## Compiling your smart contract to .avm 1. Download and install [.NET Core](https://www.microsoft.com/net/download/macos ). - ![](../../../zh-cn/sc/assets/mac8.jpg) + ![](../../../zh-cn/develop/assets/mac8.jpg) 2. Copy the new-created project file test.dll generated in previous steps into the directory where neon.dll locates in. @@ -78,6 +76,6 @@ Download [Visual Studio for Mac](https://www.visualstudio.com/vs/mac/) and follo The output should look like this - ![](../../../zh-cn/sc/assets/mac0.jpg) + ![](../../../zh-cn/develop/assets/mac0.jpg) You should now find the `.avm` file in the test output folder. \ No newline at end of file diff --git a/docs/en-us/sc/devenv/getting-started-csharp-ubuntu.md b/docs/en-us/develop/devenv/getting-started-csharp-ubuntu.md similarity index 100% rename from docs/en-us/sc/devenv/getting-started-csharp-ubuntu.md rename to docs/en-us/develop/devenv/getting-started-csharp-ubuntu.md diff --git a/docs/en-us/sc/devenv/getting-started-csharp.md b/docs/en-us/develop/devenv/getting-started-csharp.md similarity index 59% rename from docs/en-us/sc/devenv/getting-started-csharp.md rename to docs/en-us/develop/devenv/getting-started-csharp.md index bdd3dfb16..1a01816da 100644 --- a/docs/en-us/sc/devenv/getting-started-csharp.md +++ b/docs/en-us/develop/devenv/getting-started-csharp.md @@ -1,4 +1,4 @@ # How to write smart contracts in C# on Windows -For information about how to write smart contracts in C# on Windows, refer to [Compiling a contract sample](../gettingstarted/develop.md). +For information about how to write smart contracts in C# on Windows, refer to [Compiling a contract sample](../../gettingstarted/develop.md). diff --git a/docs/en-us/sc/devenv/getting-started-python.md b/docs/en-us/develop/devenv/getting-started-python.md similarity index 100% rename from docs/en-us/sc/devenv/getting-started-python.md rename to docs/en-us/develop/devenv/getting-started-python.md diff --git a/docs/en-us/network/assets/create-wallet.png b/docs/en-us/develop/network/assets/create-wallet.png similarity index 100% rename from docs/en-us/network/assets/create-wallet.png rename to docs/en-us/develop/network/assets/create-wallet.png diff --git a/docs/en-us/network/assets/initial-balance.png b/docs/en-us/develop/network/assets/initial-balance.png similarity index 100% rename from docs/en-us/network/assets/initial-balance.png rename to docs/en-us/develop/network/assets/initial-balance.png diff --git a/docs/en-us/network/assets/private_multi_tx1.png b/docs/en-us/develop/network/assets/private_multi_tx1.png similarity index 100% rename from docs/en-us/network/assets/private_multi_tx1.png rename to docs/en-us/develop/network/assets/private_multi_tx1.png diff --git a/docs/en-us/network/assets/private_multi_tx2.png b/docs/en-us/develop/network/assets/private_multi_tx2.png similarity index 100% rename from docs/en-us/network/assets/private_multi_tx2.png rename to docs/en-us/develop/network/assets/private_multi_tx2.png diff --git a/docs/en-us/network/assets/private_multi_tx3.png b/docs/en-us/develop/network/assets/private_multi_tx3.png similarity index 100% rename from docs/en-us/network/assets/private_multi_tx3.png rename to docs/en-us/develop/network/assets/private_multi_tx3.png diff --git a/docs/en-us/network/assets/privatechain_1.jpg b/docs/en-us/develop/network/assets/privatechain_1.jpg similarity index 100% rename from docs/en-us/network/assets/privatechain_1.jpg rename to docs/en-us/develop/network/assets/privatechain_1.jpg diff --git a/docs/en-us/network/assets/privatechain_3.jpg b/docs/en-us/develop/network/assets/privatechain_3.jpg similarity index 100% rename from docs/en-us/network/assets/privatechain_3.jpg rename to docs/en-us/develop/network/assets/privatechain_3.jpg diff --git a/docs/en-us/network/assets/solo.png b/docs/en-us/develop/network/assets/solo.png similarity index 100% rename from docs/en-us/network/assets/solo.png rename to docs/en-us/develop/network/assets/solo.png diff --git a/docs/en-us/network/private-chain/private-chain2.md b/docs/en-us/develop/network/private-chain/private-chain2.md similarity index 95% rename from docs/en-us/network/private-chain/private-chain2.md rename to docs/en-us/develop/network/private-chain/private-chain2.md index c1b04ee46..8eac5c22d 100644 --- a/docs/en-us/network/private-chain/private-chain2.md +++ b/docs/en-us/develop/network/private-chain/private-chain2.md @@ -6,7 +6,7 @@ In this document we will introduce a simple way to build a private chain on a wi Install Neo-CLI and make four copies of the node folder with the name of node1, node2, node3, and node4, successively. -For more information refer to [Installation of Neo-CLI](../../node/cli/setup.md). +For more information refer to [Installation of Neo-CLI](../../../node/cli/setup.md). ## Creating wallet files @@ -215,7 +215,7 @@ At this point the private chain has been set up. All the files we modified are Enter each node directory and double-click `Run.cmd`. When the screen shows consensus information and block height is increasing as shown below, the private chain is set up successfully. -![](../../../zh-cn/assets/privatechain_demo.png) +![](../../../../zh-cn/assets/privatechain_demo.png) The private chain is terminated if you close all the windows. @@ -276,7 +276,7 @@ Here we want to send NEO from the contract address to the normal address. 7. Use `list asset` to check the wallet balance: - ![image](../../assets/privatechain_32.png) + ![image](../../../assets/privatechain_32.png) Similarly, you can refer to the preceding steps to withdraw GAS from the multi-party signature address. @@ -284,7 +284,7 @@ Similarly, you can refer to the preceding steps to withdraw GAS from the multi-p #### Creating multi-party signature addresses -1. Refer to [Installing Neo-GUI](../../node/gui/install.md) to download and install Neo-GUI, and then connect it to our private chain. +1. Refer to [Installing Neo-GUI](../../../node/gui/install.md) to download and install Neo-GUI, and then connect it to our private chain. 2. Configure the file config.private.json to make sure the Neo-GUI port is not conflict with the one of Neo-CLI; otherwise, Neo-GUI cannot work as Neo-CLI is running. 3. Start Neo-GUI and open any of the four wallets. 4. Click `+` besides `Accounts` and select `Create Multi-signature Address`. @@ -299,6 +299,6 @@ Now you should see 100 million NEO and 30 million GAS displayed. 2. Enter the recipient address and the transfer amount. -3. Refer to [Signature](../../node/gui/advanced.html#signature) to complete the transaction. +3. Refer to [Signature](../../../node/gui/advanced.html#signature) to complete the transaction. Once the transfer transaction begins broadcasting it will take a while for successful remittance to the account. \ No newline at end of file diff --git a/docs/en-us/network/private-chain/solo.md b/docs/en-us/develop/network/private-chain/solo.md similarity index 94% rename from docs/en-us/network/private-chain/solo.md rename to docs/en-us/develop/network/private-chain/solo.md index 1bfb64e0b..2487cfdac 100644 --- a/docs/en-us/network/private-chain/solo.md +++ b/docs/en-us/develop/network/private-chain/solo.md @@ -6,11 +6,11 @@ Alternatively, you can build a private chain with one node from scratch, which w ## Prerequisites -1. Refer to [Installation of NEO-CLI](../../node/cli/setup.md) to install Neo-CLI. +1. Refer to [Installation of NEO-CLI](../../../node/cli/setup.md) to install Neo-CLI. 2. Run Neo-CLI and enter the command `create wallet ` to create a wallet, e.g. `create wallet consensus.json`: - ![](../../../zh-cn/network/assets/create-wallet.png) + ![](../../../../zh-cn/develop/network/assets/create-wallet.png) 3. Record the wallet pubkey that appears. This will be used in later steps. @@ -152,7 +152,7 @@ In the genesis block of the Neo network, 100 million NEO and 30 million GAS are ### Using Neo-GUI to withdraw -1. Refer to [Installing Neo-GUI](../../node/gui/install.md) to download and install Neo-GUI, and then connect it to our private chain. +1. Refer to [Installing Neo-GUI](../../../node/gui/install.md) to download and install Neo-GUI, and then connect it to our private chain. 2. Configure the file config.private.json to make sure the Neo-GUI port is not conflict with the one of Neo-CLI; otherwise, Neo-GUI cannot work as Neo-CLI is running. 3. Start Neo-GUI and open the wallet consensus.json. 4. Click `+` besides `Accounts` and select `Create Multi-signature address`. diff --git a/docs/en-us/network/testnet.md b/docs/en-us/develop/network/testnet.md similarity index 95% rename from docs/en-us/network/testnet.md rename to docs/en-us/develop/network/testnet.md index 84674b181..455fa91c5 100644 --- a/docs/en-us/network/testnet.md +++ b/docs/en-us/develop/network/testnet.md @@ -26,11 +26,11 @@ For Neo-CLI, since it connects to the main net that is not available yet by defa 1. Copy the contents of the program directory under the `protocol.testnet.json` into ` protocol.json` as shown. - ![image](../assets/testnet_1.png) + ![image](../../assets/testnet_1.png) 2. Copy the contents of the program directory `config.testnet.json` into the `config.json` as shown in Figure - ![image](../assets/testnet_2_v2.png) + ![image](../../assets/testnet_2_v2.png) ## Applying for Test GAS and Test NEO @@ -52,7 +52,7 @@ The PUBLIC KEY is shown when you view the PRIVATE KEY. (Never share your PRIVATE #### Step 2 - Fill in the request Complete the form here: https://neo.org/testcoin/apply. Note that you need to change `Neo Version` to Neo3. -After a day or so you will be sent an email containing a "Multi-party signed address" and the PUBLIC key of the sender. See [Multi-party signed address](../node/gui/sc.md). +After a day or so you will be sent an email containing a "Multi-party signed address" and the PUBLIC key of the sender. See [Signature](../../node/gui/advanced.md). #### Step 3 - Create a multi-party signed address To access the assets, in your Neo-gui you will create a "Multi-party signed address" in your wallet using diff --git a/docs/en-us/sc/sample/Domain.md b/docs/en-us/develop/sample/Domain.md similarity index 100% rename from docs/en-us/sc/sample/Domain.md rename to docs/en-us/develop/sample/Domain.md diff --git a/docs/en-us/sc/sample/HelloWorld.md b/docs/en-us/develop/sample/HelloWorld.md similarity index 100% rename from docs/en-us/sc/sample/HelloWorld.md rename to docs/en-us/develop/sample/HelloWorld.md diff --git a/docs/en-us/sc/sample/storage.md b/docs/en-us/develop/sample/storage.md similarity index 92% rename from docs/en-us/sc/sample/storage.md rename to docs/en-us/develop/sample/storage.md index 78af799ee..2b4ca16f6 100644 --- a/docs/en-us/sc/sample/storage.md +++ b/docs/en-us/develop/sample/storage.md @@ -2,9 +2,9 @@ ## What is a smart contract storage? -Each smart contract deployed on the Neo blockchain owns a private storage where only the contract itself can read, write, modify, and delete data. Data in the storage is stored in the form of key-value pairs, where Key can be a string or a byte array (ByteArray) and Value can be any type. For more information refer to [Storage Class](../reference/scapi/fw/dotnet/neo/Storage.md). +Each smart contract deployed on the Neo blockchain owns a private storage where only the contract itself can read, write, modify, and delete data. Data in the storage is stored in the form of key-value pairs, where Key can be a string or a byte array (ByteArray) and Value can be any type. For more information refer to [Storage Class](../../reference/scapi/fw/dotnet/neo/Storage.md). -In Neo, most storage operations are performed through [StorageMap](../reference/scapi/fw/dotnet/neo/StorageMap.md), which appends a prefix to the Storage Key. Different prefixes are equivalent to different database tables. Using StorageMap to operate the storage is more safely. +In Neo, most storage operations are performed through [StorageMap](../../reference/scapi/fw/dotnet/neo/StorageMap.md), which appends a prefix to the Storage Key. Different prefixes are equivalent to different database tables. Using StorageMap to operate the storage is more safely. Smart contract storage operations include the following interfaces: @@ -48,7 +48,7 @@ var Hash = Storage.CurrentContext.CreateMap("Hash"); ## Storage operations -Refer to the [Storage](../reference/scapi/fw/dotnet/neo/Storage.md) and [StorageMap](../reference/scapi/fw/dotnet/neo/StorageMap.md) classes. The class [Helper](../../reference/scapi/fw/dotnet/neo/Helper.md) provides StorageMap with extended methods for storage operations. Here are some code examples. +Refer to the [Storage](../../reference/scapi/fw/dotnet/neo/Storage.md) and [StorageMap](../../reference/scapi/fw/dotnet/neo/StorageMap.md) classes. The class [Helper](../../reference/scapi/fw/dotnet/neo/Helper.md) provides StorageMap with extended methods for storage operations. Here are some code examples. ### Write and modify diff --git a/docs/en-us/develop/tool/sdk/contract.md b/docs/en-us/develop/tool/sdk/contract.md new file mode 100644 index 000000000..46717a2ae --- /dev/null +++ b/docs/en-us/develop/tool/sdk/contract.md @@ -0,0 +1,219 @@ +# Deploying and Invoking Contracts + +In Neo3 most of the functions are provided by contracts. ScriptHash is the unique identifier of the contract, and it is usually a necessary parameter for invoking contracts. + +This document introduces the following SDK features: + +- The construction method of contract deployment transaction +- Invoking methods in the contract under read-only mode +- `Nep5API` class that encapsulates the methods for invoking NEP5 contracts + +## Contract deployment + +`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 +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 +await client.SendRawTransactionAsync(transaction); +Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); +``` + +After the transaction is added to the blockchain you can get the transaction execution status to check if the contract is deployed successfully: + +```c# +// print a message after the transaction is on chain +WalletAPI neoAPI = new WalletAPI(client); +await neoAPI.WaitTransactionAsync(transaction) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); +``` + +Here is the complete code: + +```c# +using Neo.Network.P2P.Payloads; +using Neo.Network.RPC; +using Neo.SmartContract; +using Neo.SmartContract.Manifest; +using Neo.Wallets; +using System; +using Neo.IO; +using System.IO; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + 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 = "sc/Contract1.nef"; + string manifestFilePath = "sc/Contract1.manifest.json"; + + // 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("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + + // create the deploy transaction + byte[] script = nefFile.Script; + Transaction transaction = await contractClient.CreateDeployContractTxAsync(script, manifest, senderKey).ConfigureAwait(false); + + // 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); + await neoAPI.WaitTransactionAsync(transaction) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} +``` + +## Contract invocation simulation + +`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://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 +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 the method `InvokeScriptAsync` in `RpcClient`to get the execution result. + +```c# +// 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 +RpcInvokeResult invokeResult = await client.InvokeScriptAsync(script).ConfigureAwait(false); +Console.WriteLine($"The name is {invokeResult.Stack.Single().GetString()}"); +``` + +## Contract invocation (on-chain transactions) + +Generally invoking a deployed contract on the blockchain contains the following steps: + +1. Construct the script to invoke + + Take the `transfer` method of native contract Neo as an example: + + ```c# + // 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, 1024); + ``` + +2. Construct the transaction: + + ```c# + // 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 + 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: + + ```c# + // 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}")); + ``` + +For complete code refer to [Transaction Construction](transaction.md). + +## NEP-5 Contracts + +`Nep5API` encapsulates the method that generates transfer transactions. The above transaction process can be simplified to: + +```c# +Nep5API nep5API = new Nep5API(client); +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 = await nep5API.NameAsync(NativeContract.NEO.Hash).ConfigureAwait(false); + +// get nep5 symbol +string symbol = await nep5API.SymbolAsync(NativeContract.NEO.Hash).ConfigureAwait(false); + +// get nep5 token decimals +byte decimals = await nep5API.DecimalsAsync(NativeContract.NEO.Hash).ConfigureAwait(false); + +// get nep5 token total supply +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/tooldev/sdk/introduction.md b/docs/en-us/develop/tool/sdk/introduction.md similarity index 92% rename from docs/en-us/tooldev/sdk/introduction.md rename to docs/en-us/develop/tool/sdk/introduction.md index ba0942fca..151a98f81 100644 --- a/docs/en-us/tooldev/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" @@ -61,8 +61,3 @@ Neo-modules:https://github.com/neo-project/neo-modules Welcome to raise any problems you encountered in practice in the project issue list: https://github.com/neo-project/neo-modules/issues - -## What's next? - -[RPC Invocation Methods](rpc.md) - diff --git a/docs/en-us/develop/tool/sdk/monitor.md b/docs/en-us/develop/tool/sdk/monitor.md new file mode 100644 index 000000000..1c658656a --- /dev/null +++ b/docs/en-us/develop/tool/sdk/monitor.md @@ -0,0 +1,79 @@ +# Getting Blockchain Information + +The `RPC` module provides methods to get basic information of blockchain data and status, such as block height, block content, transaction details, and contracts. + +For some specific information of contracts, such as the block maximum transaction number, system fee per byte, NEP-5 contract details, you need to invoke specific contract methods, which will be introduced in this document. + + +## Getting blockchain data from RPC interfaces + +Gets the latest block height or hash: + +```c# +// choose a neo node with rpc opened +RpcClient client = new RpcClient("http://127.0.0.1:10332"); + +// get the hash of the tallest block in the main chain +string hash = await client.GetBestBlockHashAsync().ConfigureAwait(false); + +// 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 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 = await client.GetBlockAsync("0x4e61cd9d76e30e9147ee0f5b9c92f4447decbe52c6c8b412d0382a14d3a0b408").ConfigureAwait(false); +``` + +Gets the contract script, hash, and manifest through `RpcClient`: + +```c# +// get NEO contract state +ContractState contractState = await client.GetContractStateAsync(NativeContract.NEO.Hash.ToString()).ConfigureAwait(false); +``` + +For more information refer to [RPC invocation methods](rpc.md). + +## Getting policy information + +Invokes the method `policyAPI` in the native contract `PolicyContract` to get the Policy related information: + +```c# +// choose a neo node with rpc opened +PolicyAPI policyAPI = new PolicyAPI(new RpcClient("http://127.0.0.1:10332")); + +// get the system fee per byte +long feePerByte = await policyAPI.GetFeePerByteAsync().ConfigureAwait(false); // 1000, 0.00001000 GAS per byte + +// get the max size of one block +uint maxBlockSize = await policyAPI.GetMaxBlockSizeAsync().ConfigureAwait(false); // 262144, (1024 * 256) bytes one block + +// get the max transaction count per 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 + +NEP5 is an asset standard for Neo3, such as NEO and GAS, both of which are assets based on NEP5 native contract. You can invoke `Nep5API` to get the name, mark, decimal place, and amount of the NEP5 contract. + +```c# +// get nep5 token info +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/tooldev/sdk/rpc.md b/docs/en-us/develop/tool/sdk/rpc.md similarity index 50% rename from docs/en-us/tooldev/sdk/rpc.md rename to docs/en-us/develop/tool/sdk/rpc.md index 19ce93e23..98cc02ec4 100644 --- a/docs/en-us/tooldev/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); ``` -### GetNep5Balances +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); +``` + +### 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,10 +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); ``` - -### What's next? - -[Getting Blockchain Data](monitor.md) - diff --git a/docs/en-us/develop/tool/sdk/transaction.md b/docs/en-us/develop/tool/sdk/transaction.md new file mode 100644 index 000000000..df860675a --- /dev/null +++ b/docs/en-us/develop/tool/sdk/transaction.md @@ -0,0 +1,310 @@ +# Transaction Construction + +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: + + ```c# + // construct the script, in this example, we will transfer 1 NEO to the receiver + UInt160 scriptHash = NativeContract.NEO.Hash; + byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); + ``` + +2. Construct `TransactionManagerFactory` with the parameters `RpcClient ` and `Magic `; Construct `TransactionManager` with the parameters `Script` and`Signers`: + + ```c# + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + ``` + +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); + ``` + - multiple signatures + + ```c# + // add multi-signatures for the transaction with sendKey + txManager.AddMultiSig(receiverKey, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); + 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. + + ```c# + // 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 + Transaction tx = await txManager.SignAsync().ConfigureAwait(false); + ``` + +## Transaction Construction Examples + +### Constructing an NEP5 transfer transaction + +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; +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"); + UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; + + // 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("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); + + // 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, 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. + 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); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} +``` + +`WalletAPI` encapsulates the above process, so you can simplify the NEP5 transfer as follows: + +```c# +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 + +The following example implements a function that transfers 10 GAS to a multi-signature account. The scripthash of a multi-signature account is obtained from the scripthash of the multi-signature contract. As the sender is a normal account, the process of adding a signature is the same as last example. + +```c# +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; +using Utility = Neo.Network.RPC.Utility; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + 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("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; + + // get the KeyPair of your accounts + 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 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, 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); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} +``` + +### Constructing a transaction to transfer from multi-signature account + +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; +using Neo.Network.P2P.Payloads; +using Neo.Network.RPC; +using Neo.SmartContract; +using Neo.SmartContract.Native; +using Neo.VM; +using Neo.Wallets; +using System; +using Utility = Neo.Network.RPC.Utility; + +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://127.0.0.1:10332"); + + // get the KeyPair of your account + 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); + // get the scripthash of the multi-signature Contract + UInt160 multiAccount = multiContract.Script.ToScriptHash(); + + UInt160 receiver = Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash; + + // 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); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} +``` + diff --git a/docs/en-us/tooldev/sdk/wallet.md b/docs/en-us/develop/tool/sdk/wallet.md similarity index 79% rename from docs/en-us/tooldev/sdk/wallet.md rename to docs/en-us/develop/tool/sdk/wallet.md index 1d8af34b7..1490ba54f 100644 --- a/docs/en-us/tooldev/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,13 +240,8 @@ 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); ``` -## What's next? -[Transaction Construction](transaction.md) diff --git a/docs/en-us/sc/write/basics.md b/docs/en-us/develop/write/basics.md similarity index 100% rename from docs/en-us/sc/write/basics.md rename to docs/en-us/develop/write/basics.md diff --git a/docs/en-us/sc/write/limitation.md b/docs/en-us/develop/write/limitation.md similarity index 100% rename from docs/en-us/sc/write/limitation.md rename to docs/en-us/develop/write/limitation.md diff --git a/docs/en-us/develop/write/migrate.md b/docs/en-us/develop/write/migrate.md new file mode 100644 index 000000000..212bb5723 --- /dev/null +++ b/docs/en-us/develop/write/migrate.md @@ -0,0 +1,49 @@ +# Contract Migration and Destruction + +Smart contracts support to be migrated or destroyed after release. Before you can do that you need to reserve the specific interfaces in the old contracts. + +## Contract Migration + +In some cases you want to upgrade the smart contracts deployed on the blockchain or migrate the storage of a contract into another new contract, you need to migrate smart contracts. + +### Implementing the Update interface +To enable migration function, you need to implement the update interface in the contract, as shown below: + +```c# +public static object Main(string method, params object[] args) +{ + ... + if (method == "update") return Update((byte[])args[0], (string)args[1]); + ... +} + +[DisplayName("update")] +public static bool Update(byte[] script, string manifest) +{ + if (!Runtime.CheckWitness(Owner)) return false; + Contract.Update(script, manifest); + return true; +} +``` + +If you want to migrate the contract later, you must implement the `update` interface in the contract prior to deployment. For more information, refer to [Deploying and Invoking Smart Contracts](../deploy/deploy.md). + +### Migrating the contract +Firstly, get your new contract ready and then invoke the `update` interface. + +For information about invoking the contract, refer to [Invoking contracts](../deploy/invoke.md). + +After the `update` interface is implemented, the contract storage is migrated to the new contract and the old contract is destroyed. + +## Contract Destruction + +To destroy a contract, you need to reserve the destruction interface in the contract. + +The contract destruction mainly calls the `Neo.Contract.Destroy` method: + +```c# +Contract.Destroy(); +``` + +The `Destroy` method accepts no parameters, and it will delete contract and the storage area. + diff --git a/docs/en-us/sc/write/nep5.md b/docs/en-us/develop/write/nep5.md similarity index 69% rename from docs/en-us/sc/write/nep5.md rename to docs/en-us/develop/write/nep5.md index d30db0342..9b0a82d93 100644 --- a/docs/en-us/sc/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/exchange/gas.md b/docs/en-us/exchange/gas.md index 144f9d40d..386327056 100644 --- a/docs/en-us/exchange/gas.md +++ b/docs/en-us/exchange/gas.md @@ -23,7 +23,7 @@ Claimed *GAS = f(neo_amount, Δt_const)* Suppose all the exchange addresses are stored in one wallet, the following chart demonstrates the procedure and computational formula how the exchange distributes GAS to the user A. -![gasflow_en](../sc/assets/gasflow_en.png) +![gasflow_en](../develop/assets/gasflow_en.png) The shorter the snapshot interval, the more precise the calculation is. If the snapshot interval is not uniform, use the weighted average calculation method. diff --git a/docs/en-us/exchange/transaction.md b/docs/en-us/exchange/transaction.md index 2e1fd87d6..6597fb873 100644 --- a/docs/en-us/exchange/transaction.md +++ b/docs/en-us/exchange/transaction.md @@ -26,7 +26,7 @@ NetworkFee = VerificationCost + tx.size * FeePerByte ## System fee -The system fee is charged for the instructions executed by NeoVM. For each instruction fee refer to [System Fee](../sc/fees.md). The total system fee you need to pay depends on the number and type of the instructions executed by your smart contract. The following figure shows the calculation formula: +The system fee is charged for the instructions executed by NeoVM. For each instruction fee refer to [System Fee](../reference/fees.md). The total system fee you need to pay depends on the number and type of the instructions executed by your smart contract. The following figure shows the calculation formula: ``` SystemFee = InvocationCost = The sum of all executed opcode fee diff --git a/docs/en-us/sc/gettingstarted/assets/2_privatechain_demo.png b/docs/en-us/gettingstarted/assets/2_privatechain_demo.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/2_privatechain_demo.png rename to docs/en-us/gettingstarted/assets/2_privatechain_demo.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_1545037391347.png b/docs/en-us/gettingstarted/assets/3_1545037391347.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_1545037391347.png rename to docs/en-us/gettingstarted/assets/3_1545037391347.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_2017-06-07_12-07-03.png b/docs/en-us/gettingstarted/assets/3_2017-06-07_12-07-03.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_2017-06-07_12-07-03.png rename to docs/en-us/gettingstarted/assets/3_2017-06-07_12-07-03.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg b/docs/en-us/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg rename to docs/en-us/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg diff --git a/docs/en-us/sc/gettingstarted/assets/3_edit_environment_variable.png b/docs/en-us/gettingstarted/assets/3_edit_environment_variable.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_edit_environment_variable.png rename to docs/en-us/gettingstarted/assets/3_edit_environment_variable.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_environment_variable.png b/docs/en-us/gettingstarted/assets/3_environment_variable.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_environment_variable.png rename to docs/en-us/gettingstarted/assets/3_environment_variable.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg b/docs/en-us/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg rename to docs/en-us/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg diff --git a/docs/en-us/sc/gettingstarted/assets/3_new_smart_contract_project.png b/docs/en-us/gettingstarted/assets/3_new_smart_contract_project.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_new_smart_contract_project.png rename to docs/en-us/gettingstarted/assets/3_new_smart_contract_project.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_publish_and_profile_settings.jpg b/docs/en-us/gettingstarted/assets/3_publish_and_profile_settings.jpg similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_publish_and_profile_settings.jpg rename to docs/en-us/gettingstarted/assets/3_publish_and_profile_settings.jpg diff --git a/docs/en-us/sc/gettingstarted/assets/3_publish_and_profile_settings.png b/docs/en-us/gettingstarted/assets/3_publish_and_profile_settings.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_publish_and_profile_settings.png rename to docs/en-us/gettingstarted/assets/3_publish_and_profile_settings.png diff --git a/docs/en-us/sc/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg b/docs/en-us/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg rename to docs/en-us/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg diff --git a/docs/en-us/sc/gettingstarted/assets/3_smart_contract_function_code.png b/docs/en-us/gettingstarted/assets/3_smart_contract_function_code.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/3_smart_contract_function_code.png rename to docs/en-us/gettingstarted/assets/3_smart_contract_function_code.png diff --git a/docs/en-us/sc/gettingstarted/assets/compile.png b/docs/en-us/gettingstarted/assets/compile.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/compile.png rename to docs/en-us/gettingstarted/assets/compile.png diff --git a/docs/en-us/sc/gettingstarted/assets/contractfile.png b/docs/en-us/gettingstarted/assets/contractfile.png similarity index 100% rename from docs/en-us/sc/gettingstarted/assets/contractfile.png rename to docs/en-us/gettingstarted/assets/contractfile.png diff --git a/docs/en-us/sc/gettingstarted/deploy.md b/docs/en-us/gettingstarted/deploy.md similarity index 93% rename from docs/en-us/sc/gettingstarted/deploy.md rename to docs/en-us/gettingstarted/deploy.md index 54050690d..08c3571e7 100644 --- a/docs/en-us/sc/gettingstarted/deploy.md +++ b/docs/en-us/gettingstarted/deploy.md @@ -26,7 +26,7 @@ Gas: 3 Signed and relayed transaction with hash=0xe03aade81fb96c44e115a1cc9cfe984a9df4a283bd10aa0aefa7ebf3e296f757 ``` -For more information, refer to [Deploying Smart Contracts](../deploy/deploy.md)。 +For more information, refer to [Deploying Smart Contracts](../develop/deploy/deploy.md). ## Invoking contract @@ -58,4 +58,4 @@ Where: - VM State: `HALT` indicates the vm executed successfully; `FAULT` indicates the vm exited during execution due to an exception. - Evaluation Stack: the result of contract execution, where the value is encoded with Base64 when it is a string or ByteArray. -For more information, refer to [Invoking Smart Contracts](../deploy/invoke.md). +For more information, refer to [Invoking Smart Contracts](../develop/deploy/invoke.md). diff --git a/docs/en-us/sc/gettingstarted/develop.md b/docs/en-us/gettingstarted/develop.md similarity index 95% rename from docs/en-us/sc/gettingstarted/develop.md rename to docs/en-us/gettingstarted/develop.md index 2caeb7cf9..cd246d44c 100644 --- a/docs/en-us/sc/gettingstarted/develop.md +++ b/docs/en-us/gettingstarted/develop.md @@ -42,7 +42,7 @@ We will complete the following tasks in this section: 3. Go to the publishing directory, run PowerShell and enter the command `./neon.exe` to check if neon works as below: - ![neon](../../../zh-cn/sc/assets/neon.png) + ![neon](../../zh-cn/gettingstarted/assets/neon.png) 4. Add the publishing directory to the environment variable Path: @@ -50,7 +50,7 @@ We will complete the following tasks in this section: > > Remove the old Neo2.x neon path if there is one. - ![env](../../../zh-cn/sc/assets/env.png) + ![env](../../zh-cn/gettingstarted/assets/env.png) 5. Start PowerShell anywhere and run the command `neon.exe` to check if it works. @@ -67,7 +67,7 @@ We will complete the following tasks in this section: 2. In the project template dialog that appears, search for `neocontract` and select NeoContract for C#. Follow the wizard to create the project. - ![neocontract](../../../zh-cn/sc/assets/neocontract.png) + ![neocontract](../../zh-cn/gettingstarted/assets/neocontract.png) 3. In the Solution panel, right click the project and then select `Manage NuGet Package`. Uninstall the NuGet reference for `Neo.SmartContract.Framework`. @@ -112,7 +112,3 @@ When the compilation is done, the following files are generated under the `bin/D - `NEP5.nef` : The smart contract execution file for Neo3, just as .avm for Neo2. - `NEP5.manifest.json` : The descriptive file of the smart contract, covering descriptions of functions, ScriptHash, entry, method, parameters, and return values of the contract. - -## What's next? - -[Deploying and invoking contract](deploy.md) diff --git a/docs/en-us/sc/gettingstarted/enviroment.md b/docs/en-us/gettingstarted/enviroment.md similarity index 78% rename from docs/en-us/sc/gettingstarted/enviroment.md rename to docs/en-us/gettingstarted/enviroment.md index 6314914d2..8dbc5b928 100644 --- a/docs/en-us/sc/gettingstarted/enviroment.md +++ b/docs/en-us/gettingstarted/enviroment.md @@ -4,8 +4,8 @@ Neo provides a test net for development, debugging and testing purposes. Besides, you can also choose to set up your own private chain where you can get more flexibly with plenty of test tokens. You can pick one of the following options: -- [Set up a private chain with one node](../../network/private-chain/solo.md) -- [Set up a private chain on a Windows host](../../network/private-chain/private-chain2.md) +- [Set up a private chain with one node](../develop/network/private-chain/solo.md) +- [Set up a private chain on a Windows host](../develop/network/private-chain/private-chain2.md) Refer to the instructions from above links to set up your private chain and withdraw NEO and GAS from genesis block. @@ -16,7 +16,3 @@ Now let's create a new wallet file used for deploying smart contracts: 1. Create a new wallet file named 0.json and copy the default address for later usage. 2. Open the wallet where you have withdrawn NEO and GAS from genesis block, transfer all the assets in that wallet to 0.json and wait for the transaction to be confirmed. 3. Open 0.json and assets is displayed in the account. - -## What's next? - -[Compiling a sample contract](develop.md) diff --git a/docs/en-us/sc/gettingstarted/prerequisites.md b/docs/en-us/gettingstarted/prerequisites.md similarity index 75% rename from docs/en-us/sc/gettingstarted/prerequisites.md rename to docs/en-us/gettingstarted/prerequisites.md index e5e3518e1..80ba0271f 100644 --- a/docs/en-us/sc/gettingstarted/prerequisites.md +++ b/docs/en-us/gettingstarted/prerequisites.md @@ -2,8 +2,6 @@ In next sections, we will work you through an example of how to release an NEP-5 asset on Neo blockchain, which includes the tasks of setting up and configuring the development environment, compiling, deploying and invoking the smart contract on a private Neo chain. -Neo provides two full-node clients: NEO-GUI and NEO-CLI. This tutorial is based on the usage of Neo-CLI. - ## System environment Neo-CLI runs in the following environments: @@ -14,8 +12,6 @@ Neo-CLI runs in the following environments: ### Download Neo-CLI -Refer to [Neo-CLI Setup](../../node/cli/setup.md) to download and install Neo-CLI Preview2 package from GitHub. - -## What's next? +Neo provides two full-node clients: NEO-GUI and NEO-CLI. This tutorial is based on the usage of Neo-CLI. -[Setting up local network](enviroment.md) +Refer to [Neo-CLI Setup](../node/cli/setup.md) to download and install Neo-CLI Preview4 package from GitHub. \ No newline at end of file diff --git a/docs/en-us/index.md b/docs/en-us/index.md index 8f81b3e4f..2ac40c318 100644 --- a/docs/en-us/index.md +++ b/docs/en-us/index.md @@ -2,30 +2,38 @@ ####Here is an exhaustive library of Neo technical documents, including development examples for your reference. -| Neo Node | | | | -| ------------------------------------ | ------------------------------ | ---------------------------- | ---------------------------------------------- | -| [Introduction](node/introduction.md) | [Neo-CLI](node/cli/setup.md) | [Neo-GUI](node/gui/install.md) | | - -| Neo Network | | | | -| ------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------- | ---- | -| [Main Net and Test Net](network/testnet.md) | [Setting up Private Chain ](network/private-chain/solo.md) | | | - -| Smart Contract Development | | | | -| ---------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------- | ------------------------------------------------------- | -| [Getting Started](sc/gettingstarted/introduction.md) | [Writing Smart Contracts](sc/write/basics.md) | [Deploying and Invoking Contracts](sc/deploy/deploy.md) | | -| [Contract Migration](sc/migrate.md) | [System Fees](sc/fees.md) | [Contract Samples](sc/sample/HelloWorld.md) | | - -| Neo Tools Development | | | | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------- | ---------------------------------------------- | -| [Blockchain Models](tooldev/concept/blockchain/block.md) | [Charging Model](tooldev/concept/charging_model.md) | [Consensus](tooldev/consensus/consensus_algorithm.md) | [Cryptography](tooldev/concept/cryptography/encode_algorithm.md) | -| [Transaction](tooldev/transaction/transaction.md) | [Wallet](tooldev/wallets.md) | [Neo SDK](tooldev/sdk/introduction.md) | [Big and Little Endian Usage](tooldev/concept/endian.md) | - -| Document for Exchange Developers | | | | -| ----------------------------------------------- | ---- | ---- | ---- | +| Getting Started | | | | +| ------------------------------------- | ---- | ---- | ---- | +| [Getting Started](gettingstarted/prerequisites.md) | | | | + +| Neo Basics | | | | +| ------------------------------------------------------ | ------------------------------------ | ------------------------------------------------- | ------------------------------------------------------------ | +| [Blockchain Models](basic/concept/blockchain/block.md) | [Consensus](basic/consensus/dbft.md) | [Neo VM](basic/neovm.md) | [Cryptography](basic/concept/cryptography/encode_algorithm.md) | +| [Transaction](basic/concept/transaction.md) | [Wallet](basic/concept/wallets.md) | [Charging Model](basic/concept/charging_model.md) | | + + +| Neo Node | | | | +| ------------------------------------ | ---------------------------- | ------------------------------ | ---- | +| [Introduction](node/introduction.md) | [Neo-CLI](node/cli/setup.md) | [Neo-GUI](node/gui/install.md) | | + +| Developer Guide | | | | +| ----------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------ | ---- | +| [Neo Network](develop/network/testnet.md) | [Writing Smart Contracts](develop/write/basics.md) | [Deploying and Invoking Contracts](develop/deploy/deploy.md) | | +| [Tools](develop/tool/sdk/introduction.md) | [Contract Samples](develop/sample/HelloWorld.md) | | | + +| Advanced Topics | | | | +| --------------- | ---- | ---- | ---- | +| [Oracle]() | | | | + +| Reference | | | | +| ---------------------------------------------- | --------------------------------------------- | ------------------------------------------------- | ----------------------------------------- | +| [RPC API](reference/rpc/latest-version/api.md) | [Smart Contract API](reference/scapi/api.md) | [Smart Contract Framework](reference/scapi/fw.md) | [NeoVM Instructions](reference/neo_vm.md) | +| [Fees](reference/fees.md) | [Governance API](reference/governance_api.md) | | | + +| Document for Exchange Developers | | | | +| ------------------------------------------------------- | ---- | ---- | ---- | | [Document for Exchange Developers](exchange/general.md) | | | | -| Reference | | | | -| ---------------------------------------------- | -------------------------------------------- | ------------------------------------------------- | ----------------------------------------------------------- | -| [RPC API](reference/rpc/latest-version/api.md) | [Smart Contract API](reference/scapi/api.md) | [Smart Contract Framework](reference/scapi/fw.md) | [NeoVM Instructions](reference/Neo_vm.md) | - \ No newline at end of file + + diff --git a/docs/en-us/glossary.md b/docs/en-us/intro/glossary.md similarity index 94% rename from docs/en-us/glossary.md rename to docs/en-us/intro/glossary.md index 2e5f42be4..c6361cae6 100644 --- a/docs/en-us/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](sc/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/sc/gettingstarted/introduction.md b/docs/en-us/intro/introduction.md similarity index 79% rename from docs/en-us/sc/gettingstarted/introduction.md rename to docs/en-us/intro/introduction.md index 914d5897f..4ed0a2b7a 100644 --- a/docs/en-us/sc/gettingstarted/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/node/cli/cli.md b/docs/en-us/node/cli/cli.md index c83bb38cf..fdaf1aac0 100644 --- a/docs/en-us/node/cli/cli.md +++ b/docs/en-us/node/cli/cli.md @@ -1027,7 +1027,7 @@ Exports the block data from the specified block height. The output can be used f ### start consensus -Starts the consensus on the premise that the wallet has a consensus authority, allows consensus authority to be obtained on the main net through voting. If a private chain is deployed, public key of the consensus can be set up in the `protocol.json`. For more information refer to [Setting up Private Chain](../../network/private-chain/private-chain2.md). +Starts the consensus on the premise that the wallet has a consensus authority, allows consensus authority to be obtained on the main net through voting. If a private chain is deployed, public key of the consensus can be set up in the `protocol.json`. For more information refer to [Setting up Private Chain](../../develop/network/private-chain/private-chain2.md). > [!NOTE] > diff --git a/docs/en-us/node/cli/config.md b/docs/en-us/node/cli/config.md index f408d8277..b106ed118 100644 --- a/docs/en-us/node/cli/config.md +++ b/docs/en-us/node/cli/config.md @@ -53,7 +53,7 @@ Where: To connect the node to test net, replace the content of configuration files `config.json` and `protocol.json` with the content of `config.testnet.json` and `protocol.testnet.json` respectively. -To connect the node to your private net, refer to [Setting up Private Chain](../../network/private-chain/solo.md). +To connect the node to your private net, refer to [Setting up Private Chain](../../develop/network/private-chain/solo.md). ## Installing plugins @@ -188,7 +188,3 @@ If you want the external program to access the node API need to open the firewal > [!WARNING] > > If you open the API service and the wallet in Neo-CLI, you need to set up your firewall policy. For example, set a whitelist for the firewall to only allow access to these ports by whitelisted IP addresses. If completely opening the service to external network, others may be able to export the private key or transfer assets using API. - -## What's next? - -[CLI Command Reference](cli.md) \ No newline at end of file diff --git a/docs/en-us/node/cli/setup.md b/docs/en-us/node/cli/setup.md index e585759e7..533ddf163 100644 --- a/docs/en-us/node/cli/setup.md +++ b/docs/en-us/node/cli/setup.md @@ -51,11 +51,11 @@ You can download and compile the Neo-CLI source directly from Github. ### Installing required files 1. Git clone Neo-CLI source code from [Github](https://github.com/neo-project/neo-node) or using the following command: - + ``` - $ git clone https://github.com/neo-project/neo-node.git + $ git clone -b master-2.x https://github.com/neo-project/neo-node.git ``` - + 2. Download [LevelDB](https://github.com/neo-ngd/leveldb/releases) and unzip the package for later use. 3. Install the latest version of [.NET Core Runtime](https://dotnet.microsoft.com/download/dotnet-core/current/runtime) diff --git a/docs/en-us/node/gui/blockchain.md b/docs/en-us/node/gui/blockchain.md index 082233b60..e0bad9287 100644 --- a/docs/en-us/node/gui/blockchain.md +++ b/docs/en-us/node/gui/blockchain.md @@ -4,7 +4,7 @@ You can click `Block` on the Neo-GUI main page to enter the blockchain page to v ## Block -The block is a logical structure and the most basic unit of the blockchain. Data is permanently recorded on the blockchain via blocks. For information about the basic concept of the block refer to [Block](../../tooldev/concept/blockchain/block.md). +The block is a logical structure and the most basic unit of the blockchain. Data is permanently recorded on the blockchain via blocks. For information about the basic concept of the block refer to [Block](../../basic/concept/blockchain/block.md). ### Viewing block list @@ -44,7 +44,7 @@ You can view the following information by switching tabs in this page: - **Transaction**: Displays the basic information of the transaction, such as the block, size, time stamp, as well as the transaction transfer record and the witness of the transaction. - **Notifications**: Displays the execution log of the smart contract in the transaction, including information such as whether the NEP-5 transfer was successful. -For information about the basic concept of transactions refer to [Transaction](../../tooldev/transaction/transaction.md). +For information about the basic concept of transactions refer to [Transaction](../../basic/concept/transaction.md). ## Assets diff --git a/docs/en-us/node/gui/contract.md b/docs/en-us/node/gui/contract.md index 1b965d541..2170ff47b 100644 --- a/docs/en-us/node/gui/contract.md +++ b/docs/en-us/node/gui/contract.md @@ -40,7 +40,7 @@ To deploy a contract on the blockchain, open a wallet first and then do the foll After the contract is deployed on the blockchain successfully, you can search and invoke the contract with the contract hash. -For more information refer to [Deploying Smart Contracts](../../sc/deploy/deploy.md). +For more information refer to [Deploying Smart Contracts](../../develop/deploy/deploy.md). ## Invoking a contract @@ -76,5 +76,5 @@ After the contract deployed on the blockchain you can enter the **Invoke** page 5. If the trial run goes successfully, click `Invoke`. -For more information refer to [Invoking Smart Contracts](../../sc/deploy/invoke.md). +For more information refer to [Invoking Smart Contracts](../../develop/deploy/invoke.md). diff --git a/docs/en-us/node/gui/install.md b/docs/en-us/node/gui/install.md index 6b1b833b2..41e4b67e6 100644 --- a/docs/en-us/node/gui/install.md +++ b/docs/en-us/node/gui/install.md @@ -23,7 +23,7 @@ Neo-GUI is an open source project, thus you can download the installation packag After installation Neo-GUI connects to the Neo test net automatically. -If you have already built a private chain (see [Setting up private chain](../../network/private-chain/solo.md)), you can also connect Neo-GUI to it. +If you have already built a private chain (see [Setting up private chain](../../develop/network/private-chain/solo.md)), you can also connect Neo-GUI to it. 1. Find the `config.json` and `protocol.json` files of your private chain. diff --git a/docs/en-us/sc/fees.md b/docs/en-us/reference/fees.md similarity index 72% rename from docs/en-us/sc/fees.md rename to docs/en-us/reference/fees.md index 8b12b7d24..31502242b 100644 --- a/docs/en-us/sc/fees.md +++ b/docs/en-us/reference/fees.md @@ -3,7 +3,7 @@ The system fee is calculated by opcodes to be executed by the Neo virtual machine. The 10 GAS free system fee will be cancled in NEO3. The total fee is subject to the quantity and type of instructions in the contract script. The calculation formula is as follows: -![](../../zh-cn/assets/system_fee.png) +![](C:/neo-project/docs/docs/zh-cn/assets/system_fee.png) where OpcodeSet is opcode set, OpcodePricei is the cost of opcode i, ni is the execution times of instruction i in the contract script. @@ -11,22 +11,31 @@ The fee of each interop service and instruction is shown in the table below. ### Fees for interop service -| Interop Service | Fee (GAS) | +| Interop Service | Fee (GAS) | |--|--| | 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 | @@ -56,20 +65,17 @@ The fee of each interop service and instruction is shown in the table below. | System.StorageContext.AsReadOnly| 0.00000400 | | System.Storage.Get| 0.01000000 | | System.Storage.Find| 0.01000000 | -| System.Storage.Put| See [1] | -| System.Storage.PutEx| See [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] When a Key-Value pair is written to the storage: -> -> - If the new pair key-value size is greater than the old key-value size, fee = [(newKey.Size +newValue.Size) - (oldKey.Size + oldValue.Size)] * GasPerByte -> - If the new pair key-value size is less than or equal to the old key-value size, fee = 1 * GasPerByte -> - If there is no existing key-value, 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 | @@ -78,7 +84,7 @@ The fee of each interop service and instruction is shown in the table below. - + @@ -102,27 +108,45 @@ The fee of each interop service and instruction is shown in the table below. - - + + - + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + +
Fee (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
+
@@ -158,6 +182,7 @@ The fee of each interop service and instruction is shown in the table below.
+
@@ -167,7 +192,7 @@ The fee of each interop service and instruction is shown in the table below. - + @@ -176,37 +201,64 @@ The fee of each interop service and instruction is shown in the table below. - + - - + + - + - + - + - + - + + + + + + + +
Fee (GAS)
Neo.Native.PolicyNeo.Native.Policy getMaxTransactionsPerBlock 0.01000000
0.01000000
getFeePerByteGetMaxBlockSystemFee 0.01000000
setMaxBlockSize0.03000000GetFeePerByte0.01000000
getBlockedAccounts
IsBlocked 0.01000000
setMaxTransactionsPerBlock
SetMaxBlockSize 0.03000000
setFeePerByte
SetMaxTransactionsPerBlock 0.03000000
blockAccount
SetMaxBlockSystemFee 0.03000000
unblockAccount
SetFeePerByte 0.03000000
BlockAccount0.03000000
UnblockAccount0.03000000
+ + + + + + + + + + + + + + + + + + + +
Interop ServiceMethod NameFee (GAS)
Neo.Native.Oraclefinish0
request0.50000000
verify0.01000000
-For the description of API in the table above, refer to [NEO Namespace](../reference/scapi/api/neo.md) +For the description of API in the table above, refer to [NEO Namespace](../reference/scapi/api/neo.md). ### Fees for Instructions -| Instruction | Fee (Gas) | -|---------------------|-------------| +| Instruction | Fee (GAS) | +|--|--| |PUSHINT8|0.00000030| |PUSHINT16|0.00000030| |PUSHINT32|0.00000030| @@ -263,7 +315,7 @@ For the description of API in the table above, refer to [NEO Namespace](../refer |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| @@ -286,8 +338,8 @@ For the description of API in the table above, refer to [NEO Namespace](../refer |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| @@ -313,8 +365,8 @@ For the description of API in the table above, refer to [NEO Namespace](../refer |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| @@ -324,11 +376,11 @@ For the description of API in the table above, refer to [NEO Namespace](../refer |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| 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/rpc/latest-version/api.md b/docs/en-us/reference/rpc/latest-version/api.md index 77e6aa5aa..274b59187 100644 --- a/docs/en-us/reference/rpc/latest-version/api.md +++ b/docs/en-us/reference/rpc/latest-version/api.md @@ -31,7 +31,7 @@ For P2P and WebSocket information see [Node Introduction](../../../node/introduc | [getrawtransaction](api/getrawtransaction.md) | \ [verbose=0] | Returns the transaction information with the specified hash value. | | [getstorage](api/getstorage.md) | \ \ | Returns the value with the contract script hash and the key. | | [gettransactionheight](api/gettransactionheight.md) | \ | Returns the transaction height with the specified transaction hash. | -| [getvalidators](api/getvalidators.md) | | Gets the information about the validators. | +| [getcommittee](api/getcommittee.md) | | Gets the public key list of current Neo committee members. | ### Node @@ -68,6 +68,7 @@ For P2P and WebSocket information see [Node Introduction](../../../node/introduc | [getnewaddress](api/getnewaddress.md) | | Creates a new address. | | [getwalletunclaimedgas](api/getwalletunclaimedgas.md) | | Gets the amount of unclaimed GAS in the wallet. | | [importprivkey](api/importprivkey.md) | \ | Imports the private key to the wallet. | +| [calculatenetworkfee](api/calculatenetworkfee.md) | \ | Calculates network fee for the specified transaction. | | [listaddress](api/listaddress.md) | | Lists all the addresses in the current wallet. | | [openwallet](api/openwallet.md) | \ \ | Opens the specified wallet. | | [sendfrom](api/sendfrom.md) | \\\\ | Transfers from the specified address to the destination address. | diff --git a/docs/en-us/reference/rpc/latest-version/api/calculatenetworkfee.md b/docs/en-us/reference/rpc/latest-version/api/calculatenetworkfee.md new file mode 100644 index 000000000..071326027 --- /dev/null +++ b/docs/en-us/reference/rpc/latest-version/api/calculatenetworkfee.md @@ -0,0 +1,37 @@ +# calculatenetworkfee Method + +Calculates network fee for the specified transaction. + +> [!Note] +> +> Before you can invoke this method you must install the plugin [RpcServer](https://github.com/neo-project/neo-plugins/releases). + +## Parameter Description + +tx: Base64-encoded string of transaction information. + +## Example + +Request body: + +```json +{ + "jsonrpc": "2.0", + "method": "calculatenetworkfee", + "params": ["AAzUzgl2c4kAAAAAAMhjJAAAAAAAmRQgAAKDHlc9J/rM4KzhpixYX/fRkt2q8ACBubhEJKzaXrq9mt5PesW40qC01AEAXQMA6HZIFwAAAAwUgx5XPSf6zOCs4aYsWF/30ZLdqvAMFIG5uEQkrNpeur2a3k96xbjSoLTUE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAJCDED0lByRy1/NfBDdKCFLA3RKAY+LLVeXAvut42izfO6PPsKX0JeaL959L0aucqcxBJfWNF3b+93mt9ItCxRoDnChKQwhAuj/F8Vn1i8nT+JHzIhKKmzTuP0Nd5qMWFYomlYKzKy0C0GVRA14QgxAMbiEtF4zjCUjGAzanxLckFiCY3DeREMGIxyerx5GCG/Ki0LGvNzbvPUAWeVGvbL5TVGlK55VfZECmy8voO1LsisRDCEC6P8XxWfWLydP4kfMiEoqbNO4/Q13moxYViiaVgrMrLQRC0ETje+v"], + "id": 1 +} +``` + +Response body: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "networkfee": 2384840 + } +} + +``` diff --git a/docs/en-us/reference/rpc/latest-version/api/getapplicationlog.md b/docs/en-us/reference/rpc/latest-version/api/getapplicationlog.md index de0d7a690..114e85da5 100644 --- a/docs/en-us/reference/rpc/latest-version/api/getapplicationlog.md +++ b/docs/en-us/reference/rpc/latest-version/api/getapplicationlog.md @@ -8,54 +8,195 @@ Returns the contract event information based on the specified txid. The contract ## Parameter Description -txid: Transaction ID +- txid: Transaction ID + +- trigger type: Optional. It has the following options: + + - OnPersist + - PostPersist + - Application + - Verification + - System: OnPersist | PostPersist + - All: OnPersist | PostPersist | Verification | Application + + It defaults to All. You can specify a trigger type. ## Example -Request body: +Request body 1: ```json { "jsonrpc": "2.0", + "id": 1, "method": "getapplicationlog", - "params": ["0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295"], - "id": 1 + "params": [ + "0xd6ea48f1c33defc1815562b3ace4ead99bf33a8ae67b2642cf73c2f192a717e5" + ] } ``` -Response body: +Response body 1: +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "txid": "0xd6ea48f1c33defc1815562b3ace4ead99bf33a8ae67b2642cf73c2f192a717e5", + "executions": [ + { + "trigger": "Application", + "vmstate": "HALT", + "gasconsumed": "9007990", + "stack": [], + "notifications": [ + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "Any" + }, + { + "type": "ByteString", + "value": "9S37k0BBDIaRxjEhW0Sk+9lDN4s=" + }, + { + "type": "Integer", + "value": "400000000" + } + ] + } + }, + { + "contract": "0xde5f57d430d3dece511cf975a8d37848cb9e0525", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "ByteString", + "value": "9S37k0BBDIaRxjEhW0Sk+9lDN4s=" + }, + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Integer", + "value": "1" + } + ] + } + } + ] + } + ] + } +} ``` + +Request body 2: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "getapplicationlog", + "params": [ + "0x0745a04ddb7803ebd549af4d80de03fc69349b0b77615a06d9ef052637de5931", "System" + ] +} + +``` + +Response body 2: + +```json { "jsonrpc": "2.0", - "id": "1", + "id": 1, "result": { - "txid": "0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", - "trigger": "Application", - "vmstate": "HALT", - "gasconsumed": "9007990", - "stack": [], - "notifications": [ + "blockhash": "0x0745a04ddb7803ebd549af4d80de03fc69349b0b77615a06d9ef052637de5931", + "executions": [ + { + "trigger": "System", + "vmstate": "HALT", + "gasconsumed": "2031260", + "stack": [], + "notifications": [ + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Any" + }, + { + "type": "Integer", + "value": "11384830" + } + ] + } + }, + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "Any" + }, + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Integer", + "value": "2376840" + } + ] + } + } + ] + }, { - "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", - "eventname": "Transfer", - "state": { - "type": "Array", - "value": [ - { - "type": "ByteString", - "value": "+pU2/Hks6bMS9XhEc3F6o2fineE=" - }, - { - "type": "ByteString", - "value": "GM4RybFKiRJSR0M8IDpNgA/1ILE=" - }, - { - "type": "Integer", - "value": "1223300000000" + "trigger": "System", + "vmstate": "HALT", + "gasconsumed": "2031260", + "stack": [], + "notifications": [ + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "Any" + }, + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Integer", + "value": "25000000" + } + ] } - ] - } + } + ] } ] } diff --git a/docs/en-us/reference/rpc/latest-version/api/getblock.md b/docs/en-us/reference/rpc/latest-version/api/getblock.md index 3eb323ee8..0916fdcae 100644 --- a/docs/en-us/reference/rpc/latest-version/api/getblock.md +++ b/docs/en-us/reference/rpc/latest-version/api/getblock.md @@ -24,7 +24,7 @@ Request body: { "jsonrpc": "2.0", "method": "getblock", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4"], + "params": ["0xdf9c92cdb8d503214d0bf6c231ccbfa25c20ce24fc4d03a966760e4423889710", 0], "id": 1 } ``` @@ -33,9 +33,9 @@ Response body: ```json { - "jsonrpc": "2.0", - "id": 1, - "result": "0000000059ff9a2ff0861bda1abf89e07a3d248def4cf4fd4493c23d32bcf9bc741b92867ac9948cd23059eb880182e443b5eb3c75ec68404d01ff7b3c8f85a6651a6aefdc0687a06f0100001027000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c4026a4ba2eba339629ce40817053625dc315c294cea30863bb56d15a7fb2f3445d615fa0d201b940e3df662c71b200e355b8193e746b36143dcb9de3669962fc852b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb0100f86bb4ae521c7046" + "jsonrpc": "2.0", + "id": 1, + "result": "AAAAAFjOB3LXvZFhG/DF9PnA4Zh/buBfAFhvwG6JAzP4EAht5itJ14qK/tiaUxujBBTdZAYFAKnwJroJd8AQAp+vHgzyjenQdQEAANAHAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEBxGiRWC9d/xNWdbZ1uM9Z/yBVoPLKG6WTQ22aMOgk/AwQMTFdgoZEoSkvyA0791Y1AV146AJEu2R/jFOZZyj37KxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768BAGgp5HJL+bHp" } ``` @@ -47,7 +47,7 @@ verbose = 1,returns the result in JSON format: { "jsonrpc": "2.0", "method": "getblock", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", 1], + "params": ["0xdf9c92cdb8d503214d0bf6c231ccbfa25c20ce24fc4d03a966760e4423889710", 1], "id": 1 } ``` @@ -59,27 +59,27 @@ Response body: "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", + "hash": "0xdf9c92cdb8d503214d0bf6c231ccbfa25c20ce24fc4d03a966760e4423889710", "size": 222, "version": 0, - "previousblockhash": "0x86921b74bcf9bc323dc29344fdf44cef8d243d7ae089bf1ada1b86f02f9aff59", - "merkleroot": "0xef6a1a65a6858f3c7bff014d4068ec753cebb543e4820188eb5930d28c94c97a", - "time": 1578946201308, - "index": 10000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x6d0810f83303896ec06f58005fe06e7f98e1c0f9f4c5f01b6191bdd77207ce58", + "merkleroot": "0x0c1eaf9f0210c07709ba26f0a900050664dd1404a31b539ad8fe8a8ad7492be6", + "time": 1605527768562, + "index": 2000, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAmpLouujOWKc5AgXBTYl3DFcKUzqMIY7tW0Vp/svNEXWFfoNIBuUDj32YscbIA41W4GT50azYUPcud42aZYvyF", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEBxGiRWC9d/xNWdbZ1uM9Z/yBVoPLKG6WTQ22aMOgk/AwQMTFdgoZEoSkvyA0791Y1AV146AJEu2R/jFOZZyj37", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], "consensusdata": { "primary": 0, - "nonce": "46701c52aeb46bf8" + "nonce": "e9b1f94b72e42968" }, "tx": [], - "confirmations": 129368, - "nextblockhash": "0xe5ee6885a736e194c14bb020dca34bd6effe4280fbaec4542e41e4bebd8d4870" + "confirmations": 5313, + "nextblockhash": "0x09638b66b8254485b594e7849dc279675e7631a06cdff857bee6991c1daa8105" } } ``` @@ -92,7 +92,7 @@ Request body: { "jsonrpc": "2.0", "method": "getblock", - "params": [10000], + "params": [7368], "id": 1 } ``` @@ -101,9 +101,9 @@ Response body: ```json { - "jsonrpc": "2.0", - "id": "1", - "result": "0000000059ff9a2ff0861bda1abf89e07a3d248def4cf4fd4493c23d32bcf9bc741b92867ac9948cd23059eb880182e443b5eb3c75ec68404d01ff7b3c8f85a6651a6aefdc0687a06f0100001027000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c4026a4ba2eba339629ce40817053625dc315c294cea30863bb56d15a7fb2f3445d615fa0d201b940e3df662c71b200e355b8193e746b36143dcb9de3669962fc852b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb0100f86bb4ae521c7046" + "jsonrpc": "2.0", + "id": 1, + "result": "AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768CAGUTt7+NSxXGAA7aoUS2kokAAAAAACYcEwAAAAAARzMAAAHNWK7P0zW+HrPTEeHcgAlj39ctnwEAXQMA5AtUAgAAAAwUzViuz9M1vh6z0xHh3IAJY9/XLZ8MFM1Yrs/TNb4es9MR4dyACWPf1y2fE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAFCDEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+KQwhAv3yei642bBp1hrlpk26E7iWN8VC2MdMXWurST/mONaPC0GVRA14" } ``` @@ -115,39 +115,64 @@ Verbose = 1, returns the result in JSON format: { "jsonrpc": "2.0", "method": "getblock", - "params": [10000, 1], + "params": [7368,1], "id": 1 } ``` Response body: -``` +```json { "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", - "size": 222, + "hash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", + "size": 474, "version": 0, - "previousblockhash": "0x86921b74bcf9bc323dc29344fdf44cef8d243d7ae089bf1ada1b86f02f9aff59", - "merkleroot": "0xef6a1a65a6858f3c7bff014d4068ec753cebb543e4820188eb5930d28c94c97a", - "time": 1578946201308, - "index": 10000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x7b895d302b435fb452e94f7938df416129da62caa0abbbb77a69a4c656281223", + "merkleroot": "0xc30fa2a389b4f9d86ec4e952c1fb010014b1aca0f17722f85c5b288d390b0aeb", + "time": 1605687708300, + "index": 7368, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAmpLouujOWKc5AgXBTYl3DFcKUzqMIY7tW0Vp/svNEXWFfoNIBuUDj32YscbIA41W4GT50azYUPcud42aZYvyF", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wC", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], "consensusdata": { "primary": 0, - "nonce": "46701c52aeb46bf8" + "nonce": "c6154b8dbfb71365" }, - "tx": [], - "confirmations": 129343, - "nextblockhash": "0xe5ee6885a736e194c14bb020dca34bd6effe4280fbaec4542e41e4bebd8d4870" + "tx": [ + { + "hash": "0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a", + "size": 252, + "version": 0, + "nonce": 1151457806, + "sender": "NedjwsfAJYFas9rn8UHWQftTW4oKAQyW9h", + "sysfee": "9015990", + "netfee": "1252390", + "validuntilblock": 13127, + "signers": [ + { + "account": "0x9f2dd7df630980dce111d3b31ebe35d3cfae58cd", + "scopes": "CalledByEntry" + } + ], + "attributes": [], + "script": "AwDkC1QCAAAADBTNWK7P0zW+HrPTEeHcgAlj39ctnwwUzViuz9M1vh6z0xHh3IAJY9/XLZ8TwAwIdHJhbnNmZXIMFLyvQdaEx9StbuDZnalwe50fDI5mQWJ9W1I4", + "witnesses": [ + { + "invocation": "DEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+", + "verification": "DCEC/fJ6LrjZsGnWGuWmTboTuJY3xULYx0xda6tJP+Y41o8LQZVEDXg=" + } + ] + } + ], + "confirmations": 2, + "nextblockhash": "0x1545a328149baf8037873793d7e45d27385221dd69ddb606ee55434eb173a3ff" } } ``` diff --git a/docs/en-us/reference/rpc/latest-version/api/getblockheader.md b/docs/en-us/reference/rpc/latest-version/api/getblockheader.md index adc4f95c9..0a8db6472 100644 --- a/docs/en-us/reference/rpc/latest-version/api/getblockheader.md +++ b/docs/en-us/reference/rpc/latest-version/api/getblockheader.md @@ -24,7 +24,7 @@ Request body: { "jsonrpc": "2.0", "method": "getblockheader", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", 0], + "params": ["0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", 0], "id": 1 } ``` @@ -33,9 +33,9 @@ Response body: ```json { - "jsonrpc": "2.0", - "id": "1", - "result": "0000000059ff9a2ff0861bda1abf89e07a3d248def4cf4fd4493c23d32bcf9bc741b92867ac9948cd23059eb880182e443b5eb3c75ec68404d01ff7b3c8f85a6651a6aefdc0687a06f0100001027000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c4026a4ba2eba339629ce40817053625dc315c294cea30863bb56d15a7fb2f3445d615fa0d201b940e3df662c71b200e355b8193e746b36143dcb9de3669962fc852b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb00" + "jsonrpc": "2.0", + "id": 1, + "result": "AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768A" } ``` @@ -47,7 +47,7 @@ Verbose = 1, returns the result in JSON format: { "jsonrpc": "2.0", "method": "getblockheader", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", 1], + "params": ["0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b",1], "id": 1 } ``` @@ -59,22 +59,22 @@ Response body: "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", + "hash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", "size": 213, "version": 0, - "previousblockhash": "0x86921b74bcf9bc323dc29344fdf44cef8d243d7ae089bf1ada1b86f02f9aff59", - "merkleroot": "0xef6a1a65a6858f3c7bff014d4068ec753cebb543e4820188eb5930d28c94c97a", - "time": 1578946201308, - "index": 10000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x7b895d302b435fb452e94f7938df416129da62caa0abbbb77a69a4c656281223", + "merkleroot": "0xc30fa2a389b4f9d86ec4e952c1fb010014b1aca0f17722f85c5b288d390b0aeb", + "time": 1605687708300, + "index": 7368, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAmpLouujOWKc5AgXBTYl3DFcKUzqMIY7tW0Vp/svNEXWFfoNIBuUDj32YscbIA41W4GT50azYUPcud42aZYvyF", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wC", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], - "confirmations": 91937, - "nextblockhash": "0xe5ee6885a736e194c14bb020dca34bd6effe4280fbaec4542e41e4bebd8d4870" + "confirmations": 12, + "nextblockhash": "0x1545a328149baf8037873793d7e45d27385221dd69ddb606ee55434eb173a3ff" } } ``` @@ -87,7 +87,7 @@ Request body: { "jsonrpc": "2.0", "method": "getblockheader", - "params": [6000, 0], + "params": [7368], "id": 1 } ``` @@ -96,9 +96,9 @@ Response body: ```json { - "jsonrpc": "2.0", - "id": "1", - "result": "0000000020c213cb72392bd365e1e7e4ff9958e83761cd104d49dab0dd05903f7b651fec9939608fd01705162af2b399b57cf21dd2750c52cae18b5848f85f0ca7694983e014539f6f0100007017000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c400eb0087228a71228edf83e635ad0bbcd30a8e0ba04207d26657dbce334e8ea1fa7b6684a393bc6d1e054df39927e9bdf3d89e3cd9cf760a5f8639ae5b27ecc822b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb00" + "jsonrpc": "2.0", + "id": 1, + "result": "AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768A" } ``` @@ -110,7 +110,7 @@ Verbose = 1, returns the result in JSON format: { "jsonrpc": "2.0", "method": "getblockheader", - "params": [6000, 1], + "params": [7368, 1], "id": 1 } ``` @@ -122,22 +122,22 @@ Response body: "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xf929babb2b10eed2e3af429c73648ef6d3c05d247494eb95dcdae53a77236ddf", + "hash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", "size": 213, "version": 0, - "previousblockhash": "0xec1f657b3f9005ddb0da494d10cd6137e85899ffe4e7e165d32b3972cb13c220", - "merkleroot": "0x834969a70c5ff848588be1ca520c75d21df27cb599b3f22a160517d08f603999", - "time": 1578926019808, - "index": 6000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x7b895d302b435fb452e94f7938df416129da62caa0abbbb77a69a4c656281223", + "merkleroot": "0xc30fa2a389b4f9d86ec4e952c1fb010014b1aca0f17722f85c5b288d390b0aeb", + "time": 1605687708300, + "index": 7368, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAOsAhyKKcSKO34PmNa0LvNMKjgugQgfSZlfbzjNOjqH6e2aEo5O8bR4FTfOZJ+m989iePNnPdgpfhjmuWyfsyC", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wC", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], - "confirmations": 150220, - "nextblockhash": "0x17f3f1d81f2f442053a0bf8ca9a6addeb25646267127bb3b43884f61ed9a2822" + "confirmations": 16, + "nextblockhash": "0x1545a328149baf8037873793d7e45d27385221dd69ddb606ee55434eb173a3ff" } } ``` diff --git a/docs/en-us/reference/rpc/latest-version/api/getcommittee.md b/docs/en-us/reference/rpc/latest-version/api/getcommittee.md new file mode 100644 index 000000000..e9bf50a24 --- /dev/null +++ b/docs/en-us/reference/rpc/latest-version/api/getcommittee.md @@ -0,0 +1,51 @@ +# getcommittee Method + +Gets the public key list of current Neo committee members. +> [!Note] +> +> Before you can invoke this method you must install the plugin [RpcServer](https://github.com/neo-project/neo-plugins/releases). + +## Example + +Request body: + +```json +{ + "jsonrpc": "2.0", + "method": "getcommittee", + "params": [], + "id": 1 +} +``` + +Response body: + +```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 diff --git a/docs/en-us/reference/rpc/latest-version/api/getcontractstate.md b/docs/en-us/reference/rpc/latest-version/api/getcontractstate.md index 30ece3864..73b523b95 100644 --- a/docs/en-us/reference/rpc/latest-version/api/getcontractstate.md +++ b/docs/en-us/reference/rpc/latest-version/api/getcontractstate.md @@ -18,7 +18,7 @@ Request body: { "jsonrpc": "2.0", "method": "getcontractstate", - "params": ["0x27c229e71e2e7b4aa8062f695586e4243ae60a49"], + "params": ["0x99042d380f2b754175717bb932a911bc0bb0ad7d"], "id": 1 } ``` @@ -28,145 +28,84 @@ Response body: ```json { "jsonrpc": "2.0", - "id": "1", + "id": 1, "result": { - "id": 4, - "hash": "0x27c229e71e2e7b4aa8062f695586e4243ae60a49", - "script": "VwUADBQcA1dGS3d+z2tfOsOJOs4fixYh9kH4J+yMELNyaiYJEHMj2gAAACFBm/ZnzgwCAgJQNToGAABwaAwLdG90YWxTdXBwbHlQNTcGAADYqnRsJh4MGUNvbnRyYWN0IGFscmVhZHkgZGVwbG95ZWQ6IUGb9mfODAIBAVA18wUAAHFpDBQcA1dGS3d+z2tfOsOJOs4fixYh9gwHAACNSf0aB9shUzX0BQAAaAwLdG90YWxTdXBwbHkMBwAAjUn9GgfbIVM16gUAAAsMFBwDV0ZLd37Pa186w4k6zh+LFiH2DAcAAI1J/RoH2yFTE8AMCFRyYW5zZmVyQZUBb2ERc2tAVwMCDBQcA1dGS3d+z2tfOsOJOs4fixYh9kH4J+yMELNwaCYGEHEiH3jKJgh5yhCzIgMRcmomBhBxIgx4eVBBMcYzHRFxaUBXAgAMFBwDV0ZLd37Pa186w4k6zh+LFiH2Qfgn7IwQs3BoJgYQcSIKIUHGnx3wEXFpQFcHAXhwaMoUsxCzcmomBhBzIj1oEM4MCFRyYW5zZmVyl6p0bCYGEHMiJmgSzkHb/qh0sxCzdW0mBhBzIhNoE85xaRC1dm4mBhBzIgRpc2tAVxYAQYQnEUMRsxCzdwtvCyYODAl1c2VyZXJyb3I6C0EnQzXxcGjKELN3DG8MJicMIkNvbnRyaWJ1dGlvbiB0cmFuc2FjdGlvbiBub3QgZm91bmQ6EHEQchB3DSJsIWhvDc53Dm8OEM4MFIl3INjNdvTwCr+jfA7diJwgj96bs3cPbw8mEGlvDhLONSb///+ecSIvbw4QzgwUO303EcbwzPmx3KkD0b+h2JbxI4yzdxBvECYOam8OEs419/7//55yIW8NEZ53DW8NaMq1dxFvESSNQZv2Z84MAgICUDXJAwAAc2sMC3RvdGFsU3VwcGx5UDXGAwAAdGzYdxJvEiYaDBVDb250cmFjdCBub3QgZGVwbG95ZWQ6bErYJgUQUEXbIXUMBwAAwW/yhiPbIW2fdmkMBADKmjvbIaBqEaCedwdvBxC2dxNvEyYODAl1c2VyZXJyb3I6bwdut3cUbxQmDgwJdXNlcmVycm9yOiFBm/ZnzgwCAQFQNS4DAAB3CEEtUQgwdwlvCG8JE85QNW8DAABKJAZFECIE2yF3Cm8IbwkTzm8KbweeUzUnAwAAawwLdG90YWxTdXBwbHltbweeUzUkAwAAC28JE85vCm8HnlMTwAwIVHJhbnNmZXJBlQFvYRF3FW8VQFcBAAwUHANXRkt3fs9rXzrDiTrOH4sWIfZB+CfsjHBoQFcBAAwKVG9rZW4gTmFtZXBoQFcBAAwLVG9rZW5TeW1ib2xwaEBXAQAYcGhAVwEAEsNKEAwFTkVQLTXQShEMBk5FUC0xMNBwaEBXAwF4ygwBFNshsxCzcGgmBhBxIhh4StgmBRBQRdshELNyaiYGEHEiBBFxaUBXAgF4QanFS0FwaCYHaBPOIgMRcWlAVwIAQZv2Z84MAgICUDUEAgAAcGgMC3RvdGFsU3VwcGx5UDUBAgAASiQGRRAiBNshcWlAVwMBeDSGELNxaSY5DDRUaGUgcGFyYW1ldGVyICdhY2NvdW50JyBTSE9VTEQgYmUgMjAtYnl0ZSBhZGRyZXNzZXMuOiFBm/ZnzgwCAQFQNZABAABwaHhQNd0BAABKJAZFECIE2yFyakBXDAN4NR7///8Qs3NrJjYMMVRoZSBwYXJhbWV0ZXIgJ2Zyb20nIFNIT1VMRCBiZSAyMC1ieXRlIGFkZHJlc3Nlcy46eTXe/v//ELN0bCY1DDBUaGUgcGFyYW1ldGVycyAndG8nIFNIT1VMRCBiZSAyMC1ieXRlIGFkZHJlc3Nlcy46eTXM/v//ELN1bSYJEHYj5AAAAHoQtncHbwcmMQwsVGhlIHBhcmFtZXRlciBhbW91bnQgTVVTVCBiZSBncmVhdGVyIHRoYW4gMC46eEH4J+yMELN3CG8IJgkQdiOXAAAAIUGb9mfODAIBAVA1iQAAAHBoeFA11gAAAErYJgUQUEXbIXFperV3CW8JJgYQdiJkehCzJAd4ebMiAxF3Cm8KJgYRdiJPaXqzdwtvCyYMaHhQNa8AAAAiCyFoeGl6n1M0X2h5UDWGAAAASiQGRRAiBNshcmh5anqeUzRFeHl6UxPADAhUcmFuc2ZlckGVAW9hEXZuQFcBAhLDSngQUNBKeRFQ0HBoQFcCAngRznnbMItweBDOaFBBkl3oMXFpQFcBA3gRznmLcHgQzmh6U0HmPxiEQFcBA3gRznnbMItweBDOaHpTQeY/GIRAVwICeBHOeYtweBDOaFBBkl3oMXFpQFcBAngRznmLcHgQzmhQQS9Yxe1AVgkMBwAAwW/yhiPbIWAMBwAAjUn9GgfbIWEMFBwDV0ZLd37Pa186w4k6zh+LFiH2YgwEAMqaO9shYxFkDBSJdyDYzXb08Aq/o3wO3YicII/em2UMFDt9NxHG8Mz5sdypA9G/odiW8SOMZgwCAQFnBwwCAgJnCEA=", + "id": 8, + "hash": "0x99042d380f2b754175717bb932a911bc0bb0ad7d", + "script": "DBQKo4e1Ppa3mJpjFDGgVt0fQKBC9kH4J+yMQDTkQFcBAAwFSGVsbG9Bm/ZnzkGSXegxcGhAVwQBEnAMF0ludm9rZSBTdHJvYWdlLlB1dCBmb3IgaBpQQXvjun0MByB0aW1lcy6Li9soQc/nR5YMBUhlbGxveFBBm/ZnzkHmPxiEDAJOb0Gb9mfOQZJd6DHYqnNrJiwMAk5vDAJOb0Gb9mfOQZJd6DFK2CYFEFBF2yERnlBBm/ZnzkHmPxiEIhMhDAJObxFQQZv2Z85B5j8YhAwCTm9Bm/ZnzkGSXegxcWlK2CYFEFBF2yEaUEF747p9chXDShAMBFB1dCDQShF40EoSDB0gaW50byBzdG9yYWdlIGNvbXBsZXRlbHkgZm9yINBKE2rQShQMBiB0aW1lc9DBShEyCJ1Ti1Ai+EXbKEHP50eWeBHADARXb3JkQZUBb2FpEcAMDkludm9rZVB1dENvdW50QZUBb2FAVwECNZL+//8Qs3BoJhYMEU5vIGF1dGhvcml6YXRpb24uOnh5UEExxjMdQFcBADVn/v//ELNwaCYWDBFObyBhdXRob3JpemF0aW9uLjohQcafHfBAVgEMFAqjh7U+lreYmmMUMaBW3R9AoEL2YEA=", "manifest": { "groups": [], - "features": { - "storage": true, - "payable": true - }, - "supportedstandards": [ - "NEP-5", - "NEP-10" - ], + "supportedstandards": [], "abi": { - "hash": "0x27c229e71e2e7b4aa8062f695586e4243ae60a49", + "hash": "0x99042d380f2b754175717bb932a911bc0bb0ad7d", "methods": [ - { - "name": "deploy", - "parameters": [], - "offset": 0, - "returntype": "Boolean" - }, - { - "name": "migrate", - "parameters": [ - { - "name": "script", - "type": "ByteArray" - }, - { - "name": "manifest", - "type": "String" - } - ], - "offset": 258, - "returntype": "Boolean" - }, - { - "name": "destroy", - "parameters": [], - "offset": 329, - "returntype": "Boolean" - }, - { - "name": "mint", - "parameters": [], - "offset": 459, - "returntype": "Boolean" - }, { "name": "verify", "parameters": [], - "offset": 946, + "offset": 28, "returntype": "Boolean" }, { - "name": "name", - "parameters": [], - "offset": 979, - "returntype": "String" - }, - { - "name": "symbol", - "parameters": [], - "offset": 997, - "returntype": "String" - }, - { - "name": "decimals", + "name": "myMethod", "parameters": [], - "offset": 1016, - "returntype": "Integer" + "offset": 31, + "returntype": "ByteArray" }, { - "name": "supportedStandards", - "parameters": [], - "offset": 1023, - "returntype": "Array" - }, - { - "name": "totalSupply", - "parameters": [], - "offset": 1119, - "returntype": "Integer" - }, - { - "name": "balanceOf", + "name": "put", "parameters": [ { - "name": "account", - "type": "ByteArray" + "name": "word", + "type": "String" } ], - "offset": 1170, - "returntype": "Integer" + "offset": 54, + "returntype": "Void" }, { - "name": "transfer", + "name": "update", "parameters": [ { - "name": "from", - "type": "ByteArray" - }, - { - "name": "to", + "name": "script", "type": "ByteArray" }, { - "name": "amount", - "type": "Integer" + "name": "manifest", + "type": "String" } ], - "offset": 1274, - "returntype": "Boolean" + "offset": 363, + "returntype": "Void" + }, + { + "name": "destroy", + "parameters": [], + "offset": 406, + "returntype": "Void" }, { "name": "_initialize", "parameters": [], - "offset": 1776, + "offset": 447, "returntype": "Void" } ], "events": [ { - "name": "Transfer", + "name": "Word", "parameters": [ { - "name": "arg1", - "type": "ByteArray" - }, + "name": "obj", + "type": "String" + } + ] + }, + { + "name": "InvokePutCount", + "parameters": [ { - "name": "arg2", + "name": "obj", "type": "ByteArray" - }, - { - "name": "arg3", - "type": "Integer" } ] } @@ -182,8 +121,9 @@ Response body: "safemethods": [], "extra": { "Author": "Neo", + "Name": "Sample", "Email": "dev@neo.org", - "Description": "This is a NEP5 example" + "Description": "This is a contract example" } } } diff --git a/docs/en-us/reference/rpc/latest-version/api/getrawtransaction.md b/docs/en-us/reference/rpc/latest-version/api/getrawtransaction.md index c11602f23..594c961ed 100644 --- a/docs/en-us/reference/rpc/latest-version/api/getrawtransaction.md +++ b/docs/en-us/reference/rpc/latest-version/api/getrawtransaction.md @@ -22,7 +22,7 @@ Request body: { "jsonrpc": "2.0", "method": "getrawtransaction", - "params": ["0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", 0], + "params": ["0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a"], "id": 1 } ``` @@ -33,7 +33,7 @@ Response body: { "jsonrpc": "2.0", "id": 1, - "result": "0001fea4517673890000000000c863240000000000d4192000028a45f89ca928a5381de89efff2b93f7d66eea2a800fa9536fc792ce9b312f5784473717aa367e29de101005d0300a95cd21c0100000c1418ce11c9b14a89125247433c203a4d800ff520b10c14fa9536fc792ce9b312f5784473717aa367e29de113c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b523802420c40c8bbb4e871a321544cf6c42c5b5d18cb7eafcfa8d0fcde2c054469ae0dbd8b566dc7ced0b65a4d598c9a7ce8cbebeda04260a3248fc6d9a634b30136d2042bd5290c2102a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b0b4195440d78420c40f3120275f82c19813671c7f19c9d030094ad57dece03d6246c8199df98f8b53e37fa2642cd5241b87331b450a2f25e2e1d8a4187c48bb752304c71a30e6001c12b110c2102a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b110b41138defaf" + "result": "AA7aoUS2kokAAAAAACYcEwAAAAAARzMAAAHNWK7P0zW+HrPTEeHcgAlj39ctnwEAXQMA5AtUAgAAAAwUzViuz9M1vh6z0xHh3IAJY9/XLZ8MFM1Yrs/TNb4es9MR4dyACWPf1y2fE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAFCDEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+KQwhAv3yei642bBp1hrlpk26E7iWN8VC2MdMXWurST/mONaPC0GVRA14" } ``` @@ -45,7 +45,7 @@ When verbose = 1, the result in Json format is returned: { "jsonrpc": "2.0", "method": "getrawtransaction", - "params": ["0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", 1], + "params": ["0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a", 1], "id": 1 } ``` @@ -55,41 +55,33 @@ Response body: ```json { "jsonrpc": "2.0", - "id": "1", + "id": 1, "result": { - "hash": "0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", - "size": 384, + "hash": "0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a", + "size": 252, "version": 0, - "nonce": 1369767425, - "sender": "NYX6FuequzNvtajBpKtHkiy6ggKFTmtDjv", - "sysfee": "9007990", - "netfee": "2384840", - "validuntilblock": 2103764, + "nonce": 1151457806, + "sender": "NedjwsfAJYFas9rn8UHWQftTW4oKAQyW9h", + "sysfee": "9015990", + "netfee": "1252390", + "validuntilblock": 13127, "signers": [ { - "account": "0xa8a2ee667d3fb9f2ff9ee81d38a528a99cf8458a", - "scopes": "FeeOnly" - }, - { - "account": "0xe19de267a37a71734478f512b3e92c79fc3695fa", + "account": "0x9f2dd7df630980dce111d3b31ebe35d3cfae58cd", "scopes": "CalledByEntry" } ], "attributes": [], - "script": "AwCpXNIcAQAADBQYzhHJsUqJElJHQzwgOk2AD/UgsQwU+pU2/Hks6bMS9XhEc3F6o2fineETwAwIdHJhbnNmZXIMFLyvQdaEx9StbuDZnalwe50fDI5mQWJ9W1I4", + "script": "AwDkC1QCAAAADBTNWK7P0zW+HrPTEeHcgAlj39ctnwwUzViuz9M1vh6z0xHh3IAJY9/XLZ8TwAwIdHJhbnNmZXIMFLyvQdaEx9StbuDZnalwe50fDI5mQWJ9W1I4", "witnesses": [ { - "invocation": "DEDIu7TocaMhVEz2xCxbXRjLfq/PqND83iwFRGmuDb2LVm3HztC2Wk1ZjJp86Mvr7aBCYKMkj8bZpjSzATbSBCvV", - "verification": "DCECqepoQswMs7DyMXsHyFDePR4rJDqY7S1Wo/9MpmqvMwsLQZVEDXg=" - }, - { - "invocation": "DEDzEgJ1+CwZgTZxx/GcnQMAlK1X3s4D1iRsgZnfmPi1Pjf6JkLNUkG4czG0UKLyXi4dikGHxIu3UjBMcaMOYAHB", - "verification": "EQwhAqnqaELMDLOw8jF7B8hQ3j0eKyQ6mO0tVqP/TKZqrzMLEQtBE43vrw==" + "invocation": "DEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+", + "verification": "DCEC/fJ6LrjZsGnWGuWmTboTuJY3xULYx0xda6tJP+Y41o8LQZVEDXg=" } ], - "blockhash": "0xecb6531e97a837db58f676ffc0b3038e638a483a5bd5729356cca48b9bd2748a", - "confirmations": 395, - "blocktime": 1595556303116, + "blockhash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", + "confirmations": 44, + "blocktime": 1605687708300, "vmstate": "HALT" } } diff --git a/docs/en-us/reference/rpc/latest-version/api/getstorage.md b/docs/en-us/reference/rpc/latest-version/api/getstorage.md index b25afea2f..f6a21a479 100644 --- a/docs/en-us/reference/rpc/latest-version/api/getstorage.md +++ b/docs/en-us/reference/rpc/latest-version/api/getstorage.md @@ -8,7 +8,7 @@ Returns the stored value according to the contract script hash and the stored ke ### Parameter Description -* script_hash: Contract script hash +* script_hash: Contract script hash or contract ID * key: The key to look up in storage (in hex string) @@ -18,10 +18,10 @@ Request body: ```json { - "jsonrpc": "2.0", - "method": "getstorage", - "params": ["03febccf81ac85e3d795bc5cbd4e84e907812aa3", "5065746572"], - "id": 15 + "jsonrpc": "2.0", + "method": "getstorage", + "params": ["0x99042d380f2b754175717bb932a911bc0bb0ad7d", "48656c6c6f"], + "id": 1 } ``` @@ -29,8 +29,8 @@ Response body: ```json { - "jsonrpc": "2.0", - "id": 15, - "result": "4c696e" + "jsonrpc": "2.0", + "id": 1, + "result": "776f726c64" } ``` diff --git a/docs/en-us/reference/rpc/latest-version/api/getvalidators.md b/docs/en-us/reference/rpc/latest-version/api/getvalidators.md deleted file mode 100644 index e8c340b1b..000000000 --- a/docs/en-us/reference/rpc/latest-version/api/getvalidators.md +++ /dev/null @@ -1,80 +0,0 @@ -# getvalidators Method - -Returns the current NEO validators information and voting status. - -> [!Note] -> -> You must install the plugin [RpcServer](https://github.com/neo-project/neo-modules/releases) before you can invoke the method. - -## Example - -Request body: - -```json -{ - "jsonrpc": "2.0", - "method": "getvalidators", - "params": [], - "id": 1 -} -``` - -Response body: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "result": [ - { - "publickey": "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70", - "votes": "46632420", - "active": true - }, - { - "publickey": "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d", - "votes": "46632420", - "active": true - }, - { - "publickey": "025bdf3f181f53e9696227843950deb72dcd374ded17c057159513c3d0abe20b64", - "votes": "0", - "active": false - }, - { - "publickey": "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e", - "votes": "46632420", - "active": true - }, - { - "publickey": "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554", - "votes": "46632420", - "active": true - }, - { - "publickey": "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", - "votes": "46632420", - "active": true - }, - { - "publickey": "032f7b887a43774c51927e44d4c471655cdf6257ad92e38c1cf50c67e1a10281b4", - "votes": "0", - "active": false - }, - { - "publickey": "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", - "votes": "46632420", - "active": true - }, - { - "publickey": "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", - "votes": "46632420", - "active": true - } - ] -} -``` - -- publickey: Candidate's public key -- votes: Candidate's votes -- active: If true, the candidate is among validators; otherwise not. \ No newline at end of file diff --git a/docs/en-us/reference/rpc/latest-version/api/invokefunction.md b/docs/en-us/reference/rpc/latest-version/api/invokefunction.md index 1391dd50c..e05a60f02 100644 --- a/docs/en-us/reference/rpc/latest-version/api/invokefunction.md +++ b/docs/en-us/reference/rpc/latest-version/api/invokefunction.md @@ -15,8 +15,6 @@ Invokes a smart contract with its scripthash based on the specified operation an * params: Optional. The parameters to be passed into the smart contract operation -* sender: Optional. The transaction sender and the account paying transaction fee. By default it is the first account in signers. - * signers: Optional. List of contract signature accounts. > [!Note] @@ -76,7 +74,6 @@ Request body: "value":"8" } ], - "0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146", [ { "account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c", diff --git a/docs/en-us/reference/rpc/latest-version/api/invokescript.md b/docs/en-us/reference/rpc/latest-version/api/invokescript.md index 4527e13cf..8a9456c64 100644 --- a/docs/en-us/reference/rpc/latest-version/api/invokescript.md +++ b/docs/en-us/reference/rpc/latest-version/api/invokescript.md @@ -10,7 +10,6 @@ Returns the result after passing a script through the VM. ### Parameter Description - script: A script runnable in the VM. This is the same script that is returned in invokefunction -- sender: The transaction sender and the account paying transaction fee. It is the first account in singers. - signers: list of contract signature accounts * account: signature account * scopes: signature's valid scopes, allowed values: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global @@ -28,7 +27,6 @@ Request body: "method": "invokescript", "params": [ "180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52", - ["0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146"], [ { "account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c", diff --git a/docs/en-us/reference/rpc/latest-version/api/sendrawtransaction.md b/docs/en-us/reference/rpc/latest-version/api/sendrawtransaction.md index a9d9a0224..515faaeb3 100644 --- a/docs/en-us/reference/rpc/latest-version/api/sendrawtransaction.md +++ b/docs/en-us/reference/rpc/latest-version/api/sendrawtransaction.md @@ -8,7 +8,7 @@ Broadcasts transactions over the NEO network. ## Parameter Description -hex: A hexadecimal string that has been serialized after the transaction signed in the program. +hex: A Base64-encoded string that has been serialized after the transaction signed in the program. ## Example @@ -18,7 +18,7 @@ Request body: { "jsonrpc": "2.0", "method": "sendrawtransaction", - "params": ["004715897d2bf173f849d1d59123d097c009aa31624d39e73900e1f50500000000466a130000000000f699200000012bf173f849d1d59123d097c009aa31624d39e739015d0300d0ed902e0000000c1425275006800e73cc64286753a3a732422521c8e40c142bf173f849d1d59123d097c009aa31624d39e73913c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b523901420c40632d2abc04cce02a7d373a2def1b5d126ce75cdd6f40ef8ab9258960841c4123c48288a6f44bc86d94e83755faee3c17d059b99561a18d923202717796e0b68f290c2103b9c46c6d5c671ef5c21bc7aa7c30468aeb081a2e3895269adf947718d650ce1e0b410a906ad4"], + "params": ["ALmNfAb4lqIAAAAAAAZREgAAAAAA8S8AAAEKo4e1Ppa3mJpjFDGgVt0fQKBC9gEAKQwFd29ybGQRwAwDcHV0DBR9rbALvBGpMrl7cXVBdSsPOC0EmUFifVtSAUIMQACXF48H1VRmI50ievPfC042rJgj7ZQ3Y4ff27abOpeclh+6KpsL6gWfZTAUyFOwdjkA7CWLM3HsovQeDQlI0oopDCEDzqPi+B8a+TUi0p7eTySh8L7erXKTOR0ziA9Uddl4eMkLQZVEDXg="], "id": 1 } ``` diff --git a/docs/en-us/reference/rpc/latest-version/api/submitblock.md b/docs/en-us/reference/rpc/latest-version/api/submitblock.md index fa116129f..b2508c096 100644 --- a/docs/en-us/reference/rpc/latest-version/api/submitblock.md +++ b/docs/en-us/reference/rpc/latest-version/api/submitblock.md @@ -17,7 +17,7 @@ Broadcasts a new block in the NEO network. ### Parameter Description -hex: A hexadecimal string of a serialized block. +hex: A Base64-encoded string of a serialized block. ## Example @@ -27,7 +27,7 @@ Request body: { "jsonrpc": "2.0", "method": "submitblock", - "params": ["0000000020101cfb80de52766575a91310fddd7bf4fbd4f904e5574373649092cffffcf154badd3ae13d8aa76e75ebf9a1b2fcff874e85798a940da9e21f9533625b5a135bf545ce74010000180000000b2222301e1d5984be6d5a928e946d269603505801420c40ffe24193611172117b7cb49915afe91ec7bf314c6f855f13f82f84329238e8e1649c1aea471873fb374f548a70bb04d0cb127ddb1d4765f67d3b29a2a10e42822b110c2102470d8f746f040f8b9355be5e6fd1dc280f0c6ba9270420290337b07a37f706bd110b41138defaf010088e65a74589edfbf"], + "params": ["AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768CAGUTt7+NSxXGAA7aoUS2kokAAAAAACYcEwAAAAAARzMAAAHNWK7P0zW+HrPTEeHcgAlj39ctnwEAXQMA5AtUAgAAAAwUzViuz9M1vh6z0xHh3IAJY9/XLZ8MFM1Yrs/TNb4es9MR4dyACWPf1y2fE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAFCDEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+KQwhAv3yei642bBp1hrlpk26E7iWN8VC2MdMXWurST/mONaPC0GVRA14"], "id": 1 } ``` diff --git a/docs/en-us/reference/scapi/api.md b/docs/en-us/reference/scapi/api.md index d3b88615d..45ddd2035 100644 --- a/docs/en-us/reference/scapi/api.md +++ b/docs/en-us/reference/scapi/api.md @@ -2,8 +2,6 @@ The NEO Smart Contract API expands the capabilities of the Smart Contract to access the blockchain data, manipulate persistent storage, and query the execution environment. It is part of the Neo Virtual Machine (NeoVM) Interoperability Service Layer. -For information about NeoVM, see [NEO Smart Contract Introduction](../../sc/gettingstarted/introduction.md). - For more information on how to use the framework to easily call APIs in high-level languages, see [Smart Contracts Framework](fw.md). diff --git a/docs/en-us/reference/scapi/api/System.md b/docs/en-us/reference/scapi/api/System.md index eb149ff6a..441f29059 100644 --- a/docs/en-us/reference/scapi/api/System.md +++ b/docs/en-us/reference/scapi/api/System.md @@ -6,8 +6,12 @@ The interop service layer provides APIs for smart contracts to access the blockc | API | Description | |--|--| -| System.Binary.Base64Decode | Decodes StackItem to byte array | +| System.Binary.Base64Decode | Decodes Base64-encoded string into byte array | | System.Binary.Base64Encode | Encodes byte array to Base64 string | +| System.Binary.Serialize | Serializes stack elements into byte array | +| System.Binary.Deserialize | Deserializes the byte array into stack elements | +| System.Binary.Base58Decode | Decodes Base58-encoded string into byte array | +| System.Binary.Base58Encode | Encodes byte array to Base58 string | **BlockChain API**: @@ -20,6 +24,15 @@ The interop service layer provides APIs for smart contracts to access the blockc |System.Blockchain.GetTransactionFromBlock|Gets a transaction with the txid in the block| |System.Blockchain.GetContract|Gets a contract with the hash| +**Callback API**: + +| API | Description | +| --------------------------------- | ------------------------------------------------------------ | +| System.Callback.Create | Creates a callback service according to the stack pointer | +| System.Callback.CreateFromMethod | Creates a callback service for the specified method of the specified contract | +| System.Callback.CreateFromSyscall | Creates a callback service for system call | +| System.Callback.Invoke | Invokes the callback method | + **Contract API**: | API | Description | @@ -30,6 +43,18 @@ The interop service layer provides APIs for smart contracts to access the blockc |System.Contract.Call|Invokes a contract| |System.Contract.CallEx|Invokes a contract with the Flag| |System.Contract.IsStandard|Checks whether the contract is a standard contract| +|System.Contract.GetCallFlags|Gets the execution permission of the current context| + +**Crypto API**: + +| API | Description | +| --------------------------------------------- | ----------------------------------------------------- | +| System.Crypto.RIPEMD160 | Calculates the RIPEMD160 hash value of stack elements | +| System.Crypto.SHA256 | Calculates the Sha256 hash value of stack elements | +| System.Crypto.VerifyWithECDsaSecp256r1 | Uses the Secp256r1 curve to verify single signature | +| System.Crypto.VerifyWithECDsaSecp256k1 | Uses the Secp256k1 curve to verify single signature | +| System.Crypto.CheckMultisigWithECDsaSecp256r1 | Uses the Secp256r1 curve to verify multi-signature | +| System.Crypto.CheckMultisigWithECDsaSecp256k1 | Uses the Secp256k1 curve to verify multi-signature | **Enumerator API**: @@ -64,9 +89,14 @@ The interop service layer provides APIs for smart contracts to access the blockc |System.Runtime.Platform|Gets the platform information of the contract being executed| |System.Runtime.GetTrigger|Gets the triggering condition of the contract| |System.Runtime.GetTime|Gets the timestamp of the current block | +|System.Runtime.GetScriptContainer|Gets the script container of the smart contract (the first trigger) | +|System.Runtime.GetExecutingScriptHash| Gets the script hash executed by the smart contract | +|System.Runtime.GetCallingScriptHash|Gets the script hash of the caller of the smart contract | +|System.Runtime.GetEntryScriptHash|Gets the script hash of the entry point of the smart contract (the starting point of the contract call chain) | |System.Runtime.CheckWitness|Verifies whether the container calling the contract is signed by the
script hash of the specific account| |System.Runtime.GetInvocationCounter|Gets invocation count of the current contract| |System.Runtime.Log|Records the log| +|System.Runtime.Notify|Records the contract notification| |System.Runtime.GetNotifications|Gets notifications of a contract| |System.Runtime.GasLeft|Gets the unconsumed gas| diff --git a/docs/en-us/reference/scapi/api/neo.md b/docs/en-us/reference/scapi/api/neo.md index eac6164e1..29b24a569 100644 --- a/docs/en-us/reference/scapi/api/neo.md +++ b/docs/en-us/reference/scapi/api/neo.md @@ -7,6 +7,7 @@ NEO namespace provides APIs for native contracts and verifying digital signature | API | Description | | -- | --| |Neo.Native.Deploy|Deploys and initializes all native contracts| +|Neo.Native.Call|Invokes native contracts|
@@ -17,7 +18,7 @@ NEO namespace provides APIs for native contracts and verifying digital signature Description - Neo.Native.Tokens.NEO + Neo.Native.Tokens.NEO name Gets token name, ie: NEO @@ -41,27 +42,41 @@ NEO namespace provides APIs for native contracts and verifying digital signature transfer Transfers the token + + SetGasPerBlock + Sets the number of GAS generated for each block + + + GetGasPerBlock + Gets the number of GAS generated for each block + + + RegisterCandidate + Registers as a candidate + - registerValidator - Registers to be a validator + UnregisterCandidate + Unregisters as a candidate vote - Votes for validators + Vote - getRegisteredValidators - Gets registered validators + GetCandidates + Gets a list of candidates - getValidators - Gets validators + GetCommittee + Gets a list of committee members unclaimedGas Gets unclaimed Gas + +
@@ -106,7 +121,7 @@ NEO namespace provides APIs for native contracts and verifying digital signature - + @@ -114,31 +129,70 @@ NEO namespace provides APIs for native contracts and verifying digital signature + + + + + + + + - - - + + + + - + + - + +
Description
Neo.Native.PolicyNeo.Native.Policy getMaxTransactionsPerBlock Gets max transaction number per block
getMaxBlockSize Gets max block size
GetMaxBlockSystemFeeGets the maximum system fee for the block
getFeePerByte Gets fee per byte
IsBlockedVerifies whether the account is blocked
setMaxBlockSize Sets the max block size
getBlockedAccountsGets blocked accounts
SetMaxBlockSystemFeeSets the maximum system fee for the block
setMaxTransactionsPerBlock Sets max transaction per block
setFeePerByte Sets fee per byte
blockAccount
BlockAccount Sets blocked accounts
unblockAccount
UnblockAccount Unblocks accounts
+ + + + + + + + + + + + + + + + + + + +
APIMethod NameDescription
Neo.Native.OracleFinishInvokes the callback function after getting the Oracle response
RequestInitiates an Oracle request
VerifyVerifies if the Oracle response transaction is legal
+ + +> [!Note] +> +> The above API are used for committee members only; ordinary users will fail during the signature verification process. +> +> The source code for the above API can be found under `NEO` in the (https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/PolicyContract.cs). + **Crypto API**: | API | Description | diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Contract.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Contract.md index f5f03e4d2..8fe3b65d5 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Contract.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Contract.md @@ -16,7 +16,7 @@ public class Contract | Name | description | | ---------------------------- | ---------- | -| [Script](Contract/Script.md) | Returns the scripthash of the contract | +| Script | Returns the scripthash of the contract | | HasStorage | Whether the contract contains the storage | | IsPayable | Whether the contract is able to accept assets | 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 new file mode 100644 index 000000000..dff83abfc --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas.md @@ -0,0 +1,29 @@ +# GAS Class + +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) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public class GAS +``` + +## Attributes + +| Name | Description | +| ----------------- | ------------------------------------------------------------ | +| Name | Gets the name, GAS | +| Symbol | Gets the symbol, gas | +| Decimals | Gets decimals | + +## Methods + +| Name | Description | +| ------------------------------------------------------------ | ---------------------------- | +| [TotalSupply()](Gas/TotalSupply.md) | Gets the total supply of GAS | +| [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 new file mode 100644 index 000000000..9909692b9 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md @@ -0,0 +1,49 @@ +# BalanceOf Method (byte[]) + +Gets the GAS balance in the account. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger BalanceOf(byte[] account); +``` + +Parameters: + +- account: Script hash of the account + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = GAS.BalanceOf(account); + return result; + } +} +``` + +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/TotalSupply.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/TotalSupply.md new file mode 100644 index 000000000..2acb253cf --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/TotalSupply.md @@ -0,0 +1,28 @@ +# TotalSupply Method () + +Gets the total supply of GAS. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger TotalSupply(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = GAS.TotalSupply(); + return result; + } +} +``` + +[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 new file mode 100644 index 000000000..84fe8b39c --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Gas/Transfer.md @@ -0,0 +1,52 @@ +# Transfer Method (UInt160, UInt160, BigInteger) + +Transfers GAS + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); +``` + +Parameters: + +- from: Script hash of the account you transfer from +- to: Script hash of the account you transfer to +- amount: The amount to be transferred. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + + public static object Main() + { + 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/Json.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Json.md index 51301094c..679ea36a6 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Json.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Json.md @@ -12,7 +12,7 @@ Assembly: Neo.SmartContract.Framework public static class Json ``` -## Attributes +## Methods | Name | Description | | ---------------------------------------- | -------------------------- | diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Native.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Native.md deleted file mode 100644 index ae31ce0ec..000000000 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Native.md +++ /dev/null @@ -1,21 +0,0 @@ -# Native Class - -The native contract class for the Neo blockchain. - -Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) - -Assembly: Neo.SmartContract.Framework - -## Syntax - -```c# -public class Native -``` - -## Attributes - -| Name | Description | -| ---------------------------------------- | -------------------------- | -| [NEO(string method, object\[\] arguments)](Native/NEO.md) | NeoToken of the native contract | -| [GAS(string method, object\[\] arguments)](Native/GAS.md) | GasToken of the native contract | -| [Policy(string method, object\[\]](Native/Policy.md) arguments) | PolicyContract of the native contract | diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Native/GAS.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Native/GAS.md deleted file mode 100644 index 8f3373ee0..000000000 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Native/GAS.md +++ /dev/null @@ -1,36 +0,0 @@ -# Native.GAS Method (string, object[]) - -Invokes the method in the GAS contract with the method name and method parameters. - -Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) - -Assembly: Neo.SmartContract.Framework - -## Syntax - -```c# -public static extern object GAS(string method, object[] arguments); -``` - -Parameters: - -- method: The method name -- arguments: The method arguments - -## Example - -```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; - } -} -``` - -[Back](../Native.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Native/NEO.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Native/NEO.md deleted file mode 100644 index a3acc862f..000000000 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Native/NEO.md +++ /dev/null @@ -1,36 +0,0 @@ -# Native.NEO Method (string, object[]) - -Invokes the method in the Neo contract with the method name and method parameters. - -Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) - -Assembly: Neo.SmartContract.Framework - -## Syntax - -```c# -public static extern object NEO(string method, object[] arguments); -``` - -Parameters: - -- method: The method name -- arguments: The method arguments - -## Example - -```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; - } -} -``` - -[Back](../Native.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Native/Policy.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Native/Policy.md deleted file mode 100644 index 328c26a3c..000000000 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/Native/Policy.md +++ /dev/null @@ -1,32 +0,0 @@ -# Native.Policy Method (string, object[]) - -Invokes the method in the Policy contract with the method name and method parameters. - -Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) - -Assembly: Neo.SmartContract.Framework - -## Syntax - -```c# -public static extern object Policy(string method, object[] arguments); -``` - -Parameters: - -- method: The method name -- arguments: The method arguments - -## Example - -```c# -public class Contract1 : SmartContract.Framework.SmartContract -{ - public static object Main() - { - BigInteger feeByte = (BigInteger)Native.Policy("getFeePerByte", new object[]{}); - } -} -``` - -[Back](../Native.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 new file mode 100644 index 000000000..939865c60 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo.md @@ -0,0 +1,38 @@ +# Neo Class + +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) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public class NEO +``` + +## Attributes + +| Name | Description | +| ----------------- | ------------------------------------------------------------ | +| Name | Gets the name, NEO | +| Symbol | Gets the symbol, neo | +| Decimals | Gets decimals | + +## Methods + +| Name | Description | +| ------------------------------------------------------------ | ----------------------------------------------- | +| [TotalSupply()](Neo/TotalSupply.md) | Gets the total supply of 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(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 new file mode 100644 index 000000000..3acb262e7 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md @@ -0,0 +1,50 @@ +# BalanceOf Method (UInt160) + +Gets the NEO balance in the account. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger BalanceOf(UInt160 account); +``` + +Parameters: + +- account: Script hash of the account + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = NEO.BalanceOf(account); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..73226b942 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -0,0 +1,53 @@ +# GetCandidates Method () + +Gets the list of candidates. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern (ECPoint, BigInteger)[] GetCandidates(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + (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 new file mode 100644 index 000000000..2021f8018 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -0,0 +1,46 @@ +# GetCommittee Method () + +Gets the list of committee members. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern string[] GetCommittee(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + string[] result = NEO.GetCommittee(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..348df966e --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md @@ -0,0 +1,43 @@ +# GetGasPerBlock Method () + +Gets the number of GAS generated in each block. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger GetGasPerBlock(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = NEO.GetGasPerBlock(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..8ad76f720 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -0,0 +1,46 @@ +# GetNextBlockValidators Method () + +Gets the list of validators for the next block + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern string[] GetNextBlockValidators(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + string[] result = NEO.GetNextBlockValidators(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..fcc96b5fc --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md @@ -0,0 +1,53 @@ +# RegisterCandidate Method (ECPoint) + +Registers as a candidate. + +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(ECPoint pubkey); +``` + +Parameter: + +- pubkey: The public key of the account to be registered. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..4ab0160e4 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md @@ -0,0 +1,53 @@ +# SetGasPerBlock Method (BigInteger) + +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# +public static extern bool SetGasPerBlock(BigInteger gasPerBlock); +``` + +Parameter: + +- gasPerBlock: the number of GAS generated in each block. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger gasPerBlock = 10; + bool result = NEO.SetGasPerBlock(gasPerBlock); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..e1a802896 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md @@ -0,0 +1,43 @@ +# TotalSupply Method () + +Gets the total supply of NEO. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger TotalSupply(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = NEO.TotalSupply(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..8eec59a6e --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -0,0 +1,57 @@ +# Transfer Method (UInt160, UInt160, BigInteger) + +Transfers NEO. + +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(UInt160 from, UInt160 to, BigInteger amount); +``` + +Parameters: + +- from: Script hash of the account you transfer from +- to: Script hash of the account you transfer to +- amount: The amount to be transferred. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + + public static object Main() + { + BigInterger value = 1000; + bool result = NEO.Transfer(from, to, value); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..fbc5c7008 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md @@ -0,0 +1,53 @@ +# UnRegisterCandidate Method (ECPoint) + +Unregisters as a candidate. + +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(ECPoint pubkey); +``` + +Parameter: + +- pubkey: the public key of the account to be unregistered. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..a9312c5b8 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md @@ -0,0 +1,50 @@ +# UnclaimedGas Method (UInt160, uint) + +Gets the number of unclaimed GAS. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger UnclaimedGas(UInt160 account, uint end); +``` + +Parameters + +- account: The script hash of the account to be queried; +- end: To which block height the query ends. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = NEO.UnclaimedGas(account, 100); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..ec6f3c124 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Neo/Vote.md @@ -0,0 +1,56 @@ +# Vote Method (UInt160, ECPoint) + +Votes for the candidates. + +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(UInt160 account, ECPoint voteTo); +``` + +Parameters: + +- account: Script hash of the voting account. +- voteTo: Public key of the account to vote. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..2baa7be72 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle.md @@ -0,0 +1,25 @@ +# Oracle Class + +Provides a series of methods of the native contract Oracle, which contract hash is `0x35e4fc2e69a4d04d1db4d755c4150c50aff2e9a9`. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public class Oracle +``` + +## Attribute + +| Name | Description | +| ---- | ----------------- | +| Name | The contract name | + +## Method + +| Name | Description | +| ------------------------------------------------------------ | --------------------------- | +| [Request(string url, string filter, string callback, object userData, long gasForResponse)](Oracle/Request.md) | Initiates an Oracle request | \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle/Request.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle/Request.md new file mode 100644 index 000000000..4961709f3 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle/Request.md @@ -0,0 +1,51 @@ +# Request Method (string, string, string, object, long) + +Initiates an Oracle request. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern void Request(string url, string filter, string callback, object userData, long gasForResponse); +``` + +Parameters: + +- url: The request Url +- filter: Filter, used to filter useless data +- callback: Callback function +- userData: Additional data provided by the user +- long: The cost of getting a response + +## Example + +```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); + } +} +``` + +[Back](../Oracle.md) \ No newline at end of file diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md new file mode 100644 index 000000000..568d0a593 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md @@ -0,0 +1,30 @@ +# Policy Class + +Provides a series of methods of the native contract Policy, which contract hash is `0x1ca594b36b6b6b3f05efce8b106c824053d18713`. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public class Policy +``` + +## Methods + +| Name | Description | +| ------------------------------------------------------------ | ----------------------------------------- | +| Name() | The contract name | +| [GetMaxTransactionsPerBlock()](Policy/GetMaxTransactionsPerBlock.md) | Gets max transaction number per block | +| [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(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(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 new file mode 100644 index 000000000..1efc32e09 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md @@ -0,0 +1,53 @@ +# BlockAccount Method (UInt160) + +Sets the blocked accounts + +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(UInt160 account); +``` + +Parameter + +- account: The account to be added to the block list + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + + public static object Main() + { + bool result = Policy.BlockAccount(account); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..033371f34 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md @@ -0,0 +1,43 @@ +# GetFeePerByte Method () + +Gets fee per byte + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern BigInteger GetFeePerByte(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + BigInteger result = Policy.GetFeePerByte(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..8833a3c3f --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md @@ -0,0 +1,43 @@ +# GetMaxBlockSize Method () + +Gets max block size + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern uint GetMaxBlockSize(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + uint result = Policy.GetMaxBlockSize(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..a9ac0c43a --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md @@ -0,0 +1,43 @@ +# GetMaxBlockSystemFee Method () + +Gets the maximum system fee for the block + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern long GetMaxBlockSystemFee(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + long result = Policy.GetMaxBlockSystemFee(); + return result; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..6fde1c7c7 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md @@ -0,0 +1,46 @@ +# GetMaxTransactionsPerBlock Method () + +Sets max transaction per block + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern uint GetMaxTransactionsPerBlock(); +``` + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + uint result = Policy.GetMaxTransactionsPerBlock(); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..acf47f405 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md @@ -0,0 +1,49 @@ +# IsBlocked Method (byte[]) + +Verifies whether the account is blocked. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern string[] IsBlocked(byte[] account); +``` + +Parameter: + +- account: the account script hash + +## Example + +```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; + } +} +``` + +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 new file mode 100644 index 000000000..6abf89644 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md @@ -0,0 +1,51 @@ +# SetFeePerByte Method (long) + +Sets fee per byte + +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 SetFeePerByte(long value); +``` + +Parameter: + +- value: fee per byte + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetFeePerByte(1200); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..ab49da478 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md @@ -0,0 +1,52 @@ +# SetMaxBlockSize Method (uint) + +Sets the max block size. + +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 SetMaxBlockSize(uint value); +``` + +Parameter: + +- value: the max block size + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetMaxBlockSize(1024); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..47b195a5b --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md @@ -0,0 +1,55 @@ +# SetMaxBlockSystemFee Method (uint) + +Sets the maximum system fee for the 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# +public static extern bool SetMaxBlockSystemFee(long value); +``` + +Parameter: + +- value: the maximum system fee for the block + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetMaxBlockSystemFee(4007800L); + return result; + } +} +``` + +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. + +[Back](../Policy.md) \ No newline at end of file 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 new file mode 100644 index 000000000..e2ff47195 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md @@ -0,0 +1,51 @@ +# SetMaxTransactionsPerBlock Method (uint) + +Sets max transaction per 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# +public static extern bool SetMaxTransactionsPerBlock(uint value); +``` + +Parameter: + +- value: Maximum number of transactions to be set + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + bool result = Policy.SetMaxTransactionsPerBlock(1024); + return result; + } +} +``` + +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 new file mode 100644 index 000000000..e6ab01dd4 --- /dev/null +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md @@ -0,0 +1,50 @@ +# UnblockAccount Method (UInt160) + +Unblocks accounts. + +Namespace: [Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +Assembly: Neo.SmartContract.Framework + +## Syntax + +```c# +public static extern bool UnblockAccount(UInt160 account); +``` + +Parameter: + +- account: The script hash of the account to be unblocked. + +## Example + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + + public static object Main() + { + bool result = Policy.UnblockAccount(account); + return result; + } +} +``` + +Response body: + +```json +{ + "Type":"Boolean", + "value":"true" +} +``` + +Response description: + +- true: The account is successfully unblocked. + +- Others: failed. + +[Back](../Policy.md) + diff --git a/docs/en-us/reference/scapi/fw/dotnet/neo/TriggerType.md b/docs/en-us/reference/scapi/fw/dotnet/neo/TriggerType.md index e4c35bca7..7ebd07d5c 100644 --- a/docs/en-us/reference/scapi/fw/dotnet/neo/TriggerType.md +++ b/docs/en-us/reference/scapi/fw/dotnet/neo/TriggerType.md @@ -2,7 +2,7 @@ This enumeration represents the type of smart contract triggers. Triggers enable the contract to execute different logic under different usage scenarios. -For more information about triggers, refer to [Smart Contract Basics](../../../../../sc/write/basics.md). +For more information about triggers, refer to [Smart Contract Basics](../../../../../develop/write/basics.md). Namespace: [Neo.SmartContract.Framework.Services.Neo](../neo.md) diff --git a/docs/en-us/sc/migrate.md b/docs/en-us/sc/migrate.md deleted file mode 100644 index 96a9c969d..000000000 --- a/docs/en-us/sc/migrate.md +++ /dev/null @@ -1,115 +0,0 @@ -# Contract Migration and Destruction - -Smart contracts support to be migrated or destroyed after release. Before you can do that you need to reserve the specific interfaces in the old contracts. - -## Contract Migration - -In some cases you want to upgrade the smart contracts deployed on the blockchain or migrate the storage of a contract into another new contract, you need to migrate smart contracts. - -This tutorial is based on: - -- The example created in Visual Studio 2017 -- NeoSmartContractPlugin v2.9.3 -- The latest [Neo-GUI](https://github.com/neo-project/neo-gui/releases) - -### Implementing the migrate interface -To enable migration function, you need to implement the migrate interface in the contract, as shown below: - -```c# - ... - public static object Main(string method, params object[] args) - { - - ... - if (method == "migrate") - { - if (args.Length < 9) return false; - byte[] script = (byte[])args[0]; - byte[] plist = (byte[])args[1]; - byte rtype = (byte)args[2]; - ContractPropertyState cps = (ContractPropertyState)args[3]; - string name = (string)args[4]; - string version = (string)args[5]; - string author = (string)args[6]; - string email = (string)args[7]; - string description = (string)args[8]; - return Migrate(script, - plist, - rtype, - cps, - name, - version, - author, - email, - description); - } - ... - } - private static Boolean Migrate(byte[] script, - byte[] plist, - byte rtype, - ContractPropertyState cps, - string name, - string version, - string author, - string email, - string description) - { - var contract = Contract.Migrate(script, - plist, - rtype, - cps, - name, - version, - author, - email, - description); - return true; - } - ... // Some code segments are omitted -``` - -If you want to migrate the contract later, you must implement the migrate interface in the contract prior to deployment. For more information, refer to [Deploying and Invoking Smart Contracts](deploy/deploy.md). - -### Migrating the contract -With your new contract in hand, let's invoke the migrate interface in your old contract using NEO-GUI. - -1. In NEO-GUI, click `Advanced` > `Deploy Contract`,and then `Load` the new contract. Copy the contract script and scripthash for later use. - -2. Click `Advanced` > `Invoke Contract`,and enter the old contract ScriptHash. The deployed contract information is displayed. - - ![调用合约](assets/migrate_m1.png) - -3. Click `Invoke` and then enter necessary parameters required for invoking the migrate interface. Note that the first parameter value must be filled with the new contract script obtained in the first step. - - ![输入参数](assets/migrate_m2.png) - -4. Once completed, click `Test` to view the result. - - You will find the value 1-True is returned and the invoking fee is 491 GAS. - - ![](assets/migrate_m3.png) - -5. Click `Invoke` and wait for blockchain's verification. - -6. Once the transaction confirmed, enter the new contract ScriptHash in the Invoke Contract window. The new contract information is displayed. - - ![新合约](assets/migrate_m4.png) - -7. Enter the old contract ScriptHash again,you will no longer find the information displayed. - - ![旧合约](assets/migrate_m5.png) - -That indicates the storage has been migrated from the old contract into the new contract, and meanwhile the old contract has been destroyed. - -## Contract Destruction - -To destroy a contract, you need to reserve the destruction interface in the contract. - -The contract destruction mainly calls the `Neo.Contract.Destroy` method: - -```c# -void Destroy(); -``` - -The `Destroy` method accepts no parameters, and it will delete contract and the storage area. \ No newline at end of file diff --git a/docs/en-us/toc.yml b/docs/en-us/toc.yml index a28d84a76..0aab8c09e 100644 --- a/docs/en-us/toc.yml +++ b/docs/en-us/toc.yml @@ -2,6 +2,48 @@ href: /v3/docs/en-us/index.md - name: Glossary href: /v3/docs/en-us/glossary.md +- name: Getting Started (C#) + items: + - name: Before You Begin + href: /v3/docs/en-us/gettingstarted/prerequisites.md + - name: Setting up local network + href: /v3/docs/en-us/gettingstarted/enviroment.md + - name: Compiling a Contract Sample + href: /v3/docs/en-us/gettingstarted/develop.md + - name: Deploying and Invoking the Contract + href: /v3/docs/en-us/gettingstarted/deploy.md +- name: Neo Basics + - name: Main Concepts + - name: Blockchain Models + - name: Block + href: /v3/docs/en-us/basic/concept/blockchain/block.md + - name: Tokens + href: /v3/docs/en-us/basic/concept/blockchain/token_model.md + - name: Charging Model + href: /v3/docs/en-us/basic/concept/charging_model.md + - name: Cryptography + href: + - name: Encode Algorithm + href: /v3/docs/en-us/basic/concept/cryptography/encode_algorithm.md + - name: Hash Algorithm + href: /v3/docs/en-us/basic/concept/cryptography/hash_algorithm.md + - name: Encryption Algorithm + href: /v3/docs/en-us/basic/concept/cryptography/encryption_algorithm.md + - name: Big and Little Endian Usage + href: /v3/docs/en-us/basic/concept/endian.md + - name: Wallet + href: /v3/docs/en-us/basic/concept/wallets.md + - name: Transaction + href: /v3/docs/en-us/basic/concept/transaction.md + - name: Consensus + - name: Overview + href: /v3/docs/en-us/basic/consensus/dbft.md + - name: Consensus Algorithm + href: /v3/docs/en-us/basic/consensus/consensus_algorithm.md + - name: Consensus Protocol + href: /v3/docs/en-us/basic/consensus/consensus_protocol.md + - name: Election + href: /v3/docs/en-us/basic/consensus/vote_validator.md - name: Neo Node items: - name: Introduction @@ -26,115 +68,63 @@ href: /v3/docs/en-us/node/gui/contract.md - name: Advanced Functions href: /v3/docs/en-us/node/gui/advanced.md -- name: Neo Network - items: - - name: Main Net and Test Net - href: /v3/docs/en-us/network/testnet.md - - name: Setting up Private Chain - items: - - name: Solo Mode - href: /v3/docs/en-us/network/private-chain/solo.md - - name: Multiple Nodes - href: /v3/docs/en-us/network/private-chain/private-chain2.md -- name: Smart Contract Development +- name: Development Guide items: - - name: Getting Started (C#) + - name: Neo Network items: - - name: Before You Begin - href: /v3/docs/en-us/sc/gettingstarted/prerequisites.md - - name: Setting up local network - href: /v3/docs/en-us/sc/gettingstarted/enviroment.md - - name: Compiling a Contract Sample - href: /v3/docs/en-us/sc/gettingstarted/develop.md - - name: Deploying and Invoking the Contract - href: /v3/docs/en-us/sc/gettingstarted/deploy.md + - name: Main Net and Test Net + href: /v3/docs/en-us/develop/network/testnet.md + - name: Setting up Private Chain + items: + - name: Solo Mode + href: /v3/docs/en-us/develop/network/private-chain/solo.md + - name: Multiple Nodes + href: /v3/docs/en-us/develop/network/private-chain/private-chain2.md - name: Writing smart contracts items: - name: Basics - href: /v3/docs/en-us/sc/write/basics.md + href: /v3/docs/en-us/develop/write/basics.md - name: Limitations - href: /v3/docs/en-us/sc/write/limitation.md - - name: NEP-5 - href: /v3/docs/en-us/sc/write/nep5.md - - name: Deploying and Invoking Smart Contracts - - name: Deploying Smart Contracts - href: /v3/docs/en-us/sc/deploy/deploy.md - - name: Invoking Smart Contracts - href: /v3/docs/en-us/sc/deploy/invoke.md - - name: Contract Migration and Destruction - href: /v3/docs/en-us/sc/migrate.md - - name: Fees - href: /v3/docs/en-us/sc/fees.md + href: /v3/docs/en-us/develop/write/limitation.md + - name: NEP-17 + href: /v3/docs/en-us/develop/write/nep5.md + - name: Contract Migration and Destruction + href: /v3/docs/en-us/develop/migrate.md - name: Contract Samples items: - name: Hello World - href: /v3/docs/en-us/sc/sample/HelloWorld.md + href: /v3/docs/en-us/develop/sample/HelloWorld.md - name: Domain - href: /v3/docs/en-us/sc/sample/Domain.md + href: /v3/docs/en-us/develop/sample/Domain.md - name: Storage - href: /v3/docs/en-us/sc/sample/storage.md -- name: Neo Tools Development - - name: Main Concepts - - name: Blockchain Models - - name: Block - href: /v3/docs/en-us/tooldev/concept/blockchain/block.md - - name: Tokens - href: /v3/docs/en-us/tooldev/concept/blockchain/token_model.md - - name: Charging Model - href: /v3/docs/en-us/tooldev/concept/charging_model.md - - name: Cryptography - href: - - name: Encode Algorithm - href: /v3/docs/en-us/tooldev/concept/cryptography/encode_algorithm.md - - name: Hash Algorithm - href: /v3/docs/en-us/tooldev/concept/cryptography/hash_algorithm.md - - name: Encryption Algorithm - href: /v3/docs/en-us/tooldev/concept/cryptography/encryption_algorithm.md - - name: Big and Little Endian Usage - href: /v3/docs/en-us/tooldev/concept/endian.md - - name: Consensus - - name: Consensus Algorithm - href: /v3/docs/en-us/tooldev/consensus/consensus_algorithm.md - - name: Consensus Protocol - href: /v3/docs/en-us/tooldev/consensus/consensus_protocol.md - - name: Election - href: /v3/docs/en-us/tooldev/consensus/vote_validator.md - - name: Wallet - href: /v3/docs/en-us/tooldev/wallets.md - - name: Transaction - - name: Transaction - href: /v3/docs/en-us/tooldev/transaction/transaction.md - - name: Neo SDK - items: - - name: About Neo SDK - href: /v3/docs/en-us/tooldev/sdk/introduction.md - - name: RPC Invocation Methods - href: /v3/docs/en-us/tooldev/sdk/rpc.md - - name: Getting Blockchain Information - href: /v3/docs/en-us/tooldev/sdk/monitor.md - - name: Wallet Interfaces - href: /v3/docs/en-us/tooldev/sdk/wallet.md - - name: Transaction Construction - href: /v3/docs/en-us/tooldev/sdk/transaction.md - - name: Deploying and Invoking Contracts - href: /v3/docs/en-us/tooldev/sdk/contract.md -- name: Document for Exchange Developers - items: - - name: Overview - href: /v3/docs/en-us/exchange/general.md - - name: Deploying Neo nodes - href: /v3/docs/en-us/exchange/deploynode.md - - name: Using Neo-CLI - href: /v3/docs/en-us/exchange/client.md - - name: Dealing with assets transactions - href: /v3/docs/en-us/exchange/transaction.md - - name: Distributing GAS to users - href: /v3/docs/en-us/exchange/gas.md + href: /v3/docs/en-us/develop/sample/storage.md + - name: Deploying and Invoking Smart Contracts + - name: Deploying Smart Contracts + href: /v3/docs/en-us/develop/deploy/deploy.md + - name: Invoking Smart Contracts + href: /v3/docs/en-us/develop/deploy/invoke.md + - name: Development Tools + - name: Neo SDK + items: + - name: About Neo SDK + href: /v3/docs/en-us/develop/tool/sdk/introduction.md + - name: RPC Invocation Methods + href: /v3/docs/en-us/develop/tool/sdk/rpc.md + - name: Getting Blockchain Information + href: /v3/docs/en-us/develop/tool/sdk/monitor.md + - name: Wallet Interfaces + href: /v3/docs/en-us/develop/tool/sdk/wallet.md + - name: Transaction Construction + href: /v3/docs/en-us/develop/tool/sdk/transaction.md + - name: Deploying and Invoking Contracts + href: /v3/docs/en-us/develop/tool/sdk/contract.md - name: Reference items: - name: RPC API - name: API Reference href: /v3/docs/en-us/reference/rpc/latest-version/api.md + - name: calculatenetworkfee + href: /v3/docs/en-us/reference/rpc/latest-version/api/calculatenetworkfee.md - name: closewallet href: /v3/docs/en-us/reference/rpc/latest-version/api/closewallet.md - name: dumpprivkey @@ -173,10 +163,12 @@ 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: getvalidators - href: /v3/docs/en-us/reference/rpc/latest-version/api/getvalidators.md + - name: getcommittee + href: /v3/docs/en-us/reference/rpc/latest-version/api/getcommittee.md - name: getversion href: /v3/docs/en-us/reference/rpc/latest-version/api/getversion.md - name: importprivkey @@ -232,16 +224,22 @@ href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Crypto.md - name: Enumerator href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Enumerator.md + - name: Gas + href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Gas.md - name: Helper href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Helper.md - name: Iterator href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Iterator.md - name: Json href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Json.md - - name: Native - href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Native.md + - name: Neo + href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Neo.md - name: Notification href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Notification.md + - name: Policy + href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Policy.md + - name: Oracle + href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Oracle.md - name: Runtime href: /v3/docs/en-us/reference/scapi/fw/dotnet/neo/Runtime.md - name: Storage @@ -262,5 +260,19 @@ href: /v3/docs/en-us/reference/scapi/fw/dotnet/System/ExecutionEngine.md - name: Governance API href: /v3/docs/en-us/reference/governance_api.md + - name: Fees + href: /v3/docs/en-us/reference/fees.md - name: NeoVM Instructions - href: /v3/docs/en-us/reference/neo_vm.md \ No newline at end of file + href: /v3/docs/en-us/reference/neo_vm.md +- name: Document for Exchange Developers + items: + - name: Overview + href: /v3/docs/en-us/exchange/general.md + - name: Deploying Neo nodes + href: /v3/docs/en-us/exchange/deploynode.md + - name: Using Neo-CLI + href: /v3/docs/en-us/exchange/client.md + - name: Dealing with assets transactions + href: /v3/docs/en-us/exchange/transaction.md + - name: Distributing GAS to users + href: /v3/docs/en-us/exchange/gas.md \ No newline at end of file diff --git a/docs/en-us/tooldev/neo_cli_structure.md b/docs/en-us/tooldev/neo_cli_structure.md deleted file mode 100644 index f2fb08f5b..000000000 --- a/docs/en-us/tooldev/neo_cli_structure.md +++ /dev/null @@ -1,229 +0,0 @@ -# Neo-CLI Structure - -NEO is a blockchain system based on a peer-to-peer network. It provides a digital asset ledge based on the UTXO model and an execution environment for smart contracts based on the NEO virtual machine. This chapter describes the overall structure and basic behavior of the node program Neo-CLI in the network. - -## The Whole Network - -[![neo p2p network](images/neo_cli_structure/neo-p2p-network.png)](../images/neo_cli_structure/neo-p2p-network.png) - -Each node in the network runs a Neo-CLI program or a protocol-compatible program. Among them, the consensus nodes are involved in the consensus process. Non-consensus nodes are not involved in the consensus process. The consensus process will be described in subsequent chapters. - -## Neo-CLI - -The structure of Neo-CLI is shown below. (Some parts of structure may change due to version upgrade) - -[![NEO-CLI structure](images/neo_cli_structure/NEO-CLI.png)](../images/neo_cli_structure/NEO-CLI.png) - -### Neo-CLI command line tools - -Neo-CLI is a command line program which provides basic functionality for interacting with the blockchain through the command line console. For more information, refer to [Neo-CLI command line tools](../node/cli/cli.md). - -### Ledger API - -The ledger API defines the basic data types of the UTXO model, including basic data structures such as transaction, block, and validator. The details are covered in subsequent chapters. - -### Wallets - -NEO officially provides two types of wallets, one is the sqlite database format wallet, and the other is the NEP-6 wallet. The advantage of the sqlite format wallet is that its performance is relatively better. The disadvantage is that its compatible platforms are not as many as the NEP-6 wallet. - -### LevelDBStore / Blockchain - -Blockchain data management module based on leveldb which provides storage and query services of blockchain data to the other parts. - -### LocalNode - -It is the module for network communication between nodes. It is responsible for exchanging information with other nodes in the network. Details are covered in subsequent chapters. - -### RpcServer - -A module that provides an interface for RPC requests. For more information, refer to [RPC API](../reference/rpc/latest-version/api.md). - -### ConsensusService - -In NEO's network, only consensus nodes need to start consensus service. The consensus node exchanges information with other consensus nodes through the peer-to-peer network to complete the process of generating new blocks in the blockchain. Details will be covered in subsequent chapters. - -### Plugin - -The logic of some specific modules in the blockchain is implemented in the form of a plugin to facilitate customization and debugging of specific functions. The following four categories are included: - - - **ILogPlugin** : The storage plugin for execution result of smart contracts. - - **IPolicyPlugin** : The sorting strategy plugin for transactions when generating new blocks. - - **IRpcPlugin** : A plugin for RPC module. - - **IPersistencePlugin** : The customized behavior plugin when the node receives a new block and saves it to the local database. - -### NeoVM - -A virtual machine implemented by NEO. It's used to execute verification scripts and smart contracts. Details will be covered in subsequent chapters. - -The ApplicationEngine is a layer of encapsulation of the NEO VM. The NEO VM is designed as a standalone module which can be deployed outside of the blockchain. ApplicationEngine is more closely linked to the blockchain itself. - -## Configuration files - -The node program Neo-CLI accesses the following configuration files during execution. - - - **config.json** : Basic configuration file - - **protocol.json** : Protocol configuration file - -### config.json - -It defines basic configurations such as database path, network configuration, and startup settings. - -```json -{ - "ApplicationConfiguration": { - "Paths": { - "Chain": "Chain_{0}", - "Index": "Index_{0}" - }, - "P2P": { - "Port": 10333, - "WsPort": 10334 - }, - "RPC": { - "BindAddress": "127.0.0.1", - "Port": 10332, - "SslCert": "", - "SslCertPassword": "" - }, - "UnlockWallet": { - "Path": "", - "Password": "", - "StartConsensus": false, - "IsActive": false - } - } -} -``` - -Attribute Description: - - - Paths/Chain : The prefix of storage directory for the blockchain database. The suffix of the storage directory is an 8-digit hexadecimal called the MagicNumber. MagicNumber will be mentioned later. - - Paths/Index : The prefix of storage directory for the wallet index. - - P2P/Port: The listening port number of the TCP/IP protocol connection between network nodes. - - P2P/WsPort : The listening port number of the WebSocket protocol connection between network nodes. - - RPC/BindAddress : The listening IP address of the JSON-RPC service. - - RPC/Port : The listening port number of the JSON-RPC service. - - RPC/SslCert : Authentication of the secure connection of the JSON-RPC service. When the default is empty, no secure connection is used. - - RPC/SslCertPassword : The password for the secure connection of the JSON-RPC service. When the default is empty, no secure connection is used. - - UnlockWallet/IsActive : Whether to automatically unlock the wallet when starting the network node. - - UnlockWallet/Path : The path of the wallet file to unlock when starting the network node. - - UnlockWallet/Password : The password to unlock the wallet file when starting the network node. - - UnlockWallet/StartConsensus : Whether to automatically start consensus when starting a network node. Auto-starting consensus relies on automatically unlocking the wallet. - -`config.mainnet.json` and `config.testnet.json` are two backup files that store the configuration for the mainnet and testnet. - -### protocol.json - -It defines protocol-level variables, public keys of spare consensus nodes, list of seed nodes, and system fee prices. - -```json -{ - "ProtocolConfiguration": { - "Magic": 7630401, - "AddressVersion": 23, - "SecondsPerBlock": 15, - "StandbyValidators": [ - "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", - "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", - "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", - "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554", - "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d", - "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e", - "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70" - ], - "SeedList": [ - "seed1.ngd.network:10333", - "seed2.ngd.network:10333", - "seed3.ngd.network:10333", - "seed4.ngd.network:10333", - "seed5.ngd.network:10333", - "seed6.ngd.network:10333", - "seed7.ngd.network:10333", - "seed8.ngd.network:10333", - "seed9.ngd.network:10333", - "seed10.ngd.network:10333", - "seed1.neo.org:10333", - "seed2.neo.org:10333", - "seed3.neo.org:10333", - "seed4.neo.org:10333", - "seed5.neo.org:10333" - ], - "SystemFee": { - "EnrollmentTransaction": 1000, - "IssueTransaction": 500, - "PublishTransaction": 500, - "RegisterTransaction": 10000 - } - } -} -``` - -Attribute Description: - - - Magic : Magic Number. Mainnet: 7630401 (0x00746E41) Testnet: 1953787457 (0x74746E41). When building a private chain network, the magic number can be changed to any integer, but the magic number used by all the nodes in the same network must be the same. - - AddressVersion : The address version. Fixed value 23 - - SecondsPerBlock : The block interval. The consensus nodes in the same network must have the same value. - - StandbyValidators: A list of public keys of the alternate consensus node. - - SeedList : List of seed nodes. The seed node is not a consensus node. New nodes in the network can ask the seed nodes for the IP addresses and port number of other nodes. - - SystemFee: System Fee Definition. - -protocol.mainnet.json and protocol.testnet.json are two backup files that store the configuration for the mainnet and the testnet. - -> [!NOTE] -> -> - In Neo-CLI 2.7.6, a temporary file peers.dat was used to save IP addresses of known nodes, Neo-CLI 2.9.0+ no longer uses the file. -> - If Neo-CLI meets an exception during execution and is terminated, the error's content will be written to a file (error.log) for debugging. - -## Brief startup process - -### Neo-CLI startup - -1. Initialize LevelDBStore and create or open the leveldb database. - -2. Start LocalNode asynchronously to start peer-to-peer network communication. - -3. Open wallet and start the consensus service according to the configuration file. - -4. Start the JSON-RPC service based on the command line argument (rpc). - -5. Start a command line loop and execute the commands entered in the command prompt. - -6. When the system exits, stop the RPC service. Stop the LocalNode and peer-to-peer network communication. Close the leveldb database. - -### LevelDBStore initialization - -1. Open the leveldb database or create the database if it does not exist. - -2. Read the data format version number. If the version number is less than 2.9.1, clear the database and then write the latest version number. - -### Blockchain initialization - -1. Read the list of block headers of the blockchain from the database and save them in memory for fast index access (header_index). - -2. If there is no block information in the database, write the genesis block to the database. - -### LocalNode initialization - -1. Scan the IP address of all local network adapters and save them. - -2. Start a background loop and check the number of connections to other peers every 5 seconds. If it is less than the maximum number of connections (10), it will try to connect to more peers. If the information of other peers are unknown, it will connect to the seed nodes and then ask for the addresses and port number of other peers. - -3. If the device is in a LAN behind a NAT and does not have an IP address on the internet, it will try to discover the external IP address and set up a new port mapping using the Internet Gateway Device Protocol(IGD) implemented as part of UPnp. Then it will start listening on port for TCP/IP connections and start listening on port for websocket connections on the external IP address. - -4. Start listening on port locally and accept TCP/IP connections from other peers. - -5. Start the WebSocket service locally and accept WebSocket connections from other peers. - -### ConsensusService initialization - -  1. Initialize the consensus context - -  2. Listen to consensus messages and process them - -### JSON-RPC service initialization - -Listen on the specified address and port. Enable secure links (https) if specified. - -### Other initialization - -Initialize all plugins. For more information about plugins, refer to [Install Plugins](../node/cli/setup.md). diff --git a/docs/en-us/tooldev/network-protocol.md b/docs/en-us/tooldev/network-protocol.md deleted file mode 100644 index 80b3e9bb6..000000000 --- a/docs/en-us/tooldev/network-protocol.md +++ /dev/null @@ -1,121 +0,0 @@ -# Network Structure: P2P - -NEO uses P2P network structure and TCP/IP protocol for transmission. - -There are 2 types of node in the network, ordinary node and consensus node. The former can perform transaction/block broadcasting, receiving and relaying, while the latter can furthermore perform block construction. - -NEO's network protocol standard is similiar to Bitcoin's, but varies a lot in block / transaction data structure. - -> [!NOTE] -> -> - In NEO network, seed node is not equal to consensus node. It's a kind of ordinary node which provides node list query service to other nodes. -> - NEO network also supports WebSocket connection and supports constructing node in a LAN by using UPnP protocol (Optional). - -## Transmission Protocol and Port - -| Protocol | Port (Main net) | Port (Test net) | -| --- | --- | --- | -| TCP/IP | 10333 | 20333 | -| WebSocket | 10334 | 20334 | - -> [!Note] -> -> The ports mentioned above can be set to any unused ones when constructing a NEO private chain. Ports of the nodes in a private chain can also be different. - -## Message - -Message's basic format is as follows: - -| Type | Name | Description | -| --- | --- | --- | -| uint | Magic | Magic number to avoid network conflict | -| string(12) | Command | String message name (Fill with zeros if shorter than 12 byte) | -| int | Payload length | Payload length | -| uint | Payload Checksum | Payload verification to avoid falsification and transmission errors | -| byte[] | Payload | Message text, varying by message type | - -## Command List - -| Name | Uniqueness | High priority | Reserved | Description | -| --- | --- | --- | --- | --- | -| getaddr | 〇 | 〇 | | Queries address and port numer of other nodes. | -| addr | 〇 | | | Answers getaddr message with at most 200 records of succesfully connected node addresses and port numbers. | -| filteradd | | 〇 | | Adds data to bloom_filter for SPV wallet. | -| filterclear | | 〇 | | Remove bloom_filter for SPV wallet. | -| filterload | | 〇 | | Initialize bloom_filter for SPV wallet. | -| getblocks | 〇 | | | Specify the start and end hash values to get the details of several consecutive blocks. | -| getdata | | | | Queries other nodes for Inventory objects of specified type and hash.
Current usage:
1)Sending get-transaction query during consensus process.
2)Sending getdata message upon receiving inv message. | -| block | | | | Answers getdata message with Block of specified hash. | -| consensus | | 〇 | | Answers getdata message with consensus data of specified hash. | -| tx | | | | Answering getdata message for a transaction with specified hash. | -| getheaders | 〇 | | | Node with fewer information queries for block head after two nodes establish connection. | -| headers | | | | Answers getheaders message with at most 2000 block header items. | -| inv | | | | Send Inventory hash array of specified type and hash (only hash value rather than complete information). Inventory types include Block, Transaction, and Consensus). Currently inv message is used in these scenarios:
1)Sending transaction in consensus process.
2)Replying getblocks message with no more than 500 blocks.
3) Replying mempool message with all transactions in memory pool.
4) Relaying an Inventory.
5) Relaying a batch of transactions. | -| mempool | 〇 | 〇 | | Query for all transactions in the memory pool of the connected node. | -| version | - | 〇 | - | First instruction: with information like block header height, etc. | -| verack | - | 〇 | - | Sencond instruction: handshake Version | -| merkleblock | | | 〇 | Sending process is implemented while receiving is not. It's for SPV wallet. | -| ping | | | | Standard ping message | -| pong | | | | Response to ping message | -| alert | | 〇 | 〇 | Unimplemented | -| notfound | | | 〇 | Unimplemented | -| reject | | | 〇 | Unimplemented | -| others | | | 〇 | Neglected | - -> [!NOTE] -> -> - Uniqueness:only one such message in message queue at the same time. -> - High priority:the system needs to guarantee that higher priority messages are transmitted and processed first. - -## Conversation protocol - -1. Firstly a NEO node tries to connect to those seed nodes. - -2. The node firstly sends `version` message upon connecting successfully and waits for `version` message. Local block height is contained in `version` message. - -3. The node sends `verack` message and waits for `verack` message to complete handshake. - -4. If the local block height is lower than the other side's height, the node sends `getheaders` message. - -5. The other side sends `headers` message which contains no more than 2000 block headers upon receiving `getheaders` message. - -6. If block header information has been synchronized and local block height is lower than the other side's, send `getblocks` message. - -7. The other side will send `inv` message which contains no more than 500 block hashes upon receiving `getblocks` message. - -8. The node determines whether the complete block information is needed based on each block hash upon receiving the `inv` message. If so, the node sends `getdata` message querying for complete block information. - -9. The other side sends `block` message which contains complete block information upon receiving `getdata` message. - -10. NEO nodes check the number of connections every 5 seconds. The node connects to backup nodes initiatively if connection count is less than 10. The node sends `getaddr` message to connected nodes to query information about other nodes in the network if backup nodes are not enough. - -11. The other side sends `addr` message which contains address and port information of no more than 200 nodes upon receiving `getaddr` message. - -12. The node uses hash to manage relatively large data like consensus messages / block / transaction data, to avoid receiving duplicate messages from different nodes. - -13. The node is responsible for relaying received consensus messages / block / transaction data to other nodes by `inv` message. - -## Conversation Sequence Instance - -| Message direction | Message type | Description | -| --- | --- | --- | -| send | version | Send version to perform 1st handshake | -| receive | version | Receive version to perform 1st handshake | -| send | verack | Send verack to perform 2nd handshake | -| receive | verack | Receive verack to perform 2nd handshake | -| send | getheaders | Send getheaders to retrieve block head | -| receive | headers | Receive block headers | -| send | getblocks | Send getblocks to get blocks | -| receive | inv(blocks) | Receive inv hash of some blocks | -| send | getdata(blocks) | Send getdata to retrieve complete block | -| receive | inv(consensus) | Receive inv hash of consensus data | -| send | getdata(consensus) | Send getdata to retrieve consensus data of specified hash | -| receive | consensus | Receive complete consensus data | -| send | inv(consensus) | Relay received consensus data's hash to other nodes | -| receive | block | Receive a complete block | -| send | inv(block) | Relay block hash | -| receive | block | Receive a complete block | -| send | inv(block) | Relay block hash | -| receive | block | Receive a complete block | -| send | inv(block) | Relay block hash | -| ... | ... | ... | diff --git a/docs/en-us/tooldev/sdk/contract.md b/docs/en-us/tooldev/sdk/contract.md deleted file mode 100644 index ef7ce1f29..000000000 --- a/docs/en-us/tooldev/sdk/contract.md +++ /dev/null @@ -1,181 +0,0 @@ -# Deploying and Invoking Contracts - -In Neo3 most of the functions are provided by contracts. ScriptHash is the unique identifier of the contract, and it is usually a necessary parameter for invoking contracts. - -This document introduces the following SDK features: - -- The construction method of contract deployment transaction -- Invoking methods in the contract under read-only mode -- `Nep5API` class that encapsulates the methods for invoking NEP5 contracts - -## 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. - -```c# -// create the deploy contract transaction -Transaction transaction = contractClient.CreateDeployContractTx(script, manifest, senderKey); -``` - -After the transaction is constructed, you need to broadcast it on the blockchain: - -```c# -// Broadcast the transaction over the Neo network -client.SendRawTransaction(transaction); -Console.WriteLine($"Transaction {transaction.Hash.ToString()} is broadcasted!"); -``` - -After the transaction is added to the blockchain you can get the transaction execution status to check if the contract is deployed successfully: - -```c# -// print a message after the transaction is on chain -WalletAPI neoAPI = new WalletAPI(client); -neoAPI.WaitTransaction(transaction) - .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - -``` - -Here is the complete code: - -```c# -using Neo.Network.P2P.Payloads; -using Neo.Network.RPC; -using Neo.SmartContract; -using Neo.SmartContract.Manifest; -using Neo.Wallets; -using System; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - 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]; - - // we use default ContractManifest in this example - ContractManifest manifest = ContractManifest.CreateDefault(script.ToScriptHash()); - - // deploying contract needs sender to pay the system fee - KeyPair senderKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - - // create the deploy transaction - Transaction transaction = contractClient.CreateDeployContractTx(script, manifest, senderKey); - - // Broadcast the transaction over the Neo network - client.SendRawTransaction(transaction); - 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) - .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - - Console.ReadKey(); - } - } -} -``` - -## 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. - -```c# -// choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); -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(); -``` - -Or you can use `MakeScript` to construct the script you want to execute and then invoke `InvokeScript` to get the execution result. - -```c# -// construct the script you want to run in test mode -byte[] script = scriptHash.MakeScript("name"); -// call invoke script -name = client.InvokeScript(script).Stack.Single().ToStackItem().GetString(); -``` - -## Contract invocation (on-chain transactions) - -Generally invoking a deployed contract on the blockchain contains the following steps: - -1. Construct the script to invoke - - 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 - UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); - ``` - -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; - ``` - -3. Broadcast the transaction on the blockchain: - - ```c# - // broadcasts the transaction over the Neo network - client.SendRawTransaction(tx); - ``` - -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: - - ```c# - // print a message after the transaction is on chain - WalletAPI neoAPI = new WalletAPI(client); - neoAPI.WaitTransaction(tx) - .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); - ``` - -For complete code refer to [Transaction Construction](transaction.md). - -## NEP-5 Contracts - -`Nep5API` encapsulates the method that generates transfer transactions. The above transaction process can be simplified to: - -```c# -Nep5API nep5API = new Nep5API(client); -Transaction tx = nep5API.CreateTransferTx(scriptHash, sendKey, receiver, 1); -``` - -Additionally, `Nep5API` also provides a set of simple methods to get data: - -```c# -// get nep5 name -string name = nep5API.Name(scriptHash); - -// get nep5 symbol -string symbol = nep5API.Symbol(scriptHash); - -// get nep5 token decimals -uint decimals = nep5API.Decimals(scriptHash); - -// get nep5 token total supply -BigInteger totalSupply = nep5API.TotalSupply(scriptHash); -``` - diff --git a/docs/en-us/tooldev/sdk/monitor.md b/docs/en-us/tooldev/sdk/monitor.md deleted file mode 100644 index 6307c77cd..000000000 --- a/docs/en-us/tooldev/sdk/monitor.md +++ /dev/null @@ -1,76 +0,0 @@ -# Getting Blockchain Information - -The `RPC` module provides methods to get basic information of blockchain data and status, such as block height, block content, transaction details, and contracts. - -For some specific information of contracts, such as the block maximum transaction number, system fee per byte, NEP-5 contract details, you need to invoke specific contract methods, which will be introduced in this document. - - -## Getting blockchain data from RPC interfaces - -Gets the latest block height or hash: - -```c# -// choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - -// get the highest block hash -string hash = client.GetBestBlockHash(); - -// get the highest block height -uint height = client.GetBlockCount() - 1; -``` - -Gets the specific data inside a block, including transaction list, etc. - -```c# -// get block data -RpcBlock block = client.GetBlock("166396"); - -// get block data with block hash -RpcBlock block = client.GetBlock("0x953f6efa29c740b68c87e0a060942056382a6912a0ddeddc2f6641acb92d9700"); -``` - -Gets the contract script, hash, and manifest through `RpcClient`: - -```c# -// get NEO contract state -ContractState contractState = client.GetContractState(NativeContract.NEO.Hash.ToString()); -``` - -For more information refer to [RPC invocation methods](rpc.md). - -## Getting policy information - -Invokes the method `policyAPI` in the native contract `PolicyContract` to get the Policy related information: - -```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 - -// get the system fee per byte -long feePerByte = policyAPI.GetFeePerByte(); // 1000, 0.00001000 GAS per byte - -// get the max size of one block -uint maxBlockSize = policyAPI.GetMaxBlockSize(); // 262144, (1024 * 256) bytes one block - -// get the max transaction count per block -uint maxTransactionsPerBlock = policyAPI.GetMaxTransactionsPerBlock(); // 512, max 512 transactions one block -``` - -## Getting NEP-5 contract information - -NEP5 is an asset standard for Neo3, such as NEO and GAS, both of which are assets based on NEP5 native contract. You can invoke `Nep5API` to get the name, mark, decimal place, and amount of the NEP5 contract. - -```c# -// get nep5 token info -Nep5API nep5API = new Nep5API(client); -RpcNep5TokenInfo tokenInfo = nep5API.GetTokenInfo(NativeContract.NEO.Hash); -``` - -## What's next? - -[Wallet Interfaces](wallet.md) - diff --git a/docs/en-us/tooldev/sdk/transaction.md b/docs/en-us/tooldev/sdk/transaction.md deleted file mode 100644 index 52cbe0b8c..000000000 --- a/docs/en-us/tooldev/sdk/transaction.md +++ /dev/null @@ -1,280 +0,0 @@ -# Transaction Construction - -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. - -## Transaction construction process - -1. Construct a transaction script to determine what functions the transaction will perform, such as a transfer transaction: - - ```c# - // construct the script, in this example, we will transfer 1 NEO to the receiver - UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); - ``` - -2. Initialize `TransactionManager` with `RpcClient ` and `ScriptHash ` of the sending account. - - ```c# - // initialize the TransactionManager with rpc client and the sender scripthash - TransactionManager txManager = new TransactionManager(client, sender); - ``` - -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. - - - single signature - - ```c# - // add signature for the transaction with sendKey - txManager.AddSignature(sendKey); - ``` - - multiple signatures - - ```c# - // add multi-signatures for the transaction with sendKey - txManager.AddMultiSig(receiverKey, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); - 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. - - ```c# - // create a multi-signature contract - 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 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. - -```c# -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; -using Utility = Neo.Network.RPC.Utility; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - - // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - 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 } }; - - // get the scripthash of the account you want to transfer to - UInt160 receiver = Utility.GetScriptHash("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"); - - // construct the script, in this example, we will transfer 1 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; - - // broadcasts the transaction over the Neo network. - client.SendRawTransaction(tx); - 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 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); -``` - -### Constructing a transaction to transfer to multi-signature account - -The following example implements a function that transfers 10 GAS to a multi-signature account. The scripthash of a multi-signature account is obtained from the scripthash of the multi-signature contract. As the sender is a normal account, the process of adding a signature is the same as last example. - -```c# -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; -using Utility = Neo.Network.RPC.Utility; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - - // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; - - // get the KeyPair of your accounts - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); - - // create multi-signatures contract - 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 - // 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); - 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 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. - -```c# -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; -using Utility = Neo.Network.RPC.Utility; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - - // get the KeyPair of your account - KeyPair receiverKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); - - // 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; - 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); - 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(); - } - } -} - -``` - -## What's next? - -[Contract Deployment and Invocation](contract.md) \ No newline at end of file diff --git a/docs/zh-cn/advanced/assets/oracle.png b/docs/zh-cn/advanced/assets/oracle.png new file mode 100644 index 000000000..45f5abed6 Binary files /dev/null and b/docs/zh-cn/advanced/assets/oracle.png differ diff --git a/docs/zh-cn/advanced/oracle.md b/docs/zh-cn/advanced/oracle.md new file mode 100644 index 000000000..ecd53d25c --- /dev/null +++ b/docs/zh-cn/advanced/oracle.md @@ -0,0 +1,84 @@ +# 预言机 + +预言机(Oracle)的出现解决了区块链无法向外部网络获取链外信息的问题,作为智能合约与外部世界通信的网关,Oracle 为区块链打开了一扇通往外部世界的窗户。对于链外请求到的数据,Oracle会通过多方验证来保证结果的准确性,并将结果以区块的形式在链上存储供合约访问。 + +## Neo Oracle + +Neo 提供了内置的 Oracle 服务,以原生合约的形式供其他合约调用。为了获取链外的网络数据,合约首先需构造Oracle请求交易,部署上链后则可调用 Neo Oracle 服务。 + +Oracle节点由委员会选举,除了 Oracle 节点外,网络中的所有节点也会协助交易的运行。当Oracle交易广播到网络中后,每个节点会将当前未验证的交易作为已知的哈希存储在其内存池中,并将其传递给其他节点。通过此过程,Oracle交易的Oracle节点将使用URL并应用过滤器来完成所有包含的请求。然后,通过将结果附加到Oracle交易的TransactionAttribute 部分,这些节点将就返回响应的数据达成共识。 + +一旦收集到足够的签名,就可以将Oracle交易视为已验证,并由共识节点将其存储在一个区块中,待区块上链后即可供合约访问。 + +Oracle 节点会收取一定交易费用。在 Neo 网络中,可用GAS支付Oracle交易。 + +![](assets/oracle.png) + +## Oracle 请求 + +| 字段 | 字节数 | 描述 | +| ---------------- | --------- | ---------------------------------------------- | +| Url | string | 请求的Url | +| Filter | string | 过滤器,可用于过滤无用数据 | +| CallbackContract | 20 bytes | 回调合约 | +| CallbackMethod | string | 回调方法名 | +| UserData | var bytes | 用户提供的额外数据 | +| GasForResponse | long | 获取响应所需的费用,由调用Oracle服务的合约设置 | + +### GasForResponse + +用于支付获取响应交易的费用,GasForResponse应不小于0.1GAS,否则无法发起Oracle请求。 + +### Filter + +过滤器用于在从数据源返回的结果中过滤出有用信息,其中Filter字段为JSONPath表达式,更多关于JSONPath的信息,可点击[此处](https://github.com/json-path/JsonPath)查看。 + +## Oracle 响应 + +在构建Response交易时会调用Oracle合约的`finish`方法,从而执行回调函数`CallbackMethod`,回调函数需要在请求交易合约内定义。回调函数通常需要以下几个字段: + +| 字段 | 字节数 | 描述 | +| -------- | --------- | ------------------ | +| Url | string | 请求的Url | +| UserData | var bytes | 用户提供的额外数据 | +| Code | byte | Oracle 响应编码 | +| Result | var bytes | 响应内容 | + +### Code +Code字段定义了响应交易的执行结果,包括以下五种类型: + +| 值 | 名称 | 说明 | 类型 | +| ------ | ----------- | ---------------- | ------ | +| `0x00` | `Success` | 执行成功 | `byte` | +| `0x01` | `NotFound` | 请求的信息不存在 | `byte` | +| `0x12` | `Timeout` | 执行超时 | `byte` | +| `0x14` | `Forbidden` | 无执行权限 | `byte` | +| `0xff` | `Error` | 执行错误 | `byte` | + +## 示例合约 + +```C# + public class OracleDemo : SmartContract + { + public static void DoRequest() + { + 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); + } + } +``` \ No newline at end of file diff --git a/docs/zh-cn/tooldev/concept/blockchain/block.md b/docs/zh-cn/basic/concept/blockchain/block.md similarity index 100% rename from docs/zh-cn/tooldev/concept/blockchain/block.md rename to docs/zh-cn/basic/concept/blockchain/block.md diff --git a/docs/zh-cn/tooldev/concept/blockchain/token_model.md b/docs/zh-cn/basic/concept/blockchain/token_model.md similarity index 100% rename from docs/zh-cn/tooldev/concept/blockchain/token_model.md rename to docs/zh-cn/basic/concept/blockchain/token_model.md diff --git a/docs/zh-cn/tooldev/concept/charging_model.md b/docs/zh-cn/basic/concept/charging_model.md similarity index 81% rename from docs/zh-cn/tooldev/concept/charging_model.md rename to docs/zh-cn/basic/concept/charging_model.md index ab2a12253..48b568d2e 100644 --- a/docs/zh-cn/tooldev/concept/charging_model.md +++ b/docs/zh-cn/basic/concept/charging_model.md @@ -1,6 +1,6 @@ # 收费模型 -用户在使用 Neo 网络时,需要支付一定的费用,总手续费包含系统费(System Fee)和网络费(Network Fee),费用单位为 GAS。费用分配如下图所示。 +用户在使用 Neo 网络时,需要支付一定的费用,总手续费包含系统费 (System Fee) 和网络费 (Network Fee),费用单位为 GAS。费用分配如下图所示。 [![economic model](../images/blockchain/economic_model.jpg)](../../images/blockchain/economic_model.jpg) @@ -11,5 +11,5 @@ ### 系统费 系统费是交易在虚拟机中执行消耗的资源费用,费用总额受合约脚本的指令数量和指令类型影响。 -此外,运行智能合约时,产生的系统调用或虚拟机对指令的执行,也会产生系统费用。具体收费信息请参见 [手续费](../../sc/fees.md)。 +此外,运行智能合约时,产生的系统调用或虚拟机对指令的执行,也会产生系统费用。具体收费信息请参见 [手续费](../../reference/fees.md)。 diff --git a/docs/zh-cn/tooldev/concept/cryptography/encode_algorithm.md b/docs/zh-cn/basic/concept/cryptography/encode_algorithm.md similarity index 100% rename from docs/zh-cn/tooldev/concept/cryptography/encode_algorithm.md rename to docs/zh-cn/basic/concept/cryptography/encode_algorithm.md diff --git a/docs/zh-cn/tooldev/concept/cryptography/encryption_algorithm.md b/docs/zh-cn/basic/concept/cryptography/encryption_algorithm.md similarity index 100% rename from docs/zh-cn/tooldev/concept/cryptography/encryption_algorithm.md rename to docs/zh-cn/basic/concept/cryptography/encryption_algorithm.md diff --git a/docs/zh-cn/tooldev/concept/cryptography/hash_algorithm.md b/docs/zh-cn/basic/concept/cryptography/hash_algorithm.md similarity index 100% rename from docs/zh-cn/tooldev/concept/cryptography/hash_algorithm.md rename to docs/zh-cn/basic/concept/cryptography/hash_algorithm.md diff --git a/docs/zh-cn/tooldev/concept/endian.md b/docs/zh-cn/basic/concept/endian.md similarity index 97% rename from docs/zh-cn/tooldev/concept/endian.md rename to docs/zh-cn/basic/concept/endian.md index 3b4003745..91581b38b 100644 --- a/docs/zh-cn/tooldev/concept/endian.md +++ b/docs/zh-cn/basic/concept/endian.md @@ -17,7 +17,7 @@ Neo 系统中所有的整数类型都是采用小端序 (Little Endian) 编码 - 大端序:0x946d6caa602a2b85fbeb7cf05335b2c3b124f1e4 - 小端序:e4f124b1c3b23553f07cebfb852b2a60aa6c6d94 -要进行钱包地址与ScriptHash的互转,以及ScriptHash的大小端序之间的互转,可以使用以下一种方法: +要进行钱包地址与ScriptHash的互转,以及ScriptHash的大小端序之间的互转,可以使用以下方法: - [数据转换工具](https://peterlinx.github.io/DataTransformationTools/) @@ -47,7 +47,7 @@ var outputs = new List{ new TransferOutput() #### 通过RPC接口调用合约 -这里以 [InvokeFunction](../../reference/rpc/latest-version/api/invokefunction.html) 为例,调用 NEP-5 合约的 balanceOf 方法。 +这里以 [InvokeFunction](../../reference/rpc/latest-version/api/invokefunction.md) 为例,调用 NEP-5 合约的 balanceOf 方法。 如果传入的地址,参数类型为Hash160,需要使用**大端序**的地址ScriptHash。 diff --git a/docs/zh-cn/tooldev/transaction/transaction.md b/docs/zh-cn/basic/concept/transaction.md similarity index 98% rename from docs/zh-cn/tooldev/transaction/transaction.md rename to docs/zh-cn/basic/concept/transaction.md index 6fc1c34da..4448ec564 100644 --- a/docs/zh-cn/tooldev/transaction/transaction.md +++ b/docs/zh-cn/basic/concept/transaction.md @@ -84,7 +84,7 @@ witnesses属性用于验证交易的有效性和完整性。Witness即“见证 #### 验证脚本 -验证脚本,常见为地址脚本,包括普通地址脚本和多签地址脚本,该地址脚本可以从钱包账户中直接获取,其构造方式,请参考[钱包-地址](../wallets.md#地址); +验证脚本,常见为地址脚本,包括普通地址脚本和多签地址脚本,该地址脚本可以从钱包账户中直接获取,其构造方式,请参考[钱包-地址](wallets.md#地址); 也可以为自定义的鉴权合约脚本。 diff --git a/docs/zh-cn/tooldev/wallets.md b/docs/zh-cn/basic/concept/wallets.md similarity index 97% rename from docs/zh-cn/tooldev/wallets.md rename to docs/zh-cn/basic/concept/wallets.md index 2409ab3f7..73430c44a 100644 --- a/docs/zh-cn/tooldev/wallets.md +++ b/docs/zh-cn/basic/concept/wallets.md @@ -8,7 +8,7 @@ Neo的钱包可以自行设计和修改,但需要满足一定的规则。 Neo 中,账户即合约,地址代表的为一段合约代码,从私钥到公钥,再到地址的流程如下图。 -![](images/wallets/privatekey-2-publickey-address.png) +![](../images/wallets/privatekey-2-publickey-address.png) ### 私钥 @@ -24,7 +24,7 @@ Neo 中,账户即合约,地址代表的为一段合约代码,从私钥到 wif 格式是在原有32字节数据前后添加前缀0x80和后缀0x01,并做Base58Check编码的字符串 -[![](images/wallets/wif_format.png)](../images/wallets/privateKey-wif.png) +[![](../images/wallets/wif_format.png)](../images/wallets/privateKey-wif.png) Example: @@ -70,7 +70,7 @@ Neo 中,账户即合约,地址代表的为一段合约代码,从私钥到 0x0C + 0x21 + 公钥(压缩型 33字节) + 0x0B + 0x41 + 0x0a906ad4 ``` - ![](images/wallets/account_address_script_checksign.png) + ![](../images/wallets/account_address_script_checksign.png) 2. 计算地址脚本合约哈希 (20字节,由地址脚本合约先做一次SHA256再做一次RIPEMD160得到) @@ -94,7 +94,7 @@ Neo 中,账户即合约,地址代表的为一段合约代码,从私钥到 ``` emitPush(N) + 0x0C + 0x21 + 公钥1(压缩型 33字节) + .... + 0x0C + 0x21 + 公钥m(压缩型 33字节) + emitPush(M) + 0x0B + 0x41 + 0x3073b3bb ``` - ![](images/wallets/account_address_script_multi_checksign.png) + ![](../images/wallets/account_address_script_multi_checksign.png) 2. 计算地址脚本合约哈希(20字节,地址脚本合约做一次sha256和riplemd160得到) @@ -230,7 +230,7 @@ NEP6钱包采用了以scrypt为核心算法的相关技术作为钱包私钥的 #### 加密方法 -![](images/wallets/nep2key.png) +![](../images/wallets/nep2key.png) 1. 由公钥计算地址,并获取`SHA256(SHA256(Address))`的前四个字节作为地址哈希 @@ -359,7 +359,7 @@ Java示例代码: 全节点钱包包含所有区块数据的备份,保存了所有链上数据,并且参与p2p网络通信,所以占用存储空间较大。 -Neo-CLI 和 Neo-GUI 都是全节点钱包,相关信息请参考 [Neo节点](../node/introduction.md)。 +Neo-CLI 和 Neo-GUI 都是全节点钱包,相关信息请参考 [Neo节点](../../node/introduction.md)。 ### SPV钱包 diff --git a/docs/zh-cn/tooldev/consensus/consensus_algorithm.md b/docs/zh-cn/basic/consensus/consensus_algorithm.md similarity index 94% rename from docs/zh-cn/tooldev/consensus/consensus_algorithm.md rename to docs/zh-cn/basic/consensus/consensus_algorithm.md index be97d2e9e..4a5b019b0 100644 --- a/docs/zh-cn/tooldev/consensus/consensus_algorithm.md +++ b/docs/zh-cn/basic/consensus/consensus_algorithm.md @@ -1,7 +1,5 @@ # dBFT 2.0 算法 -NEO 在PBFT(Practical Byzantine Fault Tolerance, 实用拜占庭容错)算法的基础上,提出了dBFT(delegated Byzantine Fault Tolerance, 委托拜占庭容错)共识算法。算法根据区块链实时投票情况,决定下一轮参与共识的节点,有效降低了算法耗时,从而提高了出块速度,同时降低了交易确认周期。2019年3月又在原dBFT算法的基础上提出了升级版算法dBFT2.0,引入了三阶段共识机制和恢复机制,进一步提升了算法的鲁棒性和安全性。 - ## 共识术语 | **名称** | **定义** | diff --git a/docs/zh-cn/tooldev/consensus/consensus_protocol.md b/docs/zh-cn/basic/consensus/consensus_protocol.md similarity index 100% rename from docs/zh-cn/tooldev/consensus/consensus_protocol.md rename to docs/zh-cn/basic/consensus/consensus_protocol.md diff --git a/docs/zh-cn/basic/technology/dbft.md b/docs/zh-cn/basic/consensus/dbft.md similarity index 81% rename from docs/zh-cn/basic/technology/dbft.md rename to docs/zh-cn/basic/consensus/dbft.md index 66bf69d0b..a3be7bc51 100644 --- a/docs/zh-cn/basic/technology/dbft.md +++ b/docs/zh-cn/basic/consensus/dbft.md @@ -1,6 +1,4 @@ -# 共识机制 - -## 概述 +# 概述 区块链是一种去中心化的分布式账本系统,它可以用于登记和发行数字化资产、产权凭证、积分等,并以点对点的方式进行转账、支付和交易。区块链技术最早是由中本聪在一个密码学的邮件列表中提出的 [1],也就是比特币。此后,基于区块链技术的各种应用纷纷出现,比如基于区块链的电子现金系统、基于区块链的股权交易系统、基于区块链的智能合约系统等。区块链系统与传统的中心化账本系统相比,具有完全公开、不可篡改、防止多重支付等优点,并且不依赖于任何的可信第三方。 @@ -26,33 +24,11 @@ 参与共识的节点,需要维护一个状态表,用于记录当前的共识状态。一次共识从开始到结束所使用的数据集合,称为视图。如果在当前视图内无法达成共识,则需要更换视图。我们为每一个视图分配一个编号 𝑣,编号从 0 开始,并逐渐递增,直到达成共识为止。 我们为每一个参与共识的节点分配一个编号,从 0 开始,最后一个节点的编号为 N − 1。每一轮共识都需要有一个节点来充当议长,其它节点则为议员。议长的编号 𝑝 由如下的算法来决定:假设当前共识的区块高度为ℎ,则 𝑝 = (ℎ − 𝑣) 𝑚𝑜𝑑 N,其中 𝑝 的取值范围为 0 ≤ 𝑝 < N。每一次共识产生一个区块,并附有至少 N − F 个共识节点的签名。一旦有新的区块产生,则立即开始新一轮的共识,同时重置 𝑣 = 0。 -### 一般流程 - -![](../../tooldev/images/consensus/1.png) - -一轮共识具有以下4个阶段: - -1. 议长发起共识,广播Prepare Request ; -2. 接收到Prepare Request后,议员广播Prepare Response; -3. 接收到足够多的Prepare Response 消息后,共识节点广播Commit; -4. 接收到足够多的Commit后,共识节点产生新块并广播。 - -### 视图更换 - -当共识过程中出现以下情况时,会发起Change View Request尝试更换议长: - -- 议员在验证交易时出现问题 -- 议员等待议长的Prepare Request超时,或等待Prepare Response超时 - -### 恢复机制 - -当发起Change View Request的时候,若缺少足够的活跃共识节点连接(已经发出Commit信息的节点和故障节点数目之和大于*F*)的时候,共识节点会向网络广播Recovery Request消息,以将数据同步至最新共识状态。共识节点收到Recovery Request时,如果满足一定条件,就会生成并广播Recovery Message。 - -## dBFT 2.0 的容错性 +### dBFT 2.0 的容错性 共识节点个数为 *N* 的dBFT2.0共识系统可以最多容忍 F = ⌊ (N−1) / 3 ⌋ 个异常节点。系统的每个共识操作(Commit,Change View,出块等)需要至少 M = N − F 个节点达成共识,只要系统中的正常共识节点不少于*M*,共识进程就可以不断进行下去。比如,在一个*N* = 4 的共识系统中,只需 4 − ⌊ (4−1) / 3 ⌋ =3 个正常共识节点,就可以保证系统的正常工作。 -## dBFT 2.0 的终局性 +### dBFT 2.0 的终局性 dBFT 2.0针对旧版本可能产生分叉的问题进行修正,从根本上杜绝了分叉的可能性。这是由于: @@ -65,12 +41,3 @@ dBFT 2.0针对旧版本可能产生分叉的问题进行修正,从根本上杜 - 其他共识节点的数量不足产生另一个不同的区块。 因此可以保证新块的唯一性。 - -## 延伸阅读 - -[共识算法](../../tooldev/consensus/consensus_algorithm.md) - -[共识协议](../../tooldev/consensus/consensus_protocol.md) - -[投票](../../tooldev/consensus/vote_validator.md) - diff --git a/docs/zh-cn/tooldev/consensus/vote_validator.md b/docs/zh-cn/basic/consensus/vote_validator.md similarity index 100% rename from docs/zh-cn/tooldev/consensus/vote_validator.md rename to docs/zh-cn/basic/consensus/vote_validator.md diff --git a/docs/zh-cn/tooldev/images/blockchain/account_scripthash.jpg b/docs/zh-cn/basic/images/blockchain/account_scripthash.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/account_scripthash.jpg rename to docs/zh-cn/basic/images/blockchain/account_scripthash.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/blockchain.jpg b/docs/zh-cn/basic/images/blockchain/blockchain.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/blockchain.jpg rename to docs/zh-cn/basic/images/blockchain/blockchain.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/economic_model.jpg b/docs/zh-cn/basic/images/blockchain/economic_model.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/economic_model.jpg rename to docs/zh-cn/basic/images/blockchain/economic_model.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/gas-distribution-en.jpg b/docs/zh-cn/basic/images/blockchain/gas-distribution-en.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/gas-distribution-en.jpg rename to docs/zh-cn/basic/images/blockchain/gas-distribution-en.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/gas-distribution.jpg b/docs/zh-cn/basic/images/blockchain/gas-distribution.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/gas-distribution.jpg rename to docs/zh-cn/basic/images/blockchain/gas-distribution.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/nextconsensus_script.jpg b/docs/zh-cn/basic/images/blockchain/nextconsensus_script.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/nextconsensus_script.jpg rename to docs/zh-cn/basic/images/blockchain/nextconsensus_script.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/nextconsensus_witness.jpg b/docs/zh-cn/basic/images/blockchain/nextconsensus_witness.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/nextconsensus_witness.jpg rename to docs/zh-cn/basic/images/blockchain/nextconsensus_witness.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/system1.jpg b/docs/zh-cn/basic/images/blockchain/system1.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/system1.jpg rename to docs/zh-cn/basic/images/blockchain/system1.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/system1_em.jpg b/docs/zh-cn/basic/images/blockchain/system1_em.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/system1_em.jpg rename to docs/zh-cn/basic/images/blockchain/system1_em.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/tx.jpg b/docs/zh-cn/basic/images/blockchain/tx.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/tx.jpg rename to docs/zh-cn/basic/images/blockchain/tx.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain/utxo.jpg b/docs/zh-cn/basic/images/blockchain/utxo.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain/utxo.jpg rename to docs/zh-cn/basic/images/blockchain/utxo.jpg diff --git a/docs/zh-cn/tooldev/images/blockchain_paradigm/.gitignore b/docs/zh-cn/basic/images/blockchain_paradigm/.gitignore similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain_paradigm/.gitignore rename to docs/zh-cn/basic/images/blockchain_paradigm/.gitignore diff --git a/docs/zh-cn/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png b/docs/zh-cn/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png rename to docs/zh-cn/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode-en.png diff --git a/docs/zh-cn/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png b/docs/zh-cn/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png rename to docs/zh-cn/basic/images/blockchain_paradigm/Base58CheckEncodeAndDecode.png diff --git a/docs/zh-cn/tooldev/images/blockchain_paradigm/MerkleTree01-en.png b/docs/zh-cn/basic/images/blockchain_paradigm/MerkleTree01-en.png similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain_paradigm/MerkleTree01-en.png rename to docs/zh-cn/basic/images/blockchain_paradigm/MerkleTree01-en.png diff --git a/docs/zh-cn/tooldev/images/blockchain_paradigm/MerkleTree01.png b/docs/zh-cn/basic/images/blockchain_paradigm/MerkleTree01.png similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain_paradigm/MerkleTree01.png rename to docs/zh-cn/basic/images/blockchain_paradigm/MerkleTree01.png diff --git a/docs/zh-cn/tooldev/images/blockchain_paradigm/formula_ecdsa.jpg b/docs/zh-cn/basic/images/blockchain_paradigm/formula_ecdsa.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/blockchain_paradigm/formula_ecdsa.jpg rename to docs/zh-cn/basic/images/blockchain_paradigm/formula_ecdsa.jpg diff --git a/docs/zh-cn/tooldev/images/consensus/1.png b/docs/zh-cn/basic/images/consensus/1.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/1.png rename to docs/zh-cn/basic/images/consensus/1.png diff --git a/docs/zh-cn/tooldev/images/consensus/10.png b/docs/zh-cn/basic/images/consensus/10.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/10.png rename to docs/zh-cn/basic/images/consensus/10.png diff --git a/docs/zh-cn/tooldev/images/consensus/11.png b/docs/zh-cn/basic/images/consensus/11.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/11.png rename to docs/zh-cn/basic/images/consensus/11.png diff --git a/docs/zh-cn/tooldev/images/consensus/2.png b/docs/zh-cn/basic/images/consensus/2.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/2.png rename to docs/zh-cn/basic/images/consensus/2.png diff --git a/docs/zh-cn/tooldev/images/consensus/3.png b/docs/zh-cn/basic/images/consensus/3.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/3.png rename to docs/zh-cn/basic/images/consensus/3.png diff --git a/docs/zh-cn/tooldev/images/consensus/4.png b/docs/zh-cn/basic/images/consensus/4.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/4.png rename to docs/zh-cn/basic/images/consensus/4.png diff --git a/docs/zh-cn/tooldev/images/consensus/5.png b/docs/zh-cn/basic/images/consensus/5.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/5.png rename to docs/zh-cn/basic/images/consensus/5.png diff --git a/docs/zh-cn/tooldev/images/consensus/6.png b/docs/zh-cn/basic/images/consensus/6.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/6.png rename to docs/zh-cn/basic/images/consensus/6.png diff --git a/docs/zh-cn/tooldev/images/consensus/7.png b/docs/zh-cn/basic/images/consensus/7.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/7.png rename to docs/zh-cn/basic/images/consensus/7.png diff --git a/docs/zh-cn/tooldev/images/consensus/8.png b/docs/zh-cn/basic/images/consensus/8.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/8.png rename to docs/zh-cn/basic/images/consensus/8.png diff --git a/docs/zh-cn/tooldev/images/consensus/9.png b/docs/zh-cn/basic/images/consensus/9.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/9.png rename to docs/zh-cn/basic/images/consensus/9.png diff --git a/docs/zh-cn/tooldev/images/consensus/consensus_msg_seq.jpg b/docs/zh-cn/basic/images/consensus/consensus_msg_seq.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/consensus_msg_seq.jpg rename to docs/zh-cn/basic/images/consensus/consensus_msg_seq.jpg diff --git a/docs/zh-cn/tooldev/images/consensus/vote_candidate.png b/docs/zh-cn/basic/images/consensus/vote_candidate.png similarity index 100% rename from docs/zh-cn/tooldev/images/consensus/vote_candidate.png rename to docs/zh-cn/basic/images/consensus/vote_candidate.png diff --git a/docs/zh-cn/tooldev/images/neo_cli_structure/.gitignore b/docs/zh-cn/basic/images/neo_cli_structure/.gitignore similarity index 100% rename from docs/zh-cn/tooldev/images/neo_cli_structure/.gitignore rename to docs/zh-cn/basic/images/neo_cli_structure/.gitignore diff --git a/docs/zh-cn/tooldev/images/neo_cli_structure/neo-cli.png b/docs/zh-cn/basic/images/neo_cli_structure/neo-cli.png similarity index 100% rename from docs/zh-cn/tooldev/images/neo_cli_structure/neo-cli.png rename to docs/zh-cn/basic/images/neo_cli_structure/neo-cli.png diff --git a/docs/zh-cn/tooldev/images/neo_cli_structure/neo-p2p-network.png b/docs/zh-cn/basic/images/neo_cli_structure/neo-p2p-network.png similarity index 100% rename from docs/zh-cn/tooldev/images/neo_cli_structure/neo-p2p-network.png rename to docs/zh-cn/basic/images/neo_cli_structure/neo-p2p-network.png diff --git a/docs/zh-cn/tooldev/images/neo_vm/.gitignore b/docs/zh-cn/basic/images/neo_vm/.gitignore similarity index 100% rename from docs/zh-cn/tooldev/images/neo_vm/.gitignore rename to docs/zh-cn/basic/images/neo_vm/.gitignore diff --git a/docs/zh-cn/tooldev/images/neo_vm/nvm.jpg b/docs/zh-cn/basic/images/neo_vm/nvm.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/neo_vm/nvm.jpg rename to docs/zh-cn/basic/images/neo_vm/nvm.jpg diff --git a/docs/zh-cn/tooldev/images/neo_vm/nvm2.jpg b/docs/zh-cn/basic/images/neo_vm/nvm2.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/neo_vm/nvm2.jpg rename to docs/zh-cn/basic/images/neo_vm/nvm2.jpg diff --git a/docs/zh-cn/tooldev/images/transaction/network_fee.png b/docs/zh-cn/basic/images/transaction/network_fee.png similarity index 100% rename from docs/zh-cn/tooldev/images/transaction/network_fee.png rename to docs/zh-cn/basic/images/transaction/network_fee.png diff --git a/docs/zh-cn/tooldev/images/transaction/system_fee.png b/docs/zh-cn/basic/images/transaction/system_fee.png similarity index 100% rename from docs/zh-cn/tooldev/images/transaction/system_fee.png rename to docs/zh-cn/basic/images/transaction/system_fee.png diff --git a/docs/zh-cn/tooldev/images/tx_execution/.gitignore b/docs/zh-cn/basic/images/tx_execution/.gitignore similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/.gitignore rename to docs/zh-cn/basic/images/tx_execution/.gitignore diff --git a/docs/zh-cn/tooldev/images/tx_execution/formula_gas.jpg b/docs/zh-cn/basic/images/tx_execution/formula_gas.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/formula_gas.jpg rename to docs/zh-cn/basic/images/tx_execution/formula_gas.jpg diff --git a/docs/zh-cn/tooldev/images/tx_execution/tx_claim_gas.jpg b/docs/zh-cn/basic/images/tx_execution/tx_claim_gas.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/tx_claim_gas.jpg rename to docs/zh-cn/basic/images/tx_execution/tx_claim_gas.jpg diff --git a/docs/zh-cn/tooldev/images/tx_execution/tx_flow_graph.jpg b/docs/zh-cn/basic/images/tx_execution/tx_flow_graph.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/tx_flow_graph.jpg rename to docs/zh-cn/basic/images/tx_execution/tx_flow_graph.jpg diff --git a/docs/zh-cn/tooldev/images/tx_execution/tx_p2p_flow.jpg b/docs/zh-cn/basic/images/tx_execution/tx_p2p_flow.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/tx_p2p_flow.jpg rename to docs/zh-cn/basic/images/tx_execution/tx_p2p_flow.jpg diff --git a/docs/zh-cn/tooldev/images/tx_execution/tx_process_flow.jpg b/docs/zh-cn/basic/images/tx_execution/tx_process_flow.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/tx_process_flow.jpg rename to docs/zh-cn/basic/images/tx_execution/tx_process_flow.jpg diff --git a/docs/zh-cn/tooldev/images/tx_execution/tx_process_flow_en.jpg b/docs/zh-cn/basic/images/tx_execution/tx_process_flow_en.jpg similarity index 100% rename from docs/zh-cn/tooldev/images/tx_execution/tx_process_flow_en.jpg rename to docs/zh-cn/basic/images/tx_execution/tx_process_flow_en.jpg diff --git a/docs/zh-cn/tooldev/images/wallets/account_address_script_checksign.png b/docs/zh-cn/basic/images/wallets/account_address_script_checksign.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/account_address_script_checksign.png rename to docs/zh-cn/basic/images/wallets/account_address_script_checksign.png diff --git a/docs/zh-cn/tooldev/images/wallets/account_address_script_multi_checksign.png b/docs/zh-cn/basic/images/wallets/account_address_script_multi_checksign.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/account_address_script_multi_checksign.png rename to docs/zh-cn/basic/images/wallets/account_address_script_multi_checksign.png diff --git a/docs/zh-cn/tooldev/images/wallets/nep2key.png b/docs/zh-cn/basic/images/wallets/nep2key.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/nep2key.png rename to docs/zh-cn/basic/images/wallets/nep2key.png diff --git a/docs/zh-cn/tooldev/images/wallets/privateKey-wif-en.png b/docs/zh-cn/basic/images/wallets/privateKey-wif-en.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/privateKey-wif-en.png rename to docs/zh-cn/basic/images/wallets/privateKey-wif-en.png diff --git a/docs/zh-cn/tooldev/images/wallets/privateKey-wif.png b/docs/zh-cn/basic/images/wallets/privateKey-wif.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/privateKey-wif.png rename to docs/zh-cn/basic/images/wallets/privateKey-wif.png diff --git a/docs/zh-cn/tooldev/images/wallets/privatekey-2-publickey-address.png b/docs/zh-cn/basic/images/wallets/privatekey-2-publickey-address.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/privatekey-2-publickey-address.png rename to docs/zh-cn/basic/images/wallets/privatekey-2-publickey-address.png diff --git a/docs/zh-cn/tooldev/images/wallets/wif_format.png b/docs/zh-cn/basic/images/wallets/wif_format.png similarity index 100% rename from docs/zh-cn/tooldev/images/wallets/wif_format.png rename to docs/zh-cn/basic/images/wallets/wif_format.png diff --git a/docs/zh-cn/basic/technology/neovm.md b/docs/zh-cn/basic/neovm.md similarity index 99% rename from docs/zh-cn/basic/technology/neovm.md rename to docs/zh-cn/basic/neovm.md index 67dca754a..d33d0ac76 100644 --- a/docs/zh-cn/basic/technology/neovm.md +++ b/docs/zh-cn/basic/neovm.md @@ -14,7 +14,7 @@ NeoVM 是一个用于执行 NEO 智能合约的轻量级虚拟机。 作为 NEO NEO 虚拟机 (NeoVM) 的系统架构,主要由执行引擎、栈、互操作接口等部分构成。 -![](../../assets/neovm.png) +![](../assets/neovm.png) #### 执行引擎 diff --git a/docs/zh-cn/basic/technology/neocontract.md b/docs/zh-cn/basic/technology/neocontract.md deleted file mode 100644 index 707991694..000000000 --- a/docs/zh-cn/basic/technology/neocontract.md +++ /dev/null @@ -1,266 +0,0 @@ -# NeoContract 白皮书 - -## 前言 - -智能合约是指能够自动执行合约条款的计算机程序,它的概念最早是由密码学家尼克萨博于 1994 年提出的,几乎与互联网同龄。由于缺少可信的执行环境,智能合约并没有被广泛应用。 - -2008 年一位自称 Satoshi Nakamoto 的人发布了比特币,并提出了区块链的概念。在比特币系统中,Nakamoto 使用了一套脚本系统来帮助用户更加灵活地控制自己的账户和转账流程,这套脚本系统成为了基于区块链的智能合约系统的雏形。 - -2014 年一位叫做 Vitalik Buterin 的少年发布了以太坊,它提供了一套基于区块链的、图灵完备的智能合约系统,使用这套系统可以创建各种基于区块链的分布式应用。 - -NEO 是一个基于区块链的数字资产及应用平台,它提供了一套全新的智能合约系统 NeoContract,并在系统底层提供了数字资产 NeoAsset 与数字身份 NeoID 等功能,使得人们可以非常方便地开展资产数字化业务,而不仅仅是在区块链上创建原生代币。 - -本文将详细介绍 NeoContract 的特点与非技术细节。技术细节请参考技术文档:[Docs.neo.org](http://docs.neo.org)。 - -## 特点 - -### 确定性 - -如果一个程序在不同的计算机、或者在同一台计算机上的不同时刻多次运行,对于相同的输入能够保证产生相同的输出,则称该程序的行为是确定性的,反之则称该程序的行为是非确定性的。 - -区块链是一个通过多方存储、多方计算的方式来实现数据不可篡改、计算结果可信的分布式系统,智能合约会在区块链网络的多个节点中运行。如果一个智能合约是非确定性的,那么不同节点运行的结果就可能不一致,从而导致共识无法达成,网络陷入停滞。因此,在设计智能合约系统的时候,需要排除一切可能导致非确定性的因素。 - -#### 时间 - -获取系统时间是一个很常用的系统函数,可能会被大量应用在一些具有时效性合约程序中。但是获取时间是一个非确定性的系统函数,不同的节点调用返回的结果也会不一致,在分布式系统中很难获得统一的精确时间。因此,NeoContract 只提供了基于区块时间戳的系统调用,可以将整个区块链看成一个时间戳服务器,并取得任意一个区块被构造时的时间戳。由于 NEO 平均每 15 秒产出一个区块,那么合约运行时的时间大约等于最新的区块时间加上 15 秒左右。 - -#### 随机数 - -很多智能合约程序会用到随机数的功能,比如对赌合约和一些小游戏等,但是随机函数是一个典型的非确定性函数,每次调用都会得到不同的结果。在分布式系统中,解决这个问题的办法有很多:可以让全体节点采用相同的随机种子,这样整个随机函数的返回序列都是确定性的,但是这种方法会提前暴露整个随机结果,使得这种随机数的实用价值大大降低;另一种方法是让全体节点进行通信以协作的方式来生成随机数,它可以采用一些密码学技巧来产生公平的随机数,但缺点是性能非常差,需要额外的通信开销;还有一种方法是引入一个中心化的随机数提供者,由它来提供随机数并保证一致性,但是这种方法的缺点是显而易见的,用户必须无条件地信任这个提供者。 - -运行在 NEO 上的智能合约有两种方式来获取随机数:第一是每个区块在被构造时,共识节点都会对一个随机数达成共识并填充到区块的 Nonce 字段中,合约程序可以读取到任意区块的 Nonce 字段;第二是合约程序可以利用区块的散列值作为随机数的生成手段,由于区块的散列值具有一定的随机性,这种方式可以得到一个较弱的随机数。 - -#### 数据源 - -如果一个程序在运行时获取数据,而数据源提供的是非确定性的数据,那么该程序也可能会变成非确定性的程序。例如,通过搜索引擎来获取某个关键词的前 10 条搜索结果——搜索引擎针对不同的 IP 地址来源可能会返回不同的排序结果。 - -NEO 向智能合约提供了两种确定性的数据源: - -- **区块链账本** - - 合约程序可以通过互操作服务来访问到整个区块链上的所有数据,包括完整的区块和交易,以及它们的每一个字段。区块上的数据都具有确定性和一致性,所以可以安全地被智能合约访问。 - -- **合约存储空间** - - 部署在 NEO 上的每一个合约都有一个仅可由该合约本身来存取的私有存储区,NEO 的共识机制确保了每一个节点上的存储状态都是一致的。 - -对于需要访问链外数据的情况,NEO 没有提供直接的方式,需要通过交易来将链外数据发送到链内,从而转化成以上两种类型的数据源,才能被智能合约所访问。 - -#### 合约调用 - -NeoContract 的智能合约具有相互调用的能力,但不能递归调用。递归可以在合约内部实现,但不能跨越当前合约的边界。 - -### 高性能 - -智能合约的执行环境会对合约的性能起到非常重要的作用。当我们分析执行环境的性能时,有两个指标是非常关键的:第一是指令的执行速度,第二是执行环境本身的启动速度。对于智能合约而言,执行环境的启动速度往往要比指令的执行速度更为重要。智能合约中较多是一些甚少涉及 IO 操作的逻辑判断指令,这些指令的执行速度很容易得到优化。而智能合约每次被调用,都必须启动一个新的虚拟机 / 容器。因此执行环境本身的启动速度(启动一个虚拟机 / 容器)对智能合约系统的性能影响更大。 - -NEO 采用了轻量级的 NeoVM(NEO Virtual Machine)作为其智能合约的执行环境,它的启动速度非常快,占用资源也很小,适合像智能合约这样短小的程序。通过 JIT(即时编译器)技术对热点智能合约进行静态编译和缓存可以显著提升虚拟机的执行效率。 - -### 扩展性 - -#### 高并发与动态分区 - -当谈及一个系统的扩展性时,会涉及到两个方面:垂直扩展和水平扩展。垂直扩展是指对处理流程进行优化使得系统能够充分利用现有设备的能力,这种方式很容易就会碰上天花板,一个串行系统的处理能力取决于单台设备的硬件极限。当我们需要对系统进行扩展时,如果有办法将串行系统改造成并行系统,那么理论上我们只需要增加设备的数量,就可以获得近乎无限的扩展性,这种方式就是横向扩展。我们在考虑对区块链系统进行扩展时,是否有无限扩展的可能?换言之,区块链能否并行地对业务进行处理? - -区块链是一个分布式的大账本,里面记录了各式各样的状态数据,同时也记录了这些状态如何变化的规则,智能合约正是用来记录这些规则的载体。区块链能否并行地对业务进行处理,就取决于多个智能合约能否并发执行——即合约的执行是否是顺序无关的。从根本上来说,如果合约之间不会相互影响,或者说如果合约不会同时对相同的状态数据进行修改,那么它们的执行就是顺序无关的,可以并发执行,否则就只能串行执行,无法横向扩展。 - -基于上面的分析,我们可以很容易设计出一个具备“无限扩展”能力的智能合约系统。只需要简单地规定: - -- **一个智能合约只能修改属于该合约自己的状态记录;** - -- **同一个事务批次(区块)中,一个合约只能被运行一次;** - - -这样一来,所有的智能合约之间都是顺序无关可以平行处理了。但是,如果“一个智能合约只能修改属于该合约自己的状态记录”,就意味着合约间无法相互调用,每个合约都是一个孤岛;如果“一个区块中,一个合约只能被运行一次”,就意味着用智能合约发行的某种数字资产在一个区块里只能处理一笔交易。这显然和“智能”二字的设计初衷大相径庭。毕竟合约间的相互调用,同一区块中多次调用同一个合约,都是我们想要的设计目标。 - -好在,NEO 要求每一个合约都显式地申明自身可能会调用哪些合约,从而使运行环境能够在运行合约程序之前,先计算出完整的调用树,并根据这个调用树来对合约的执行进行分区,让可能会对相同状态记录进行修改的合约在同一个分区中串行执行,而分区与分区之间可以并发执行。 - -#### 低耦合 - -耦合是指两个或两个以上的实体相互依赖于对方的一个量度。NeoContract 的系统采用低耦合的设计,合约程序在 NeoVM 中执行,并通过互操作服务层与外部通信。因此,对智能合约功能的绝大部分升级,都可以通过增加互操作服务的 API 来实现。 - -## 合约用途 - -### 验证合约 - -与比特币的公钥账户体系不同,NEO 的账户系统采用了合约账户体系。NEO 中的每一个账户都会对应一个验证合约,验证合约的散列值即为账户地址;而验证合约的程序逻辑则控制着该账户的所有权。当从一个账户中转账时,需要执行该账户所对应的验证合约。验证合约可以接受一组参数(通常是数字签名或者其它判断条件),并在验证后返回一个布尔值,用于向系统表明本次验证是否成功。 - -用户可以事先将验证合约部署到链上,也可以在转账的过程中直接在交易中公布合约内容。 - -### 应用合约 - -应用合约通过一种特殊的交易来触发,且可以在运行时访问和修改系统的全局状态及合约的私有状态(存储区)。例如,可以在合约中创建全局数字资产、投票、保存数据等,甚至在合约运行时动态创建一个新的合约。 - -应用合约的执行需要按指令进行计费,当交易中的手续费被全部消耗完之后,合约将会失败并停止执行,同时回滚所有的状态变化。合约执行的成功与否,不影响其所在交易的有效性。 - -### 函数合约 - -函数合约用于提供一些公共或者常用的功能,以供其它合约来调用。它使得智能合约的代码可以被重用,从而使开发者可以编写出更复杂的业务逻辑。每一个函数合约在被部署的时候,可以选择是否拥有一个私有的存储区,该存储区可在日后被授权的合约读取或者写入数据,从而实现状态持久化的功能。 - -函数合约必须事先部署到链上才能被调用,并通过“自毁”的系统函数来从链上删除,删除后将无法再被使用,且它的私有存储区也会被销毁。可以通过合约迁移的方式,将旧合约的数据在销毁之前自动迁移到子合约中。 - -## 虚拟机 - -### 虚拟硬件 - -NeoVM 提供了虚拟硬件层来对智能合约的执行提供支持,它们包括: - -**CPU** - -CPU 负责读取并按顺序执行合约中的指令,根据指令的功能进行流程控制、算数运算、逻辑运算等。未来可以对 CPU 的功能进行扩展,引入 JIT(即时编译器)的功能,从而提高指令的执行效率。 - -**调用栈** - -调用栈用于保存每一次函数调用时程序执行的上下文信息,以便在函数执行完毕并返回后,能够继续在当前的上下文中执行。 - -**计算栈** - -NeoVM 中所有的运行数据都存放在计算栈中,当执行不同的指令时,会对计算栈中的数据元素进行相应的操作。例如执行加法指令时,会将参与相加的两个操作数从计算栈中弹出,并将相加后的运算结果压入栈顶。函数调用的参数也必须按从右到左的顺序压入计算栈,函数执行完毕后可以从栈顶取回函数返回值。 - -**备用栈** - -当需要对计算栈中的元素进行调度或重新排列时,可以临时将计算栈中的元素存入备用栈,并在将来取回。 - -### 指令集 - -NeoVM 提供了一套简单而实用的指令集,用于构造智能合约程序。按功能划分,主要包含以下几类: - -- 常数指令 - -- 流程控制指令 - -- 栈操作指令 - -- 字符串指令 - -- 逻辑运算指令 - -- 算数运算指令 - -- 密码学指令 - -- 数据操作指令 - - -值得注意的是,NeoVM 的指令集中内建提供了一系列的密码学指令,如 ECDSA、SHA 等算法,以优化智能合约中用到密码学算法时的执行效率。此外,数据操作指令直接对数组及复杂数据结构提供支持。 - -### 互操作服务层 - -智能合约运行所在的虚拟机是一个沙箱环境,当合约需要访问沙箱外的数据或者将运行时的数据持久化保存时,就需要用到互操作服务层,它为虚拟机中运行的智能合约提供了对外沟通的媒介。NeoContract 在互操作服务层中,向智能合约程序公开了一系列的系统函数和服务,合约可以像调用普通函数一样访问它们,所有系统函数都是可并发的,所以无需担心扩展性问题。 - -### 调试功能 - -通常,智能合约的开发过程是非常困难的,因为没有良好的调试和测试方法。NeoVM 在虚拟机层面提供了程序调试功能的支持,可以对合约代码设置断点,还可以单步、单过程执行等。得益于虚拟机与区块链之间的低耦合设计,可以很方便地将 NeoVM 与各种 IDE 直接集成,从而提供一个与最终生产环境一致的测试环境。 - -## 高级语言 - -### C#, VB.Net, F# - -开发者可以直接使用几乎任何他们擅长的高级语言来进行 NeoContract 的开发工作。第一批被支持的语言是 C#、VB.Net、F# 等,我们提供了这些语言的编译器和插件,用于将高级语言编译成 NeoVM 所支持的指令集。由于编译器会针对 MSIL(微软中间语言)来进行编译,所以理论上任何 .Net 中的语言或者可被转译成 MSIL 的语言都可以直接被直接支持。 - -这些语言的开发者人数众多,且具有非常强大的集成开发环境,开发者可以在 Visual Studio 中进行代码的编写、生成、测试、调试等一系列的开发工作,同时还可以利用我们提供的智能合约开发模板来进行快速入门。 - -### Java, Kotlin - -Java、Kotlin 等语言是第二批被支持的语言,我们提供这些语言的编译器和 IDE 插件,来帮助开发者使用基于 JVM 的语言来开发 NEO 的智能合约应用。 - -Java 的使用非常广泛,而 Kotlin 最近也成为了 Google 官方推荐的 Android 开发语言,相信它们能为 NEO 带来大量的智能合约开发者。 - -### 其它语言 - -后续,NeoContract 将依据难易程度来分批次开发各种其它高级语言的编译器,可能会有这些语言: - -C, C++, GO - -Python, JavaScript - -未来会陆陆续续增加新的高级语言支持,使得 90% 的开发者无需学习新的语言即可参与到 NeoContract 的开发中来,甚至可将现有业务系统中的代码直接移植到区块链上。 - -## 服务 - -### 区块链账本 - -NEO 的智能合约可以在运行时通过互操作服务提供的系统函数,获取 NEO 区块链的完整账本数据,包括完整的区块和交易,以及它们的每一个字段。具体可以查询到这些数据: - -- 区块链的高度; - -- 区块头、区块; - -- 交易; - -- 交易的类型、属性、输入、输出等; - - -透过这些数据,可以开发出一些有意思的应用,比如自动权益分红、基于智能合约的工作量证明等。 - -### 数字资产 - -通过互操作服务提供的数字资产接口,智能合约不但可以查询到 NEO 区块链上各种数字资产的属性和统计信息,还可以在运行时创建新的数字资产。由智能合约所创建的数字资产,可以在合约外部进行发行、转账、交易等操作,它们与 NEO 上的原生资产一样,可以用任何与 NEO 兼容的钱包软件来管理。具体的接口主要有这些: - -- 资产属性查询; - -- 资产统计数据查询; - -- 资产生命周期管理:创建、修改、销毁等; - -- 资产管理:多国语言的名称、总量变更、精度变更、管理员变更等; - - -### 持久化 - -每一个被部署到 NEO 区块链上的智能合约程序,都会拥有一个只有该合约本身可以读写的私有存储区。智能合约对自己存储区中的数据拥有完全的操作权限:可以读取、写入、修改、删除。数据以键值对的形式来存放,并提供这些接口: - -- 遍历存储区中的所有记录; - -- 根据指定键返回特定记录; - -- 根据指定键来修改或写入新的记录; - -- 根据指定键来删除记录; - - -一般,合约只能对自己存储区中的数据进行读写,但有一个例外:当发生合约相互调用的时候,被调用合约可以通过跨域请求来访问调用者的存储区,前提是调用者向其提供了授权。此外,对于在合约运行时动态创建的子合约,父合约会即时获得其存储区的读写权限。 - -跨域请求使得 NeoContract 可以实现更加丰富的库功能,这些库可以为调用者提供高度封装的数据管理能力。 - -## 系统费用 - -### 部署费用 - -NEO 的分布式结构提供了高冗余的存储能力,对这种能力的使用不是无偿的。在 NEO 上部署智能合约需要支付一笔费用,这笔费用目前固定为 500GAS,由系统收取并成为系统收益。未来可能会根据系统运行的实际情况来调整价格。部署在区块链上的智能合约可以被多次使用,直到该合约被部署者销毁。 - -### 执行费用 - -NEO 为智能合约提供了一个可信的执行环境,而合约的执行也需要消耗各个节点的计算资源,因此用户需要为智能合约的执行支付费用。费用的数量由每一次执行所消耗的计算资源决定,计价单位也是 GAS。如果执行过程中由于费用不足导致智能合约执行失败的,已被消耗的费用不会退回,这可以防止恶意攻击对全网算力的消耗。 - -对于大多数简单的合约,它们都可以在 10 GAS 的免费额度内顺利执行完毕,从而大大降低了用户的使用成本。 - -## 应用场景 - -### 超导交易 - -区块链上的数字资产天生具有流动性的需求,通常点对点的交易无法提供足够高的流动性,因此需要由交易所来为用户提供交易服务。数字资产的交易所一般会分为两类:第一类是中心化交易所,用户需要将数字资产充值到交易所,然后在网站上挂单进行撮合交易;第二类是去中心化交易所,它的交易系统内置在区块链系统中,由系统提供撮合服务。 - -中心化交易所能够提供非常高的性能和多样化的服务,但需要有较强的信用保证,否则将会出现道德风险,比如挪用用户资金、跑路等。相对的,去中心化交易所虽然没有道德风险,但是用户体验较差,性能上也有较大的瓶颈。有没有办法将两者的优点结合起来,提供一个两全其美的方法? - -超导交易就可以做到这一点,它是这样一种机制:用户无需充值,就可以直接使用自己在区块链上的资产来进行交易,交易的结算在链上完成,但撮合的过程在链外进行,由一个中心化的交易所来提供撮合服务。由于撮合在链外,它的效率可以像中心化交易所一样高,但资产还在用户的控制之下,交易所可以根据用户的交易意愿来进行撮合服务,却无法挪用资金或者跑路,没有道德风险。 - -目前,NEO 社区中已经出现一些利用智能合约来实现区块链超导交易的项目,例如蓝鲸淘。 - -### 跨链互操作 - -可以预见,在未来较长的一段时间内,世界上将会有若干公有链以及成千上万的联盟链和私有链共存。这些独立的区块链系统都是价值与信息的孤岛,彼此之间无法互联互通。通过跨链互操作机制,可以将无数个孤立的区块链连接起来,使得不同的区块链上的价值可以相互交换,形成真正的价值互联网。 - -NeoContract 为跨链互操作的实现提供支持,不但可以实现跨链资产交换,还可以运行跨链分布式事务,在不同区块链上运行智能合约,并保证它们的一致性。 - -### 预言机 - -一部预言机可以视为是与一个预言者(oracle)相连接的图灵机。所谓预言者的概念,是一个可以回答特定问题集合的一个实体。在区块链中,预言机为智能合约打开了外部世界的大门,使得智能合约可以将真实世界的信息作为合约执行的条件。 - -NeoContract 没有提供直接访问外部数据的能力,比如访问互联网上的资源等,因为这样做会引入非确定性,使得各个节点对合约执行的结果出现不一致。在 NeoContract 中实现预言机,需要由可信的第三方将外部数据通过交易的形式发送到区块链上,使得这些信息成为账本数据的一部分,从而消除非确定性。 - -前文中提到的可信第三方,可以是一个由合约缔造者双方共同信任的人或机构,也可以是一个去中心化的由经济激励来保证的数据提供程序,可以用 NeoContract 来实现这样一个预言机。 - -### 以太坊系列 DAPP - -比特币开创了区块链及电子现金的时代,以太坊则开创了智能合约的时代。以太坊作为区块链智能合约的先驱,为智能合约系统的设计思想、经济模型、技术实现等方面均做出了巨大的贡献。同时,以太坊平台上也已经存在了大量的 DAPP(分布式应用程序),这些 DAPP 的功能各异,有对赌协议、数字资产、电子黄金、游戏平台、医疗保险、婚恋平台,覆盖各行各业。所有这些 DAPP,理论上都可以很方便地移植到 NeoContract 平台上,成为 NEO 的应用。 diff --git a/docs/zh-cn/basic/whitepaper.md b/docs/zh-cn/basic/whitepaper.md deleted file mode 100644 index c40a2c20e..000000000 --- a/docs/zh-cn/basic/whitepaper.md +++ /dev/null @@ -1,186 +0,0 @@ -# NEO 白皮书 - -一种智能经济分布式网络 - -## NEO 的设计目标:智能经济 - -NEO 是利用区块链技术和数字身份进行资产数字化,利用智能合约对数字资产进行自动化管理,实现“智能经济”的一种分布式网络。 - -### 数字资产 - -数字资产是以电子数据的形式存在的可编程控制的资产。用区块链技术实现资产数字化有去中心、去中介、免信任、可追溯、高度透明等特点。NEO 在底层支持多数字资产,用户可在 NEO 上自行注册登记资产,自由交易和流转,并且通过数字身份解决与实体资产的映射关系。用户通过合规的数字身份所注册登记的资产受到法律的保护。 - -NEO 中有两种形式的数字资产:全局资产和合约资产。全局资产能够被记录在系统空间,可以被所有智能合约和客户端所识别;合约资产被记录在智能合约的私有存储区中,需要兼容该智能合约的客户端才能识别。合约资产可以参照某种约定的标准,从而实现与多数客户端的兼容。 - -### 数字身份 - -数字身份是指以电子数据形式存在的个人、组织、事物的身份信息。目前较为成熟的数字身份体系是基于 PKI(Public Key Infrastructure)的 X.509 标准。在 NEO 中,我们将实现一套兼容 X.509 的数字身份标准。这套数字身份标准,除了兼容 X.509 的层级式的证书签发模式,还将支持 Web Of Trust 式的点对点的证书签发模式。并通过人脸、指纹、语音、短信等多因素认证实现签发阶段和使用阶段的真实身份比对。同时,还将使用区块链取代 OCSP 协议来管理、记录 X.509 的吊销证书列表 CRL。 - -### 智能合约 - -智能合约是 1994 年由密码学家尼克萨博(Nick Szabo)最先提出的理念,几乎与互联网同龄。根据 Nick Szabo 的定义:当一个预先编好的条件被触发时,智能合约执行相应的合同条款。区块链技术给我们带来了一个去中心化的,不可篡改的,高可靠性的系统,在这种环境下,智能合约才大有用武之地。NEO 具备独立的智能合约体系:NeoContract。 - -NeoContract 智能合约体系的最大特点是无缝对接现有的开发者生态。开发者无需学习新的编程语言,就能用 C#、Java 等主流编程语言在熟悉的 IDE 环境(Visual Studio、Eclipse 等)中进行智能合约的开发、调试、编译。NEO 的通用轻量级虚拟机 NeoVM 具有高确定性、高并发性、高扩展性等优点。NeoContract 智能合约体系让全球百万级的开发者能够快速进行智能合约的开发。NeoContract 将有独立的白皮书描述实现细节。 - -### 应用与生态 - -生态是开源社区项目的生命力所在。为了实现智能经济网络的目标,NEO 将致力于发展开发者生态,提供成熟的开发工具,完善的开发文档,组织教育培训活动,提供资金支持。我们计划对以下基于 NEO 的应用与生态进行支持,并对完善与提升体验的设计给予奖励: - -🔹 **节点程序** - -- 完整功能的 PC 全节点程序 - -- 更好体验的 PC 轻节点程序 - -- 提供不需要同步区块链的 Web / Android / iOS 客户端 - -- 硬件钱包​ - - -🔹 **区块链浏览器** - -🔹 **SDK 开发工具包** - -- 支持 Java / Kotlin、.NET C# / VB、JavaScript / Typescript、Python、Go - -🔹 **智能合约编译器与 IDE 插件** - -- C# / VB.Net / F#,Visual Studio - -- Java / Kotlin,Eclipse - -- C / C++ / GO - -- JavaScript / TypeScript - -- Python / Ruby - -🔹 **去中心化应用** - -- 智能基金 - -- AI 辅助的法律智能合约 - -- 网络社交 - -- 自动化代币流动性提供者 - -- 去中心化交易所 - -- 安全通讯协议 - -- 数据交易市场 - -- IP 交易市场 - -- 预测市场 - -- 广告市场 - -- 算力市场 - -- NeoGas 市场 - -## NEO 的管理模式 - -### 经济模型 - -NEO 中内置两种原生代币,NEO(缩写符号 NEO)和 NeoGas(缩写符号 GAS)。 - -NEO 是管理代币,总量 1 亿份,用于实现对 NEO 网络的管理权。管理权包括投票进行记账人选举,NEO 网络参数更改等。NEO 的最小单位为 1,不可再分割。 - -GAS 是燃料代币,最大总量上限为 1 亿,用于实现对 NEO 网络使用时的资源控制。NEO 网络对代币转账和智能合约的运行和存储进行收费,从而实现对记账人的经济激励和防止资源滥用。GAS 的最小单位为 0.00000001。 - -在 NEO 网络的创世块里,1 亿份 NEO 已经生成,而 GAS 尚未生成,数量为零。1 亿份 NEO 所对应的 1 亿份 GAS,将通过一个衰减的算法在约 22 年的时间内逐步生成至 NEO 管理代币的地址中。NEO 管理代币转入新的地址后,之后的 GAS 也将在新的地址生成。 - -NEO 网络将通过投票设置一个阈值,对一定量的转账交易和智能合约运行存储免收 GAS,以提升使用体验。当发生大量垃圾交易时,可以通过 NeoID 来优先处理具有合格身份的交易和智能合约。没有合格数字身份的交易和智能合约可以通过支付 GAS 来获得优先处理。 - -### 分发机制 - -NEO 的分发: - -NEO 的 1 亿管理代币分为两部分,第一部分 5000 万份 NEO 用于按轮次和比例分发给 NEO 开发经费众筹的支持者,该部分已经分发完毕。 - -第二部分 5000 万份由 NEO 理事会管理,用于支持 NEO 网络的长期开发、运维和生态发展。该部分的 NEO 处于锁定期,在 2017 年 10 月 16 日 NEO 网络运行达 1 年时方可解锁被使用。这部分 NEO 不会进入交易所交易,仅用于长期支持 NEO 项目,计划按如下比例分配使用: - -🔹 1000 万份(总量 10%)用于激励 NEO 开发者和 NEO 理事会成员 - -🔹 1000 万份(总量 10%)用于激励 NEO 周边生态开发者 - -🔹 1500 万份(总量 15%)用于交叉投资其他区块链项目,所获得代币归属于 NEO 理事会,并仅用于 NEO 项目 - -🔹 1500 万份(总量 15%)机动使用 - -🔹 每年使用的 NEO 原则上不得超过 1500 万份 - -GAS 的分发: - -GAS 伴随着每个新区块的生成而产生。GAS 初期总量为零,伴随着新区块的生成逐渐增多,直至约 22 年后达到总量上限 1 亿。NEO 每个区块的间隔时间约为 15-20 秒,200 万个区块约合 1 年时间。 - -第一年(实际为0-200万个区块),每个区块新生成 8 个 GAS;第二年(实际为第 200-400万个区块),每个区块新生成 7 个 GAS;以此类推,每年递减 1 个 GAS,直至第 8 年递减至每个区块新生成 1 个 GAS;自此保持每个区块新生成 1 个 GAS 直至约 22 年后的第 4400 万个区块,GAS 总量到达 1 亿,则停止伴随新区块生成 GAS。 - -按照这样的发行曲线,第 1 年会有 16% 的 GAS 被创造,前 4 年会有 52% 的 GAS 被创造,前 12 年 80% 的 GAS 被创造。这些的 GAS 都会按照 NEO 的持有比例,记录在对应的地址上。NEO 持有人可以在任意时间进行发起一笔认领交易,将这些 GAS 认领到 NEO 的地址上。 - -### 治理机制 - -链上治理:NEO 管理代币的持有人是 NEO 网络的所有者和管理者,通过在 NEO 网络上构造投票交易来实现管理权,通过获得 NEO 管理代币所对应的 GAS 燃料代币来实现 NEO 网络的使用权。 NEO 管理代币可以被转让。 - -链下治理:NEO 理事会是 NEO 项目的创始人组织成立的常务管理机构,下设管理委员会、技术委员会和秘书处,分别负责战略决策、技术决策和具体执行。NEO 理事会向 NEO 社区负责,以推广和发展 NEO 生态为首要工作目标。 - -## NEO 的技术实现 - -### 共识机制:DBFT - -DBFT 全称为 Delegated Byzantine Fault Tolerant,是一种通过代理投票来实现大规模节点参与共识的拜占庭容错型共识机制。NEO 管理代币的持有者通过投票,可以选出其所支持的记账人。随后由被选出的记账人团体通过 BFT 算法,来达成共识并生成新的区块。投票在 NEO 网络持续实时进行,而非按照固定任期。 - -DBFT 对由 n 个共识节点组成的共识系统,提供 f=⌊(n-1)/3⌋ 的容错能力,这种容错能力同时包含安全性和可用性,可以抵抗一般性故障和拜占庭故障,并适用于任何网络环境。DBFT 具有良好的最终性,一个确认即最终确认,区块无法被分叉,交易也不会发生撤销或回滚。 - -在 NEO 的 DBFT 共识机制下,每 15~20 秒生成一个区块,交易吞吐量实测可达到约 1000tps,在公有链中性能优秀。通过适当优化,有能力到达 10000TPS,可以支持大规模的商业化应用。 - -DBFT 结合数字身份技术,使得记账人可以是实名的个人或机构。从而使得冻结、撤销、继承、找回、司法判决过户等非常规操作成为可能。这有利于合规性金融资产在 NEO 网络中的登记发行。NEO 网络计划在必要的时候支持此类操作。 - -### 智能合约体系:NeoContract - -NEO 的智能合约体系由三部分组成: - -**NeoVM - 通用区块链虚拟机:** - -NeoVM 是一个轻量级的通用型虚拟机,其架构与 JVM 和 .NET Runtime 非常接近,类似于一个虚拟 CPU,负责读取并按顺序执行合约中的指令,根据指令的功能进行流程控制、算数运算、逻辑运算等。它具有良好的启动速度和通用性,非常适合应用于智能合约这种小程序,也可以被移植到非区块链的场景中,或者与 IDE 集成从而提供良好的开发体验。可以对 NeoVM 的功能进行扩展,引入 JIT(即时编译器)机制,从而提高指令的执行效率。 - -**InteropService - 互操作服务:** - -用于加载区块链账本、数字资产、数字身份、持久化存储区等底层服务。它们就像是为虚拟机提供的虚拟设备,使得智能合约可以在运行时访问这些服务,从而实现一些高级功能。通过这种低耦合的设计,**NeoVM 可以被移植到任意区块链甚至非区块链系统中使用,使得智能合约的适用领域大大扩宽。** - -**DevPack - 编译器和 IDE 插件:** - -DevPack 包含高级语言编译器和 IDE 插件。由于 NeoVM 的架构与 JVM、.NET Runtime 等高度相似,这些 DevPack 里的编译器可以将 Java byte code 和 .NET MSIL 这类中间语言编译成 NeoVM 的指令集。Java / Kotlin、C#的开发者不需要学习新的语言,在 VS、Eclipse 等熟悉的 IDE 环境中就能立即着手编写智能合约。**这使得智能合约的学习成本大大降低,可以建立丰富的 NeoContract 智能合约生态。** - -NeoContract 可以在运行智能合约之前,就通过静态分析来建立智能合约的调用树。通过确定性的调用树,**NEO 节点可以对智能合约进行动态分片,实现理论上无限的扩展**,克服了其他区块链系统的静态分片导致的“闹市拥堵效应”。 - -### 跨链互操作协议:NeoX - -NeoX 是实现跨链互操作的协议。NeoX 分为两个部分:“跨链资产交换协议”和“跨链分布式事务协议”。 - -**跨链资产交换协议:** - -NeoX 在已有的双链原子资产交换协议上进行了扩展,可以让多个参与者在不同的区块链上进行资产交换,并保证整个交易过程中的所有步骤全都成功或全都失败。为了实现这个功能,我们需要利用 NeoContract 的功能,为每一个参与者创建一个合约账户。对于其它的区块链,如果它不兼容 NeoContract,但是只要能够提供简单的智能合约功能,也能够与 NeoX 相兼容。 - -**跨链分布式事务协议:** - -跨链分布式事务是指,事务的多个步骤分散在不同的区块链上执行,且保证整个事务的一致性。这是对跨链资产交换的一种扩展,将资产交换的行为扩展成任意行为。通俗的说,NeoX 使得跨链智能合约成为了可能,一个智能合约可以在多个不同的区块链上执行不同的部分,要么全部执行完毕,要么全部退回执行前的状态。这赋予了跨链协作极大的想象力,我们正在探索跨链智能合约的应用场景。 - -### 分布式存储协议:NeoFS - -NeoFS 是一套利用了 Distributed Hash Table 技术的分布式存储协议。NeoFS 通过文件内容(Hash)而非文件路径(URI)来对数据进行索引。大文件将被分割为固定大小的数据块分布式地存储在众多节点中。 - -该类系统的主要问题是需要在冗余度和可靠性之间寻找平衡点。NeoFS 计划通过代币激励机制和建立骨干节点的方式来解决这一矛盾。用户可以选择文件的可靠性要求,低可靠性的文件可以免费或几乎免费的被存储和访问,高可靠性的文件将由骨干节点提供稳定可靠的服务。 - -NeoFS 将作为 NeoContract 体系下的 InteropService 互操作服务之一,使得智能合约可以在区块链上存放大型文件,并为这些文件设定访问权限。此外,NeoFS 可以与数字身份相结合,使记录数字身份的数字证书可以点对点签发、传送、吊销,而无需中心化服务器来管理。未来可以将陈旧的区块数据存放在 NeoFS 中,使得大部分的全节点可以释放旧数据,获得更高的扩展性,并保证历史数据的完整性。 - -### 抗量子密码学机制:NeoQS - -量子计算机的出现将对基于 RSA 和 ECC 的密码学机制产生重大挑战。量子计算机能够在极短的时间内解决 RSA 所依赖的大数分解问题和 ECC 所依赖的椭圆曲线离散对数问题。NeoQS 是一种基于格的密码学机制,QS 是 Quantum Safe 的缩写。目前,量子计算机尚无快速解决最短向量问题(SVP)和最近向量问题(CVP)的能力,格密码学被认为是抵御量子计算机的最可靠算法。 - -## 总结 - -NEO 是一种结合数字资产、数字身份和智能合约的分布式网络。NEO 系统还将使用 DBFT、NeoX、NeoFS、NeoQS 等多项原创技术,成为未来智能经济的基础架构。 diff --git a/docs/zh-cn/sc/assets/2017-06-07_11-29-16.png b/docs/zh-cn/develop/assets/2017-06-07_11-29-16.png similarity index 100% rename from docs/zh-cn/sc/assets/2017-06-07_11-29-16.png rename to docs/zh-cn/develop/assets/2017-06-07_11-29-16.png diff --git a/docs/zh-cn/sc/assets/2017-06-07_12-07-03.png b/docs/zh-cn/develop/assets/2017-06-07_12-07-03.png similarity index 100% rename from docs/zh-cn/sc/assets/2017-06-07_12-07-03.png rename to docs/zh-cn/develop/assets/2017-06-07_12-07-03.png diff --git a/docs/zh-cn/sc/assets/2017-08-14_18-21-53.png b/docs/zh-cn/develop/assets/2017-08-14_18-21-53.png similarity index 100% rename from docs/zh-cn/sc/assets/2017-08-14_18-21-53.png rename to docs/zh-cn/develop/assets/2017-08-14_18-21-53.png diff --git a/docs/zh-cn/sc/assets/2017-08-14_18-49-01.png b/docs/zh-cn/develop/assets/2017-08-14_18-49-01.png similarity index 100% rename from docs/zh-cn/sc/assets/2017-08-14_18-49-01.png rename to docs/zh-cn/develop/assets/2017-08-14_18-49-01.png diff --git a/docs/zh-cn/sc/assets/2017-08-16_12-13-27.png b/docs/zh-cn/develop/assets/2017-08-16_12-13-27.png similarity index 100% rename from docs/zh-cn/sc/assets/2017-08-16_12-13-27.png rename to docs/zh-cn/develop/assets/2017-08-16_12-13-27.png diff --git a/docs/zh-cn/sc/assets/2017-08-17_10-35-52.png b/docs/zh-cn/develop/assets/2017-08-17_10-35-52.png similarity index 100% rename from docs/zh-cn/sc/assets/2017-08-17_10-35-52.png rename to docs/zh-cn/develop/assets/2017-08-17_10-35-52.png diff --git a/docs/zh-cn/sc/assets/NeoContract1.png b/docs/zh-cn/develop/assets/NeoContract1.png similarity index 100% rename from docs/zh-cn/sc/assets/NeoContract1.png rename to docs/zh-cn/develop/assets/NeoContract1.png diff --git a/docs/zh-cn/sc/assets/compile_smart_contract.png b/docs/zh-cn/develop/assets/compile_smart_contract.png similarity index 100% rename from docs/zh-cn/sc/assets/compile_smart_contract.png rename to docs/zh-cn/develop/assets/compile_smart_contract.png diff --git a/docs/zh-cn/sc/assets/download_and_install_smart_contract_plugin.jpg b/docs/zh-cn/develop/assets/download_and_install_smart_contract_plugin.jpg similarity index 100% rename from docs/zh-cn/sc/assets/download_and_install_smart_contract_plugin.jpg rename to docs/zh-cn/develop/assets/download_and_install_smart_contract_plugin.jpg diff --git a/docs/zh-cn/sc/assets/dyn04.png b/docs/zh-cn/develop/assets/dyn04.png similarity index 100% rename from docs/zh-cn/sc/assets/dyn04.png rename to docs/zh-cn/develop/assets/dyn04.png diff --git a/docs/zh-cn/sc/assets/dyncallx.png b/docs/zh-cn/develop/assets/dyncallx.png similarity index 100% rename from docs/zh-cn/sc/assets/dyncallx.png rename to docs/zh-cn/develop/assets/dyncallx.png diff --git a/docs/zh-cn/sc/assets/edit_environment_variable.png b/docs/zh-cn/develop/assets/edit_environment_variable.png similarity index 100% rename from docs/zh-cn/sc/assets/edit_environment_variable.png rename to docs/zh-cn/develop/assets/edit_environment_variable.png diff --git a/docs/zh-cn/sc/assets/environment_variable.png b/docs/zh-cn/develop/assets/environment_variable.png similarity index 100% rename from docs/zh-cn/sc/assets/environment_variable.png rename to docs/zh-cn/develop/assets/environment_variable.png diff --git a/docs/zh-cn/sc/assets/install_core_cross_platform_development_toolset.jpg b/docs/zh-cn/develop/assets/install_core_cross_platform_development_toolset.jpg similarity index 100% rename from docs/zh-cn/sc/assets/install_core_cross_platform_development_toolset.jpg rename to docs/zh-cn/develop/assets/install_core_cross_platform_development_toolset.jpg diff --git a/docs/zh-cn/sc/assets/mac0.jpg b/docs/zh-cn/develop/assets/mac0.jpg similarity index 100% rename from docs/zh-cn/sc/assets/mac0.jpg rename to docs/zh-cn/develop/assets/mac0.jpg diff --git a/docs/zh-cn/sc/assets/mac3.jpg b/docs/zh-cn/develop/assets/mac3.jpg similarity index 100% rename from docs/zh-cn/sc/assets/mac3.jpg rename to docs/zh-cn/develop/assets/mac3.jpg diff --git a/docs/zh-cn/sc/assets/mac4.png b/docs/zh-cn/develop/assets/mac4.png similarity index 100% rename from docs/zh-cn/sc/assets/mac4.png rename to docs/zh-cn/develop/assets/mac4.png diff --git a/docs/zh-cn/sc/assets/mac5.jpg b/docs/zh-cn/develop/assets/mac5.jpg similarity index 100% rename from docs/zh-cn/sc/assets/mac5.jpg rename to docs/zh-cn/develop/assets/mac5.jpg diff --git a/docs/zh-cn/sc/assets/mac8.jpg b/docs/zh-cn/develop/assets/mac8.jpg similarity index 100% rename from docs/zh-cn/sc/assets/mac8.jpg rename to docs/zh-cn/develop/assets/mac8.jpg diff --git a/docs/zh-cn/sc/assets/mac8.png b/docs/zh-cn/develop/assets/mac8.png similarity index 100% rename from docs/zh-cn/sc/assets/mac8.png rename to docs/zh-cn/develop/assets/mac8.png diff --git a/docs/zh-cn/sc/assets/mac9.png b/docs/zh-cn/develop/assets/mac9.png similarity index 100% rename from docs/zh-cn/sc/assets/mac9.png rename to docs/zh-cn/develop/assets/mac9.png diff --git a/docs/zh-cn/sc/assets/new_smart_contract_project.png b/docs/zh-cn/develop/assets/new_smart_contract_project.png similarity index 100% rename from docs/zh-cn/sc/assets/new_smart_contract_project.png rename to docs/zh-cn/develop/assets/new_smart_contract_project.png diff --git a/docs/zh-cn/sc/assets/powershell_enviornment_variabled_updated_correctly.png b/docs/zh-cn/develop/assets/powershell_enviornment_variabled_updated_correctly.png similarity index 100% rename from docs/zh-cn/sc/assets/powershell_enviornment_variabled_updated_correctly.png rename to docs/zh-cn/develop/assets/powershell_enviornment_variabled_updated_correctly.png diff --git a/docs/zh-cn/sc/assets/publish_and_profile_settings.jpg b/docs/zh-cn/develop/assets/publish_and_profile_settings.jpg similarity index 100% rename from docs/zh-cn/sc/assets/publish_and_profile_settings.jpg rename to docs/zh-cn/develop/assets/publish_and_profile_settings.jpg diff --git a/docs/zh-cn/sc/assets/publish_neo_compiler_msil_project.jpg b/docs/zh-cn/develop/assets/publish_neo_compiler_msil_project.jpg similarity index 100% rename from docs/zh-cn/sc/assets/publish_neo_compiler_msil_project.jpg rename to docs/zh-cn/develop/assets/publish_neo_compiler_msil_project.jpg diff --git a/docs/zh-cn/sc/assets/smart_contract_function_code.png b/docs/zh-cn/develop/assets/smart_contract_function_code.png similarity index 100% rename from docs/zh-cn/sc/assets/smart_contract_function_code.png rename to docs/zh-cn/develop/assets/smart_contract_function_code.png diff --git a/docs/zh-cn/dapp/assets/structure.png b/docs/zh-cn/develop/dapp/assets/structure.png similarity index 100% rename from docs/zh-cn/dapp/assets/structure.png rename to docs/zh-cn/develop/dapp/assets/structure.png diff --git a/docs/zh-cn/dapp/integ.md b/docs/zh-cn/develop/dapp/integ.md similarity index 100% rename from docs/zh-cn/dapp/integ.md rename to docs/zh-cn/develop/dapp/integ.md diff --git a/docs/zh-cn/dapp/intro.md b/docs/zh-cn/develop/dapp/intro.md similarity index 82% rename from docs/zh-cn/dapp/intro.md rename to docs/zh-cn/develop/dapp/intro.md index ae9279de0..0d74407a8 100644 --- a/docs/zh-cn/dapp/intro.md +++ b/docs/zh-cn/develop/dapp/intro.md @@ -9,16 +9,15 @@ 在 Neo上开发部署智能合约需要消耗一定量的Gas作为手续费,考虑到开发成本以及方便性,建议开发者首先搭建Neo私链或者使用Neo测试网,用于初期的开发和测试。详情请参考: - [搭建 Neo 私链](../network/private-chain/solo.md); - - [使用 Neo-local 快速搭建本地网络](../network/private-chain/neolocal.md); - [使用 Neo 测试网](../network/testnet.md) - + 2. 运行 Neo 节点 - 针对不同开发者的偏好和经验,Neo 提供了命令行和用户界面两种节点供开发者选择,详情请参考 [Neo 节点](../node/introduction.md) + 针对不同开发者的偏好和经验,Neo 提供了命令行和用户界面两种节点供开发者选择,详情请参考 [Neo 节点](../../node/introduction.md) 3. 开发智能合约 - 智能合约实现了 DApp 的核心业务逻辑,请参考 [智能合约开发](../sc/gettingstarted/introduction.md) 完成自己项目需要使用的智能合约。 + 智能合约实现了 DApp 的核心业务逻辑,请参考 [编写智能合约](../../gettingstarted/prerequisites) 完成自己项目需要使用的智能合约。 4. DApp 集成 diff --git a/docs/zh-cn/sc/deploy/Parameter.md b/docs/zh-cn/develop/deploy/Parameter.md similarity index 65% rename from docs/zh-cn/sc/deploy/Parameter.md rename to docs/zh-cn/develop/deploy/Parameter.md index ab2ff3e7f..4446be4da 100644 --- a/docs/zh-cn/sc/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/sc/deploy/deploy.md b/docs/zh-cn/develop/deploy/deploy.md similarity index 78% rename from docs/zh-cn/sc/deploy/deploy.md rename to docs/zh-cn/develop/deploy/deploy.md index 1b954bb88..0f4ab975a 100644 --- a/docs/zh-cn/sc/deploy/deploy.md +++ b/docs/zh-cn/develop/deploy/deploy.md @@ -4,17 +4,17 @@ ## 为什么需要部署? -当一个智能合约需要在区块链上存储数据或被其它智能合约调用(称为 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 的智能合约发布功能来部署合约。 -部署智能合约以及调用智能合约均会产生费用,详情请参见 [系统手续费](../fees.md)。 +部署智能合约以及调用智能合约均会产生费用,详情请参见 [系统手续费](../../reference/fees.md)。 ## 准备工作 在开始部署之前,请确认您已经完成以下工作: diff --git a/docs/zh-cn/sc/deploy/invoke.md b/docs/zh-cn/develop/deploy/invoke.md similarity index 94% rename from docs/zh-cn/sc/deploy/invoke.md rename to docs/zh-cn/develop/deploy/invoke.md index 8c3df6615..aa4816e1b 100644 --- a/docs/zh-cn/sc/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 中,在调用合约时,可以点击下方的 `附加签名`,选择 `公钥` 然后点击 `签名` 来进行附加签名。 diff --git a/docs/zh-cn/sc/devenv/getting-started-csharp-mac.md b/docs/zh-cn/develop/devenv/getting-started-csharp-mac.md similarity index 100% rename from docs/zh-cn/sc/devenv/getting-started-csharp-mac.md rename to docs/zh-cn/develop/devenv/getting-started-csharp-mac.md diff --git a/docs/zh-cn/sc/devenv/getting-started-csharp-ubuntu.md b/docs/zh-cn/develop/devenv/getting-started-csharp-ubuntu.md similarity index 100% rename from docs/zh-cn/sc/devenv/getting-started-csharp-ubuntu.md rename to docs/zh-cn/develop/devenv/getting-started-csharp-ubuntu.md diff --git a/docs/zh-cn/sc/devenv/getting-started-csharp.md b/docs/zh-cn/develop/devenv/getting-started-csharp.md similarity index 57% rename from docs/zh-cn/sc/devenv/getting-started-csharp.md rename to docs/zh-cn/develop/devenv/getting-started-csharp.md index 5fec50fc2..9f9dfa1eb 100644 --- a/docs/zh-cn/sc/devenv/getting-started-csharp.md +++ b/docs/zh-cn/develop/devenv/getting-started-csharp.md @@ -1,4 +1,4 @@ # 在Windows上使用C#编写合约 -关于如何在Windows系统中使用C#编写合约,请参考快速入门中的[开发示例合约](../gettingstarted/develop.md)。 +关于如何在Windows系统中使用C#编写合约,请参考快速入门中的[开发示例合约](../../gettingstarted/develop.md)。 diff --git a/docs/zh-cn/sc/devenv/getting-started-python.md b/docs/zh-cn/develop/devenv/getting-started-python.md similarity index 100% rename from docs/zh-cn/sc/devenv/getting-started-python.md rename to docs/zh-cn/develop/devenv/getting-started-python.md diff --git a/docs/zh-cn/network/assets/create-wallet.png b/docs/zh-cn/develop/network/assets/create-wallet.png similarity index 100% rename from docs/zh-cn/network/assets/create-wallet.png rename to docs/zh-cn/develop/network/assets/create-wallet.png diff --git a/docs/zh-cn/network/assets/initial-balance.png b/docs/zh-cn/develop/network/assets/initial-balance.png similarity index 100% rename from docs/zh-cn/network/assets/initial-balance.png rename to docs/zh-cn/develop/network/assets/initial-balance.png diff --git a/docs/zh-cn/network/assets/private_multi_tx1.png b/docs/zh-cn/develop/network/assets/private_multi_tx1.png similarity index 100% rename from docs/zh-cn/network/assets/private_multi_tx1.png rename to docs/zh-cn/develop/network/assets/private_multi_tx1.png diff --git a/docs/zh-cn/network/assets/private_multi_tx2.png b/docs/zh-cn/develop/network/assets/private_multi_tx2.png similarity index 100% rename from docs/zh-cn/network/assets/private_multi_tx2.png rename to docs/zh-cn/develop/network/assets/private_multi_tx2.png diff --git a/docs/zh-cn/network/assets/private_multi_tx3.png b/docs/zh-cn/develop/network/assets/private_multi_tx3.png similarity index 100% rename from docs/zh-cn/network/assets/private_multi_tx3.png rename to docs/zh-cn/develop/network/assets/private_multi_tx3.png diff --git a/docs/zh-cn/network/assets/privatechain_1.jpg b/docs/zh-cn/develop/network/assets/privatechain_1.jpg similarity index 100% rename from docs/zh-cn/network/assets/privatechain_1.jpg rename to docs/zh-cn/develop/network/assets/privatechain_1.jpg diff --git a/docs/zh-cn/network/assets/privatechain_3.jpg b/docs/zh-cn/develop/network/assets/privatechain_3.jpg similarity index 100% rename from docs/zh-cn/network/assets/privatechain_3.jpg rename to docs/zh-cn/develop/network/assets/privatechain_3.jpg diff --git a/docs/zh-cn/network/assets/solo.png b/docs/zh-cn/develop/network/assets/solo.png similarity index 100% rename from docs/zh-cn/network/assets/solo.png rename to docs/zh-cn/develop/network/assets/solo.png diff --git a/docs/zh-cn/network/private-chain/private-chain2.md b/docs/zh-cn/develop/network/private-chain/private-chain2.md similarity index 95% rename from docs/zh-cn/network/private-chain/private-chain2.md rename to docs/zh-cn/develop/network/private-chain/private-chain2.md index fb7426b4d..34bda0089 100644 --- a/docs/zh-cn/network/private-chain/private-chain2.md +++ b/docs/zh-cn/develop/network/private-chain/private-chain2.md @@ -6,7 +6,7 @@ 首先安装 Neo-CLI,并将节点文件复制为 4 份,文件夹名分别命名为 node1、node2、node3、node4。 -安装过程请参考 [Neo 节点的安装部署](../../node/cli/setup.md)。 +安装过程请参考 [Neo 节点的安装部署](../../../node/cli/setup.md)。 ## 创建钱包文件 @@ -217,7 +217,7 @@ start cmd /k "cd node4 &&ping localhost -n 3 > nul&& dotnet neo-cli.dll" 进入每个节点目录,双击 `Run.cmd`,如果控制台打印出共识信息并且区块高度增长表示私链成功搭建: -![](../../assets/privatechain_demo.png) +![](../../../assets/privatechain_demo.png) 如果关闭所有窗口,将停止私有链。 @@ -276,7 +276,7 @@ start cmd /k "cd node4 &&ping localhost -n 3 > nul&& dotnet neo-cli.dll" 7. 输入 `list asset` 查看钱包资产,可以看到 NEO 已经转入。 - ![image](../../../en-us/assets/privatechain_32.png) + ![image](../../../../en-us/assets/privatechain_32.png) 参考前面提取 NEO 进行的多方签名操作,同样可以提取 GAS 到目标地址。 @@ -284,7 +284,7 @@ start cmd /k "cd node4 &&ping localhost -n 3 > nul&& dotnet neo-cli.dll" #### 创建多方签名地址 -1. 参考 [安装 Neo-GUI](../../node/gui/install.md) 下载安装 Neo-GUI 并将其连接到私链。 +1. 参考 [安装 Neo-GUI](../../../node/gui/install.md) 下载安装 Neo-GUI 并将其连接到私链。 2. 配置 config.private.json 文件,设置端口与 Neo-CLI 的端口不冲突。如果端口冲突,Neo-GUI 将无法与 Neo-CLI 同时运行。 @@ -305,7 +305,7 @@ start cmd /k "cd node4 &&ping localhost -n 3 > nul&& dotnet neo-cli.dll" 2. 输入要转入的标准地址,将 Neo/GAS 转到这个地址中。 -3. 参考 [签名](../../node/gui/advanced.html#签名) 完成转账交易。 +3. 参考 [签名](../../../node/gui/advanced.html#签名) 完成转账交易。 等待片刻后将看到 NEO/GAS 成功转入了标准地址。 diff --git a/docs/zh-cn/network/private-chain/solo.md b/docs/zh-cn/develop/network/private-chain/solo.md similarity index 96% rename from docs/zh-cn/network/private-chain/solo.md rename to docs/zh-cn/develop/network/private-chain/solo.md index 0594195b4..d29fa5e20 100644 --- a/docs/zh-cn/network/private-chain/solo.md +++ b/docs/zh-cn/develop/network/private-chain/solo.md @@ -6,7 +6,7 @@ Neo-CLI 支持单节点模式下正常生成区块,只需一个节点即可正 ## 准备工作 -1. 首先安装 Neo-CLI,安装过程请参考 [Neo 节点的安装部署](../../node/cli/setup.md)。 +1. 首先安装 Neo-CLI,安装过程请参考 [Neo 节点的安装部署](../../../node/cli/setup.md)。 2. 运行 Neo-CLI,输入 `create wallet ` 命令创建一个钱包,如 `create wallet consensus.json`。 3. 设置钱包密码(password),并确认密码。 @@ -150,7 +150,7 @@ Neo-CLI 支持单节点模式下正常生成区块,只需一个节点即可正 ### 使用 Neo-GUI 提取 -1. 参考 [安装 Neo-GUI](../../node/gui/install.md) 下载安装 Neo-GUI 并将其连接到私链。 +1. 参考 [安装 Neo-GUI](../../../node/gui/install.md) 下载安装 Neo-GUI 并将其连接到私链。 2. 配置 config.private.json 文件,设置端口与 Neo-CLI 的端口不冲突。如果端口冲突,Neo-GUI 将无法与 Neo-CLI 同时运行。 3. 运行 Neo-GUI,打开钱包 consensus.json。 4. 点击 `账户列表` 旁的 `+` 按钮,并选择`创建多签地址`。 diff --git a/docs/zh-cn/network/testnet.md b/docs/zh-cn/develop/network/testnet.md similarity index 96% rename from docs/zh-cn/network/testnet.md rename to docs/zh-cn/develop/network/testnet.md index 1126bfff8..06251a904 100644 --- a/docs/zh-cn/network/testnet.md +++ b/docs/zh-cn/develop/network/testnet.md @@ -26,11 +26,11 @@ Neo 也提供了测试网(Test Net)供开发者进行开发、调试和测 1. 将客户端目录下的 `protocol.testnet.json` 里的内容复制到 `protocol.json`(替换原有配置文件),如图所示: - ![](../assets/testnet_1_v2.png) + ![](../../assets/testnet_1_v2.png) 2. 将客户端目录下的 `config.testnet.json` 里的内容复制到 `config.json`(替换原有配置文件),如图所示: - ![](../assets/testnet_2_v2.png) + ![](../../assets/testnet_2_v2.png) ## 申请测试网 GAS 和 NEO @@ -51,7 +51,7 @@ Neo 也提供了测试网(Test Net)供开发者进行开发、调试和测 #### 第 2 步 - 填写申请 填写申请表:https://neo.org/testcoin/apply ,注意选择Neo版本为Neo3。 -一般一天后将收到邮件回复,包含一个多方签名地址和发件人的公钥。关于多方签名地址,请参见 [多方签名地址](../node/gui/sc.md)。 +一般一天后将收到邮件回复,包含一个多方签名地址和发件人的公钥。关于多方签名地址,请参见 [签名](../../node/gui/advanced.md)。 #### 第 3 步 - 创建多方签名地址并转账 diff --git a/docs/zh-cn/sc/sample/Domain.md b/docs/zh-cn/develop/sample/Domain.md similarity index 100% rename from docs/zh-cn/sc/sample/Domain.md rename to docs/zh-cn/develop/sample/Domain.md diff --git a/docs/zh-cn/sc/sample/HelloWorld.md b/docs/zh-cn/develop/sample/HelloWorld.md similarity index 100% rename from docs/zh-cn/sc/sample/HelloWorld.md rename to docs/zh-cn/develop/sample/HelloWorld.md diff --git a/docs/zh-cn/sc/sample/storage.md b/docs/zh-cn/develop/sample/storage.md similarity index 91% rename from docs/zh-cn/sc/sample/storage.md rename to docs/zh-cn/develop/sample/storage.md index 8f443d7c3..c3e66ca20 100644 --- a/docs/zh-cn/sc/sample/storage.md +++ b/docs/zh-cn/develop/sample/storage.md @@ -2,9 +2,9 @@ ## 什么是合约存储区? -每个被部署到 Neo 区块链上的智能合约程序,都拥有一个只有该合约本身可以读写、修改和删除数据的私有存储区。数据以键值对(Key-Value)的形式存放,其中 Key 可以为字符串(String)或字节数组(ByteArray),Value 可以为任意类型。详细存储区操作请参考 [Storage 类](../reference/scapi/fw/dotnet/neo/Storage.md)。 +每个被部署到 Neo 区块链上的智能合约程序,都拥有一个只有该合约本身可以读写、修改和删除数据的私有存储区。数据以键值对(Key-Value)的形式存放,其中 Key 可以为字符串(String)或字节数组(ByteArray),Value 可以为任意类型。详细存储区操作请参考 [Storage 类](../../reference/scapi/fw/dotnet/neo/Storage.md)。 -在Neo中,常用的存储区操作是通过 [StorageMap](../reference/scapi/fw/dotnet/neo/StorageMap.md) 来进行的。它在 Storage 的 Key 前面附加了前缀,不同的前缀相当于不同的数据库表。使用 StorageMap 能更安全地操作存储区。 +在Neo中,常用的存储区操作是通过 [StorageMap](../../reference/scapi/fw/dotnet/neo/StorageMap.md) 来进行的。它在 Storage 的 Key 前面附加了前缀,不同的前缀相当于不同的数据库表。使用 StorageMap 能更安全地操作存储区。 智能合约的存储区操作包含以下接口: @@ -54,7 +54,7 @@ var Hash = Storage.CurrentContext.CreateMap("Hash"); ## 操作存储区 -参考 [Storage 类](../reference/scapi/fw/dotnet/neo/Storage.md) 和 [StorageMap](../reference/scapi/fw/dotnet/neo/StorageMap.md) 类,另外 [Helper](../../reference/scapi/fw/dotnet/neo/Helper.md) 类为 StorageMap 提供了操作存储区的扩展方法。下面为代码示例。 +参考 [Storage 类](../../reference/scapi/fw/dotnet/neo/Storage.md) 和 [StorageMap](../../reference/scapi/fw/dotnet/neo/StorageMap.md) 类,另外 [Helper](../../reference/scapi/fw/dotnet/neo/Helper.md) 类为 StorageMap 提供了操作存储区的扩展方法。下面为代码示例。 ### 写入/修改 diff --git a/docs/zh-cn/tooldev/sdk/contract.md b/docs/zh-cn/develop/tool/sdk/contract.md similarity index 53% rename from docs/zh-cn/tooldev/sdk/contract.md rename to docs/zh-cn/develop/tool/sdk/contract.md index 418681f68..9b4fbcfb0 100644 --- a/docs/zh-cn/tooldev/sdk/contract.md +++ b/docs/zh-cn/develop/tool/sdk/contract.md @@ -8,7 +8,7 @@ ## 合约部署 -`ContractClient` 中提供了合约部署交易的构建方法 `CreateDeployContractTx`, 参数为合约脚本,manifest 和支付系统费和网络费的账户密钥对,其中合约脚本和 manifest 可通过编译获取,账户中需要有足够的 GAS 支付所需费用。 +`ContractClient` 中提供了合约部署交易的构建方法 `CreateDeployContractTxAsync`, 参数为合约脚本,manifest 和支付系统费和网络费的账户密钥对,其中合约脚本和 manifest 可通过编译获取,账户中需要有足够的 GAS 支付所需费用。 读取合约 nef 和 manifest.json 文件: @@ -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` 还提供了以下读取方法: ```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/tooldev/sdk/introduction.md b/docs/zh-cn/develop/tool/sdk/introduction.md similarity index 92% rename from docs/zh-cn/tooldev/sdk/introduction.md rename to docs/zh-cn/develop/tool/sdk/introduction.md index 535a6beb0..43785c6e5 100644 --- a/docs/zh-cn/tooldev/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" @@ -64,7 +64,5 @@ Neo-modules:https://github.com/neo-project/neo-modules https://github.com/neo-project/neo-modules/issues -## 阅读下节 -[RPC 调用方法](rpc.md) diff --git a/docs/zh-cn/develop/tool/sdk/monitor.md b/docs/zh-cn/develop/tool/sdk/monitor.md new file mode 100644 index 000000000..205dd350d --- /dev/null +++ b/docs/zh-cn/develop/tool/sdk/monitor.md @@ -0,0 +1,79 @@ +# 获取区块信息 + +基本的区块链数据和状态信息,如区块高度、区块内容、交易内容和合约等可以通过 `RPC` 模块直接获取,详细信息请参见 [RPC 调用方法](rpc.md)。 + +而某些特定的合约信息,如区块最大交易数量,每字节系统费,NEP5 合约信息等则需要调用特定的合约方法。 + + +## 通过 RPC 接口获取区块数据 + +获取最新区块高度或哈希: + +```c# +// choose a neo node with rpc opened +RpcClient client = new RpcClient("http://127.0.0.1:10332"); + +// get the hash of the tallest block in the main chain +string hash = await client.GetBestBlockHashAsync().ConfigureAwait(false); + +// get the number of blocks in the main chain +uint count = await client.GetBlockCountAsync().ConfigureAwait(false); +``` + +获取指定高度或哈希的区块内具体数据,包括交易列表等;结果可以是Base64编码的字符串或者Json字符串: + +```c# +// 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 = await client.GetBlockAsync("0x4e61cd9d76e30e9147ee0f5b9c92f4447decbe52c6c8b412d0382a14d3a0b408").ConfigureAwait(false); +``` + +通过 `RpcClient` 获取合约脚本、哈希与 manifest 的信息: + +```c# +// get NEO contract state +ContractState contractState = await client.GetContractStateAsync(NativeContract.NEO.Hash.ToString()).ConfigureAwait(false); +``` + +更多信息请参见 [RPC 调用方法](rpc.md)。 + +## 获取 Policy 相关信息 + +调用原生合约 `PolicyContract` 中的方法 `policyAPI` 获取 Policy 相关信息: + +```c# +// choose a neo node with rpc opened +PolicyAPI policyAPI = new PolicyAPI(new RpcClient("http://127.0.0.1:10332")); + +// get the system fee per byte +long feePerByte = await policyAPI.GetFeePerByteAsync().ConfigureAwait(false); // 1000, 0.00001000 GAS per byte + +// get the max size of one block +uint maxBlockSize = await policyAPI.GetMaxBlockSizeAsync().ConfigureAwait(false); // 262144, (1024 * 256) bytes one block + +// get the max transaction count per 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 合约信息 + +NEP5 是 Neo3 中的资产标准,NEO 和 GAS 都基于 NEP5 原生合约。调用 `Nep5API` 可以获取 NEP5 合约的名称、标记、小数位和总量等信息: + +```c# +// get nep5 token info +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/tooldev/sdk/rpc.md b/docs/zh-cn/develop/tool/sdk/rpc.md similarity index 52% rename from docs/zh-cn/tooldev/sdk/rpc.md rename to docs/zh-cn/develop/tool/sdk/rpc.md index 6ed3d4397..76b71dd7c 100644 --- a/docs/zh-cn/tooldev/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,47 +279,58 @@ 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; ``` ## 节点本地钱包 节点本地钱包接口包含可以访问节点本地钱包文件的功能,使用该部分的方法之前需要先通过 `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 +338,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(); -``` - -### 打开钱包 -打开节点所在机器中的钱包文件: - -```c# -string path = "D:/temp/123.json"; -string pass = "Password***"; -bool result = client.OpenWallet(path, pass); +List acoounts = await client.ListAddressAsync().ConfigureAwait(false); ``` - ### 从指定地址转账 从指定地址,向指定地址转账: @@ -345,7 +355,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 +378,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 +391,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 +405,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 +420,7 @@ RpcApplicationLog log = client.GetApplicationLog(txHash); ```c# string address = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; -RpcNep5Balances balances = client.GetNep5Balances(address); +RpcNep5Balances balances = await client.GetNep5BalancesAsync(address).ConfigureAwait(false); ``` ### 查询交易记录 @@ -415,10 +431,8 @@ RpcNep5Balances balances = client.GetNep5Balances(address); ```c# string address = "NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"; -RpcNep5Transfers transfers = client.GetNep5Transfers(address, 0); +RpcNep5Transfers transfers = await client.GetNep5TransfersAsync(address, 0).ConfigureAwait(false); ``` -### 阅读下节 -[获取区块信息](monitor.md) diff --git a/docs/zh-cn/develop/tool/sdk/transaction.md b/docs/zh-cn/develop/tool/sdk/transaction.md new file mode 100644 index 000000000..511758ba1 --- /dev/null +++ b/docs/zh-cn/develop/tool/sdk/transaction.md @@ -0,0 +1,310 @@ +# 构造交易 + +`Neo RPC SDK` 封装了交易构造模块,通过该模块可以使用特定的参数和方法构造 Neo3 中的交易,完成个性化的功能,本篇主要介绍这部分的使用方法。 + +> [!Note] +> +> 如果使用 SDK 中构造交易并附有签名相关的方法,需要维护一份当前所在 NEO 区块链的 protocol.json 在程序运行目录下,例如 \bin 或 \publish 目录,以确保 SDK 使用的 `Magic` 和 区块链一致,否则 SDK 构造的交易在区块链中将无法验签通过。 + +## 交易构造步骤 + +1. 构造交易脚本,决定交易要执行什么样的功能,比如转账交易: + + ```c# + // construct the script, in this example, we will transfer 1 NEO to the receiver + UInt160 scriptHash = NativeContract.NEO.Hash; + byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); + ``` + +2. 构造 `TransactionManagerFactory`,将`RpcClient`和 `Magic`作为参数; 构造`TransactionManager`, 将`Script`和`Signers`作为参数。 + + ```c# + TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) + .MakeTransactionAsync(script, cosigners).ConfigureAwait(false); + ``` + +3. 添加签名(单签或者多签),将账户的 `KeyPair` 作为签名的参数;并且签名。 + + - 单签 + + ```c# + // add signature for the transaction with sendKey + txManager.AddSignature(sendKey); + ``` + - 多签 + + ```c# + // add multi-signatures for the transaction with sendKey + txManager.AddMultiSig(receiverKey, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); + txManager.AddMultiSig(key2, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); + ``` + - 多签合约 + + 多签的本质来源于多签合约,需要先构建多签合约才能获取多签地址,进行多签转账。下面的示例使用了3个账户构成多签,验签时需要至少2个账户签名 + + ```c# + // 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. 校验签名,并将 `Witness` 添加至交易体。 + + 如果签名数量不够或手续费不够会引发异常。 + + ```c# + // sign the transaction with the added signatures + Transaction tx = await txManager.SignAsync().ConfigureAwait(false); + ``` +## 交易构造示例 + +### 构造 NEP5 转账交易 + +下面的示例实现了从sender账户转账1024个NEO到receiver账户的功能。构建不同交易时需要关注交易中脚本和所需签名的不同。 + +```c# +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"); + UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; + + // 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("NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM"); + + // 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, 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. + 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); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} +``` + +`WalletAPI` 封装了上面的过程,NEP5 转账可以简化为: + +```c# +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}")); + } + } +} +``` + +### 构造交易向多签账户转账 + +下面的示例实现了向多签账户转账 10 个 GAS 的功能。多签账户的 scripthash 由多签合约脚本的 hash 得来。因为发送方为普通账户,添加签名的过程与上一个示例没有区别。 + +```c# +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; +using Utility = Neo.Network.RPC.Utility; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + 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("L53tg72Az8QhYUAyyqTQ3LaXMXBE3S9mJGGZVKHBryZxya7prwhZ"); + UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; + + // get the KeyPair of your accounts + 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 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, 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); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} + +``` + +### 构造交易从多签账户转账 + +下面的示例实现了从多签账户转出1024个GAS的功能。多签账户的scripthash由多签合约脚本的hash得来。因为需要从多签账户转账,添加签名时要根据多签合约要求的签名数量添加。 + +```c# +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; +using Utility = Neo.Network.RPC.Utility; + +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://127.0.0.1:10332"); + + // get the KeyPair of your account + 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); + // get the scripthash of the multi-signature Contract + UInt160 multiAccount = multiContract.Script.ToScriptHash(); + + UInt160 receiver = Contract.CreateSignatureContract(receiverKey.PublicKey).ScriptHash; + + // 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); + await neoAPI.WaitTransactionAsync(tx) + .ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); + } + } +} +``` + diff --git a/docs/zh-cn/tooldev/sdk/wallet.md b/docs/zh-cn/develop/tool/sdk/wallet.md similarity index 82% rename from docs/zh-cn/tooldev/sdk/wallet.md rename to docs/zh-cn/develop/tool/sdk/wallet.md index ead084c85..c48ae49f7 100644 --- a/docs/zh-cn/tooldev/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,13 +239,8 @@ 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); ``` -## 阅读下节 -[构造交易](transaction.md) diff --git a/docs/zh-cn/sc/write/basics.md b/docs/zh-cn/develop/write/basics.md similarity index 100% rename from docs/zh-cn/sc/write/basics.md rename to docs/zh-cn/develop/write/basics.md diff --git a/docs/zh-cn/sc/write/limitation.md b/docs/zh-cn/develop/write/limitation.md similarity index 100% rename from docs/zh-cn/sc/write/limitation.md rename to docs/zh-cn/develop/write/limitation.md diff --git a/docs/zh-cn/sc/migrate.md b/docs/zh-cn/develop/write/migrate.md similarity index 87% rename from docs/zh-cn/sc/migrate.md rename to docs/zh-cn/develop/write/migrate.md index 39763c541..74571ecfa 100644 --- a/docs/zh-cn/sc/migrate.md +++ b/docs/zh-cn/develop/write/migrate.md @@ -26,14 +26,14 @@ public static bool Update(byte[] script, string manifest) } ``` -如果希望未来对合约进行迁移,那么此合约在部署之前必须实现 `update` 接口。关于部署合约,请参考 [部署和调用合约](deploy/deploy.md)。 +如果希望未来对合约进行迁移,那么此合约在部署之前必须实现 `update` 接口。关于部署合约,请参考 [部署和调用合约](../deploy/deploy.md)。 ### 进行合约迁移 -首先准备好新合约,然后通过 Neo-CLI 调用旧合约的 Migrate 的接口。 +首先准备好新合约,然后通过 Neo-CLI 调用旧合约的 update 接口。 -关于调用合约,请参考 [调用合约](deploy/invoke.md)。 +关于调用合约,请参考 [调用合约](../deploy/invoke.md)。 -执行 Update 方法后,合约的存储区已迁移到新的合约上,旧合约被销毁。 +执行 update 方法后,合约的存储区已迁移到新的合约上,旧合约被销毁。 ## 合约销毁 diff --git a/docs/zh-cn/sc/write/nep5.md b/docs/zh-cn/develop/write/nep5.md similarity index 64% rename from docs/zh-cn/sc/write/nep5.md rename to docs/zh-cn/develop/write/nep5.md index c6a60d19d..c11065847 100644 --- a/docs/zh-cn/sc/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; } } diff --git a/docs/zh-cn/exchange/transaction.md b/docs/zh-cn/exchange/transaction.md index 19a201588..353c215cf 100644 --- a/docs/zh-cn/exchange/transaction.md +++ b/docs/zh-cn/exchange/transaction.md @@ -24,7 +24,7 @@ NetworkFee = VerificationCost + tx.size * FeePerByte ## 系统费 -系统费是根据 NeoVM 要执行的指令计算得出的费用,有关每个操作指令的费用,请参考[系统费用](../sc/fees.md)。Neo3 中取消了每笔交易 10 GAS 的免费额度,系统费用总额受合约脚本的指令数量和指令类型影响,计算公式如下: +系统费是根据 NeoVM 要执行的指令计算得出的费用,有关每个操作指令的费用,请参考[系统费用](../reference/fees.md)。Neo3 中取消了每笔交易 10 GAS 的免费额度,系统费用总额受合约脚本的指令数量和指令类型影响,计算公式如下: ``` SystemFee = InvocationCost = The sum of all executed opcode fee diff --git a/docs/zh-cn/sc/gettingstarted/assets/2_privatechain_demo.png b/docs/zh-cn/gettingstarted/assets/2_privatechain_demo.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/2_privatechain_demo.png rename to docs/zh-cn/gettingstarted/assets/2_privatechain_demo.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_1545037391347.png b/docs/zh-cn/gettingstarted/assets/3_1545037391347.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_1545037391347.png rename to docs/zh-cn/gettingstarted/assets/3_1545037391347.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_2017-06-07_12-07-03.png b/docs/zh-cn/gettingstarted/assets/3_2017-06-07_12-07-03.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_2017-06-07_12-07-03.png rename to docs/zh-cn/gettingstarted/assets/3_2017-06-07_12-07-03.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg b/docs/zh-cn/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg rename to docs/zh-cn/gettingstarted/assets/3_download_and_install_smart_contract_plugin.jpg diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_environment_variable.png b/docs/zh-cn/gettingstarted/assets/3_environment_variable.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_environment_variable.png rename to docs/zh-cn/gettingstarted/assets/3_environment_variable.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg b/docs/zh-cn/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg rename to docs/zh-cn/gettingstarted/assets/3_install_core_cross_platform_development_toolset.jpg diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_new_smart_contract_project.png b/docs/zh-cn/gettingstarted/assets/3_new_smart_contract_project.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_new_smart_contract_project.png rename to docs/zh-cn/gettingstarted/assets/3_new_smart_contract_project.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_publish_and_profile_settings.jpg b/docs/zh-cn/gettingstarted/assets/3_publish_and_profile_settings.jpg similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_publish_and_profile_settings.jpg rename to docs/zh-cn/gettingstarted/assets/3_publish_and_profile_settings.jpg diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_publish_and_profile_settings.png b/docs/zh-cn/gettingstarted/assets/3_publish_and_profile_settings.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_publish_and_profile_settings.png rename to docs/zh-cn/gettingstarted/assets/3_publish_and_profile_settings.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg b/docs/zh-cn/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg rename to docs/zh-cn/gettingstarted/assets/3_publish_neo_compiler_msil_project.jpg diff --git a/docs/zh-cn/sc/gettingstarted/assets/3_smart_contract_function_code.png b/docs/zh-cn/gettingstarted/assets/3_smart_contract_function_code.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/3_smart_contract_function_code.png rename to docs/zh-cn/gettingstarted/assets/3_smart_contract_function_code.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/compile.png b/docs/zh-cn/gettingstarted/assets/compile.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/compile.png rename to docs/zh-cn/gettingstarted/assets/compile.png diff --git a/docs/zh-cn/sc/gettingstarted/assets/contractfile.png b/docs/zh-cn/gettingstarted/assets/contractfile.png similarity index 100% rename from docs/zh-cn/sc/gettingstarted/assets/contractfile.png rename to docs/zh-cn/gettingstarted/assets/contractfile.png diff --git a/docs/zh-cn/sc/assets/env.png b/docs/zh-cn/gettingstarted/assets/env.png similarity index 100% rename from docs/zh-cn/sc/assets/env.png rename to docs/zh-cn/gettingstarted/assets/env.png diff --git a/docs/zh-cn/sc/assets/neocontract.png b/docs/zh-cn/gettingstarted/assets/neocontract.png similarity index 100% rename from docs/zh-cn/sc/assets/neocontract.png rename to docs/zh-cn/gettingstarted/assets/neocontract.png diff --git a/docs/zh-cn/sc/assets/neon.png b/docs/zh-cn/gettingstarted/assets/neon.png similarity index 100% rename from docs/zh-cn/sc/assets/neon.png rename to docs/zh-cn/gettingstarted/assets/neon.png diff --git a/docs/zh-cn/sc/gettingstarted/deploy.md b/docs/zh-cn/gettingstarted/deploy.md similarity index 66% rename from docs/zh-cn/sc/gettingstarted/deploy.md rename to docs/zh-cn/gettingstarted/deploy.md index 984089272..9246f1dcd 100644 --- a/docs/zh-cn/sc/gettingstarted/deploy.md +++ b/docs/zh-cn/gettingstarted/deploy.md @@ -4,7 +4,7 @@ ## 部署合约 -在 Neo-CLI 中,输入部署合约命令 `deploy [manifestFile]` ,例如: +在 Neo-CLI 中,打开前面在 [准备工作](prerequisites.md) 里创建的钱包 0.json,输入部署合约命令 `deploy [manifestFile]` ,例如: ```bash deploy NEP5.nef @@ -26,7 +26,7 @@ Gas: 3 Signed and relayed transaction with hash=0xe03aade81fb96c44e115a1cc9cfe984a9df4a283bd10aa0aefa7ebf3e296f757 ``` -更多部署信息请参考 [部署智能合约](../deploy/deploy.md)。 +更多部署信息请参考 [部署智能合约](../develop/deploy/deploy.md)。 ## 调用合约 @@ -55,7 +55,7 @@ relay tx(no|yes): 其中: -- VM State : `HALT` 表示虚拟机执行成功, `FAULT` 表示虚拟机执行时遇到异常退出。 -- Evaluation Stack :合约执行结果,如果 value 是字符串或 ByteArray,则是 Base64 编码后的结果。 +- VM State: `HALT` 表示虚拟机执行成功, `FAULT` 表示虚拟机执行时遇到异常退出。 +- Evaluation Stack: 合约执行结果,如果 value 是字符串或 ByteArray,则是 Base64 编码后的结果。 -更多智能合调用信息请参考 [调用智能合约](../deploy/dinvoke.md)。 +更多智能合调用信息请参考 [调用智能合约](../develop/deploy/invoke.md)。 diff --git a/docs/zh-cn/sc/gettingstarted/develop.md b/docs/zh-cn/gettingstarted/develop.md similarity index 95% rename from docs/zh-cn/sc/gettingstarted/develop.md rename to docs/zh-cn/gettingstarted/develop.md index 2878bc8a3..5a33665df 100644 --- a/docs/zh-cn/sc/gettingstarted/develop.md +++ b/docs/zh-cn/gettingstarted/develop.md @@ -1,6 +1,6 @@ # 开发示例合约 -我们已经搭建私链并启动节点连接私链,下文将以使用 windows 10 和 C# 为例,带领开发者配置环境、编写、编译以及在私链上部署和调用 Neo 智能合约。 +我们已经搭建私链并启动节点连接私链,下文将以使用 Windows 10 和 C# 为例,带领开发者配置环境、编写、编译以及在私链上部署和调用 Neo 智能合约。 在本节我们将完成以下任务: @@ -40,7 +40,7 @@ 3. 进入上一步的发布路径,启动 PowerShell,输入命令 `./neon.exe` 确保 neon 可以正常启动,如下图所示: - ![neon](../assets/neon.png) + ![neon](assets/neon.png) 4. 将发布目录添加到环境变量 Path 中 : @@ -48,7 +48,7 @@ > > 如果存在旧版本的neon,需要先删除。 - ![env](../assets/env.png) + ![](assets/env.png) 5. 在任意位置启动 PowerShell,输入命令 `neon.exe` 确保环境变量已正确配置。 @@ -65,7 +65,7 @@ 2. 在项目模板对话框中,搜索neocontract,选择C#对应的NeoContact,并根据向导完成项目创建。 - ![neocontract](../assets/neocontract.png) + ![neocontract](assets/neocontract.png) 3. 在解决方案中,右键单击项目名 -> `管理 NuGet 程序包`,卸载 `Neo.SmartContract.Framework` 的 NuGet 引用。 @@ -110,7 +110,3 @@ - `NEP5.nef` :与 Neo2 中的 .avm 文件类似,.nef 是 Neo3 的智能合约执行文件。 - `NEP5.manifest.json` :智能合约的描述文档,文档中对合约的功能、ScriptHash、入口、方法、参数、返回值等进行了描述。 - -## 继续阅读 - -[部署与调用合约](deploy.md) diff --git a/docs/zh-cn/sc/gettingstarted/enviroment.md b/docs/zh-cn/gettingstarted/enviroment.md similarity index 55% rename from docs/zh-cn/sc/gettingstarted/enviroment.md rename to docs/zh-cn/gettingstarted/enviroment.md index 149235e7a..91aa34c86 100644 --- a/docs/zh-cn/sc/gettingstarted/enviroment.md +++ b/docs/zh-cn/gettingstarted/enviroment.md @@ -2,21 +2,17 @@ ## 搭建私链 -Neo 官方提供了供用户开发、调试和测试的测试网(Test Net),但在本地搭建你自己的私链将获得更多的灵活性以及取之不尽的测试币。你可以选择以下一种方式搭建私有链: +Neo 官方提供了供用户开发、调试和测试的测试网(Test Net),但在本地搭建你自己的私链将获得更多的灵活性以及取之不尽的测试币。你可以选择以下一种方式搭建私有链并提取创世区块中的 NEO 和 GAS: -- [使用单节点搭建](../../network/private-chain/solo.md) -- [在一台 Windows 主机上搭建](../../network/private-chain/private-chain2.md) - -参考以上链接,完成私链搭建并提取创世区块中的 NEO 和 GAS。 +- [使用单节点搭建](../develop/network/private-chain/solo.md) +- [在一台 Windows 主机上搭建](../develop/network/private-chain/private-chain2.md) ## 准备节点钱包文件 现在我们创建一个新的钱包文件用于发布智能合约: -1. 在 Neo-CLI 中创建一个新的钱包文件 0.json,复制默认地址备用。 +1. 在 Neo-CLI 中,输入命令 `create wallet`, 创建一个新的钱包文件 0.json,复制默认地址备用。 2. 打开前面提取了 NEO 和 GAS 的钱包,将钱包中全部的资产都转入钱包 0.json 中,等待交易确认。 3. 打开钱包文件 0.json,可以看到其中的资产。 -## 继续阅读 - -[开发示例合约](develop.md) +更多 Neo-CLI 命令,请参考 [CLI](../node/cli/cli.md)。 diff --git a/docs/zh-cn/sc/gettingstarted/prerequisites.md b/docs/zh-cn/gettingstarted/prerequisites.md similarity index 72% rename from docs/zh-cn/sc/gettingstarted/prerequisites.md rename to docs/zh-cn/gettingstarted/prerequisites.md index 063911ba3..bd9438367 100644 --- a/docs/zh-cn/sc/gettingstarted/prerequisites.md +++ b/docs/zh-cn/gettingstarted/prerequisites.md @@ -4,7 +4,7 @@ Neo 有两个全节点客户端:Neo-GUI 和 Neo-CLI。本教程将使用 Neo-CLI 搭建私链发布智能合约。 -## 系统环境 +## 系统环境 Neo-CLI 支持以下环境: @@ -14,8 +14,5 @@ Neo-CLI 支持以下环境: ## 下载客户端 -参考 [Neo-CLI 安装](../../node/cli/setup.md) 下载并安装 Neo-CLI Preview2 程序包。 +参考 [Neo-CLI 安装](../node/cli/setup.md) 下载并安装 Neo-CLI Preview4 程序包。 -## 继续阅读 - -[搭建本地网络](enviroment.md) diff --git a/docs/zh-cn/index.md b/docs/zh-cn/index.md index 2d64b34ca..6912d953d 100644 --- a/docs/zh-cn/index.md +++ b/docs/zh-cn/index.md @@ -2,31 +2,38 @@ ####Neo 官方的技术文档都在这里,还有众多开发示例可供参考。 +| 快速入门 | | | | +| ------------------------------------- | ---- | ---- | ---- | +| [合约开发快速入门](gettingstarted/prerequisites.md) | | | | + +| Neo 基础知识 | | | | +| --------------------------------------------- | ----------------------------------- | ------------------------------------------- | -------------------------------------------------------- | +| [区块模型](basic/concept/blockchain/block.md) | [共识机制](basic/consensus/dbft.md) | [Neo VM](basic/neovm.md) | [密码学](basic/concept/cryptography/encode_algorithm.md) | +| [交易](basic/concept/transaction.md) | [钱包](basic/concept/wallets.md) | [收费模型](basic/concept/charging_model.md) | | + + | Neo 节点 | | | | | -------------------------------- | ---------------------------- | ------------------------------ | ---- | | [节点介绍](node/introduction.md) | [Neo-CLI](node/cli/setup.md) | [Neo-GUI](node/gui/install.md) | | -| Neo 网络 | | | | -| ---------------------------------- | -------------------------------------------- | ---- | ---- | -| [主网和测试网](network/testnet.md) | [搭建私有链 ](network/private-chain/solo.md) | | | +| 开发指南 | | | | +| -------------------------------------------- | ---------------------------------------- | -------------------------------------- | ---- | +| [Neo 网络](develop/network/testnet.md) | [合约编写](develop/write/basics.md) | [部署与调用](develop/deploy/deploy.md) | | +| [开发工具](develop/tool/sdk/introduction.md) | [合约示例](develop/sample/HelloWorld.md) | | | + +| 进阶知识 | | | | +| ---------------------------- | ---- | ---- | ---- | +| [Oracle](advanced/oracle.md) | | | | -| 智能合约开发 | | | | -| --------------------------------------------- | ------------------------------ | ----------------------------------- | ---- | -| [快速入门](sc/gettingstarted/introduction.md) | [合约编写](sc/write/basics.md) | [部署与调用](sc/deploy/deploy.md) | | -| [合约迁移](sc/migrate.md) | [系统使用费](sc/fees.md) | [合约示例](sc/sample/HelloWorld.md) | | -| Neo 底层解析 | | | | -| ----------------------------------------------- | --------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------------- | -| [区块模型](tooldev/concept/blockchain/block.md) | [收费模型](tooldev/concept/charging_model.md) | [共识机制](tooldev/consensus/consensus_algorithm.md) | [密码学](tooldev/concept/cryptography/encode_algorithm.md) | -| [交易](tooldev/transaction/transaction.md) | [钱包](tooldev/wallets.md) | [Neo SDK](tooldev/sdk/introduction.md) | [大小端序的使用](tooldev/concept/endian.md) | +| 开发参考 | | | | +| ---------------------------------------------- | --------------------------------------- | ------------------------------------- | ----------------------------------- | +| [RPC API](reference/rpc/latest-version/api.md) | [智能合约 API](reference/scapi/api.md) | [智能合约框架](reference/scapi/fw.md) | [NeoVM 指令集](reference/neo_vm.md) | +| [手续费](reference/fees.md) | [治理 API](reference/governance_api.md) | | | | 交易所对接 | | | | | ------------------------------------- | ---- | ---- | ---- | | [交易所对接指导](exchange/general.md) | | | | -| 开发参考 | | | | -| ---------------------------------------------- | -------------------------------------- | ------------------------------------- | ----------------------------------- | -| [RPC API](reference/rpc/latest-version/api.md) | [智能合约 API](reference/scapi/api.md) | [智能合约框架](reference/scapi/fw.md) | [NeoVM 指令集](reference/neo_vm.md) | - diff --git a/docs/zh-cn/glossary.md b/docs/zh-cn/intro/glossary.md similarity index 90% rename from docs/zh-cn/glossary.md rename to docs/zh-cn/intro/glossary.md index 87b0e2840..b58990f07 100644 --- a/docs/zh-cn/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/sc/gettingstarted/introduction.md b/docs/zh-cn/intro/introduction.md similarity index 69% rename from docs/zh-cn/sc/gettingstarted/introduction.md rename to docs/zh-cn/intro/introduction.md index 490926692..bbca62107 100644 --- a/docs/zh-cn/sc/gettingstarted/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#) diff --git a/docs/zh-cn/node/cli/cli.md b/docs/zh-cn/node/cli/cli.md index 9bd80d39d..c36241705 100644 --- a/docs/zh-cn/node/cli/cli.md +++ b/docs/zh-cn/node/cli/cli.md @@ -1047,7 +1047,7 @@ Install successful, please restart neo-cli. ### start consensus -启动共识。启动共识的前提是该钱包有共识的权限,在 Neo 主网上可以通过投票选举获得共识的权限,如果自己部署的私有链,可以在 `protocol.json` 中设置共识节点的公钥,详情可参考 [私链搭建](../../network/private-chain/private-chain2.md)。 +启动共识。启动共识的前提是该钱包有共识的权限,在 Neo 主网上可以通过投票选举获得共识的权限,如果自己部署的私有链,可以在 `protocol.json` 中设置共识节点的公钥,详情可参考 [私链搭建](../../develop/network/private-chain/private-chain2.md)。 > [!NOTE] > diff --git a/docs/zh-cn/node/cli/config.md b/docs/zh-cn/node/cli/config.md index b0bd67e7f..9e9fddcb8 100644 --- a/docs/zh-cn/node/cli/config.md +++ b/docs/zh-cn/node/cli/config.md @@ -53,7 +53,7 @@ Neo-CLI 在执行过程中会访问两个配置文件 `config.json` 和 `protoco 在 Neo3 中连接测试网需要配置 `config.json` 和 `protocol.json` 文件,用 `*.testnet.json` 中的内容去替换即可。 -如果要将节点接入私链,详细信息请参见[搭建私有链](../../network/private-chain/solo.md)中的说明。 +如果要将节点接入私链,详细信息请参见 [搭建私有链](../../develop/network/private-chain/solo.md) 中的说明。 ## 安装插件 @@ -191,7 +191,3 @@ dotnet neo-cli.dll > > 如果开通了 API 服务,并且在 Neo-CLI 中打开钱包的话,需要设置防火墙策略,例如设置防火墙的白名单,这些端口仅对白名单的 IP 地址开放。如果完全对外开放,其它人可能会通过 API 导出私钥或者进行转账。 -## 阅读下节 - -[CLI 命令参考](cli.md) - diff --git a/docs/zh-cn/node/cli/setup.md b/docs/zh-cn/node/cli/setup.md index 9be86fae7..cd78e94bf 100644 --- a/docs/zh-cn/node/cli/setup.md +++ b/docs/zh-cn/node/cli/setup.md @@ -37,7 +37,7 @@ ``` 并在ubuntu 18.04 上输入以下命令: - + ``` sudo apt-get install librocksdb-dev ``` @@ -52,7 +52,7 @@ 1. 下载 [neo-node](https://github.com/neo-project/neo-node) 项目,或通过 Git 命令克隆项目。 ``` - $ git clone https://github.com/neo-project/neo-node.git + $ git clone -b master-2.x https://github.com/neo-project/neo-node.git ``` 2. 下载对应版本的 [LevelDB](https://github.com/neo-ngd/leveldb/releases) 并解压备用。 diff --git a/docs/zh-cn/node/gui/blockchain.md b/docs/zh-cn/node/gui/blockchain.md index d00d7c62e..9a0d2cebe 100644 --- a/docs/zh-cn/node/gui/blockchain.md +++ b/docs/zh-cn/node/gui/blockchain.md @@ -4,7 +4,7 @@ ## 区块 -区块(Block)是区块链的最基本的单位,是一种逻辑结构。数据通过区块,永久记录在区块链网络上。关于区块的基本概念请参考 [区块 ](../../tooldev/concept/blockchain/block.md)。 +区块(Block)是区块链的最基本的单位,是一种逻辑结构。数据通过区块,永久记录在区块链网络上。关于区块的基本概念请参考 [区块 ](../../basic/concept/blockchain/block.md)。 ### 查看区块列表 @@ -45,7 +45,7 @@ - **交易体**:显示交易的基本信息,如所在区块、大小、时间戳等,以及交易的转账记录和交易的见证人。 - **交易日志**:显示交易中智能合约的执行日志,包括 NEP-5 转账是否成功等信息。 -关于交易的基本概念请参考 [交易](../../tooldev/transaction/transaction.md)。 +关于交易的基本概念请参考 [交易](../../basic/concept/transaction.md)。 ## 资产 diff --git a/docs/zh-cn/node/gui/contract.md b/docs/zh-cn/node/gui/contract.md index 0863da141..ade870cfe 100644 --- a/docs/zh-cn/node/gui/contract.md +++ b/docs/zh-cn/node/gui/contract.md @@ -41,7 +41,7 @@ 等待部署合约的交易成功上链以后,就可以通过合约哈希搜索以及调用合约。 -更多信息可参考 [智能合约部署](../../sc/deploy/deploy.md)。 +更多信息可参考 [智能合约部署](../../develop/deploy/deploy.md)。 ## 调用合约 @@ -81,4 +81,4 @@ 5. 试运行成功后,如果想在区块链上调用,点击 ` 调用 ` 按钮。 -关于调用合约和附加签名等更多信息可参考 [智能合约调用](../../sc/deploy/invoke.md)。 +关于调用合约和附加签名等更多信息可参考 [智能合约调用](../../develop/deploy/invoke.md)。 diff --git a/docs/zh-cn/node/gui/install.md b/docs/zh-cn/node/gui/install.md index 021ba1cf5..b2620d766 100644 --- a/docs/zh-cn/node/gui/install.md +++ b/docs/zh-cn/node/gui/install.md @@ -22,7 +22,7 @@ Neo-GUI 是一个开源项目,可在 [GitHub](https://github.com/neo-ngd/Neo3- 完成安装后,Neo-GUI默认连接到Neo3-Preview3测试网。 -你也可以将Neo-GUI连接到搭建好的私链(参见[搭建私链](../../network/private-chain/solo.md))。要连接到私链,请按照以下操作进行: +你也可以将Neo-GUI连接到搭建好的私链(参见[搭建私链](../../develop/network/private-chain/solo.md))。要连接到私链,请按照以下操作进行: 1. 复制私链对应的 `config.json` 和 `protocol.json` 文件 diff --git a/docs/zh-cn/node/syncblocks.md b/docs/zh-cn/node/syncblocks.md deleted file mode 100644 index b04a1cd8a..000000000 --- a/docs/zh-cn/node/syncblocks.md +++ /dev/null @@ -1,49 +0,0 @@ -# 快速同步区块数据 - -NEO 客户端必须先完成与区块链的同步才能正常使用。由于区块链数据庞大,客户端同步时间通常很久,建议采用离线同步包加速同步过程。 - -> [!Note] -> -> 进行区块离线同步前,请确认你的NEO 客户端已安装 [ImportBlocks](https://github.com/neo-project/neo-plugins/releases/download/v2.10.3/ImportBlocks.zip) 插件。详情请参考客户端的安装说明。 -> - -## 第一步 - 获取离线包 - -1. 关闭客户端,进入[离线包下载页面](https://sync.ngd.network/)。 - -2. 在离线包下载页面,根据你所在网络点击 **主网** 或 **测试网** 标签,然后选择以下一种离线包进行下载 (无需解压): - - - **全量离线包**:包含了最完整的区块高度数据,适用于初次运行的客户端。下载到的文件为 chain.acc.zip。 - - **增量离线包**:包含起始高度到结束高度范围内的数据,当你的客户端已经同步到增量包的起始高度之上时,可使用增量包继续进行同步。下载到的文件为 chain.x.acc.zip,x 为增量包的起始高度,如 chain.1855770.acc.zip。 - - ![](../assets/syncblocks_2.png) - -## 第二步 - 放置离线包 - -将下载的压缩包文件 chain.acc.zip 或 chain.xxx.acc.zip 直接放置到客户端 NEO-CLI 或 NEO-GUI 根目录下。下图以 NEO-CLI 为例。 - -> [!Caution] -> -> #### 警告 -> -> 切勿修改离线包文件名,否则会导致无法同步。 - -![](../assets/syncblocks_3.png) - -## 第三步 - 查看同步状态 - -再次打开客户端查看同步状态: - -- 对于 NEO-GUI,将发现客户端以超快速度进行同步。同步完成后,界面左下角三个数值相同且保持相近速度稳步增加。这三个数据依次代表:钱包高度/区块高度/区块头高度。 - -![](../node/assets/gui_1.png) - -- 对于 NEO-CLI,输入 `open wallet ` 打开 NEO 命令行钱包后,输入 `show state` 查看区块同步状态,当画面显示连接 node 数为 0 并且同步速度明显加快时, 说明已进入离线同步模式。当 "Height" 后面的三个数值相同表示同步完成。 - -![](../assets/cli_sync.png) - -> [!Note] -> -> - NEO-CLI 2.9.0 之前的版本在用离线包同步时,客户端无法与外界通信,此时 node 数为 0,且无法调用 API。当离线包使用完毕后,客户端才会恢复与外界的通信。 -> -> - 也可以使用 NEO-CLI 的 `export blocks` 命令,将同步好的区块数据导出成离线同步包。 `export blocks` 后面无参数时默认导出所有区块数据,当附加 ` [count]` 参数时,可以从指定区块高度导出指定数量的区块数据,方便备份以及在原有区块数据上追加同步。相关信息请参见 [CLI命令参考](cli/cli.md) 。 \ No newline at end of file diff --git a/docs/zh-cn/sc/fees.md b/docs/zh-cn/reference/fees.md similarity index 74% rename from docs/zh-cn/sc/fees.md rename to docs/zh-cn/reference/fees.md index 546dc8b0f..fa730fd68 100644 --- a/docs/zh-cn/sc/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)。 ### 指令费用 @@ -261,7 +311,7 @@ |REVERSE4|0.00000060| |REVERSEN|0.00000400| |INITSSLOT|0.00000400| -|INITSLOT|0.00000800| +|INITSLOT|0.00001600| |LDSFLD0\~LDSFLD6|0.00000060| |LDSFLD|0.00000060| |STSFLD0\~STSFLD6|0.0000006| @@ -284,8 +334,8 @@ |AND|0.00000200| |OR|0.00000200| |XOR|0.00000200| -|EQUAL|0.00000200| -|NOTEQUAL|0.00000200| +|EQUAL|0.00001000| +|NOTEQUAL|0.00001000| |SIGN|0.00000100| |ABS|0.00000100| |NEGATE|0.00000100| @@ -311,8 +361,8 @@ |MIN|0.00000200| |MAX|0.00000200| |WITHIN|0.00000200| -|PACK|0.00007000| -|UNPACK|0.00007000| +|PACK|0.00015000| +|UNPACK|0.00015000| |NEWARRAY0|0.00000400| |NEWARRAY|0.00015000| |NEWARRAY_T|0.00015000| @@ -322,11 +372,11 @@ |SIZE|0.00000150| |HASKEY|0.00270000| |KEYS|0.00000500| -|VALUES|0.00007000| +|VALUES|0.00270000| |PICKITEM|0.00270000| -|APPEND|0.00015000| +|APPEND|0.00270000| |SETITEM|0.00270000| -|REVERSEITEMS|0.00000500| +|REVERSEITEMS|0.00270000| |REMOVE|0.00000500| |CLEARITEMS|0.00000400| |ISNULL|0.00000060| 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/rpc/latest-version/api.md b/docs/zh-cn/reference/rpc/latest-version/api.md index d538bb1b2..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,7 @@ 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) | | 获取委员会成员公钥列表 | ### 节点 @@ -66,6 +66,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..669b66c6d --- /dev/null +++ b/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md @@ -0,0 +1,37 @@ +# calculatenetworkfee 方法 + +计算指定交易的网络费GAS。 + +> [!Note] +> +> - 此方法由插件提供,需要安装 [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/getapplicationlog.md b/docs/zh-cn/reference/rpc/latest-version/api/getapplicationlog.md index a3060c5a8..9061304c1 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/getapplicationlog.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/getapplicationlog.md @@ -8,54 +8,195 @@ ## 参数说明 -txid:交易ID +- txid/blockhash:交易 ID 或区块 hash + +- trigger type: 可选参数, 有以下 trigger 类型: + + - OnPersist + - PostPersist + - Application + - Verification + - System: OnPersist | PostPersist + - All: OnPersist | PostPersist | Verification | Application + + 默认获取所有类型,也可以指定某种类型。 ## 调用示例 -请求正文: +请求正文 1: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "getapplicationlog", + "params": [ + "0xd6ea48f1c33defc1815562b3ace4ead99bf33a8ae67b2642cf73c2f192a717e5" + ] +} +``` + +响应正文 1: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "txid": "0xd6ea48f1c33defc1815562b3ace4ead99bf33a8ae67b2642cf73c2f192a717e5", + "executions": [ + { + "trigger": "Application", + "vmstate": "HALT", + "gasconsumed": "9007990", + "stack": [], + "notifications": [ + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "Any" + }, + { + "type": "ByteString", + "value": "9S37k0BBDIaRxjEhW0Sk+9lDN4s=" + }, + { + "type": "Integer", + "value": "400000000" + } + ] + } + }, + { + "contract": "0xde5f57d430d3dece511cf975a8d37848cb9e0525", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "ByteString", + "value": "9S37k0BBDIaRxjEhW0Sk+9lDN4s=" + }, + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Integer", + "value": "1" + } + ] + } + } + ] + } + ] + } +} +``` + +请求正文 2: ```json { "jsonrpc": "2.0", + "id": 1, "method": "getapplicationlog", - "params": ["0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295"], - "id": 1 -} + "params": [ + "0x0745a04ddb7803ebd549af4d80de03fc69349b0b77615a06d9ef052637de5931", "System" + ] +} + ``` -响应正文: +响应正文 2: ```json { "jsonrpc": "2.0", - "id": "1", + "id": 1, "result": { - "txid": "0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", - "trigger": "Application", - "vmstate": "HALT", - "gasconsumed": "9007990", - "stack": [], - "notifications": [ + "blockhash": "0x0745a04ddb7803ebd549af4d80de03fc69349b0b77615a06d9ef052637de5931", + "executions": [ + { + "trigger": "System", + "vmstate": "HALT", + "gasconsumed": "2031260", + "stack": [], + "notifications": [ + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Any" + }, + { + "type": "Integer", + "value": "11384830" + } + ] + } + }, + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "Any" + }, + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Integer", + "value": "2376840" + } + ] + } + } + ] + }, { - "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", - "eventname": "Transfer", - "state": { - "type": "Array", - "value": [ - { - "type": "ByteString", - "value": "+pU2/Hks6bMS9XhEc3F6o2fineE=" - }, - { - "type": "ByteString", - "value": "GM4RybFKiRJSR0M8IDpNgA/1ILE=" - }, - { - "type": "Integer", - "value": "1223300000000" + "trigger": "System", + "vmstate": "HALT", + "gasconsumed": "2031260", + "stack": [], + "notifications": [ + { + "contract": "0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc", + "eventname": "Transfer", + "state": { + "type": "Array", + "value": [ + { + "type": "Any" + }, + { + "type": "ByteString", + "value": "1rSxahaE1EDW2TzNNlNk0rjQEpI=" + }, + { + "type": "Integer", + "value": "25000000" + } + ] } - ] - } + } + ] } ] } diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getblock.md b/docs/zh-cn/reference/rpc/latest-version/api/getblock.md index e87ec896d..074ff9237 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/getblock.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/getblock.md @@ -23,7 +23,7 @@ { "jsonrpc": "2.0", "method": "getblock", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4"], + "params": ["0xdf9c92cdb8d503214d0bf6c231ccbfa25c20ce24fc4d03a966760e4423889710", 0], "id": 1 } ``` @@ -34,7 +34,7 @@ { "jsonrpc": "2.0", "id": 1, - "result": "0000000059ff9a2ff0861bda1abf89e07a3d248def4cf4fd4493c23d32bcf9bc741b92867ac9948cd23059eb880182e443b5eb3c75ec68404d01ff7b3c8f85a6651a6aefdc0687a06f0100001027000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c4026a4ba2eba339629ce40817053625dc315c294cea30863bb56d15a7fb2f3445d615fa0d201b940e3df662c71b200e355b8193e746b36143dcb9de3669962fc852b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb0100f86bb4ae521c7046" + "result": "AAAAAFjOB3LXvZFhG/DF9PnA4Zh/buBfAFhvwG6JAzP4EAht5itJ14qK/tiaUxujBBTdZAYFAKnwJroJd8AQAp+vHgzyjenQdQEAANAHAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEBxGiRWC9d/xNWdbZ1uM9Z/yBVoPLKG6WTQ22aMOgk/AwQMTFdgoZEoSkvyA0791Y1AV146AJEu2R/jFOZZyj37KxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768BAGgp5HJL+bHp" } ``` @@ -46,7 +46,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getblock", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", 1], + "params": ["0xdf9c92cdb8d503214d0bf6c231ccbfa25c20ce24fc4d03a966760e4423889710", 1], "id": 1 } ``` @@ -58,27 +58,27 @@ verbose = 1,返回 JSON 格式的结果。 "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", + "hash": "0xdf9c92cdb8d503214d0bf6c231ccbfa25c20ce24fc4d03a966760e4423889710", "size": 222, "version": 0, - "previousblockhash": "0x86921b74bcf9bc323dc29344fdf44cef8d243d7ae089bf1ada1b86f02f9aff59", - "merkleroot": "0xef6a1a65a6858f3c7bff014d4068ec753cebb543e4820188eb5930d28c94c97a", - "time": 1578946201308, - "index": 10000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x6d0810f83303896ec06f58005fe06e7f98e1c0f9f4c5f01b6191bdd77207ce58", + "merkleroot": "0x0c1eaf9f0210c07709ba26f0a900050664dd1404a31b539ad8fe8a8ad7492be6", + "time": 1605527768562, + "index": 2000, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAmpLouujOWKc5AgXBTYl3DFcKUzqMIY7tW0Vp/svNEXWFfoNIBuUDj32YscbIA41W4GT50azYUPcud42aZYvyF", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEBxGiRWC9d/xNWdbZ1uM9Z/yBVoPLKG6WTQ22aMOgk/AwQMTFdgoZEoSkvyA0791Y1AV146AJEu2R/jFOZZyj37", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], "consensusdata": { "primary": 0, - "nonce": "46701c52aeb46bf8" + "nonce": "e9b1f94b72e42968" }, "tx": [], - "confirmations": 129368, - "nextblockhash": "0xe5ee6885a736e194c14bb020dca34bd6effe4280fbaec4542e41e4bebd8d4870" + "confirmations": 5313, + "nextblockhash": "0x09638b66b8254485b594e7849dc279675e7631a06cdff857bee6991c1daa8105" } } ``` @@ -91,7 +91,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getblock", - "params": [10000], + "params": [7368], "id": 1 } ``` @@ -102,7 +102,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "id": 1, - "result": "0000000059ff9a2ff0861bda1abf89e07a3d248def4cf4fd4493c23d32bcf9bc741b92867ac9948cd23059eb880182e443b5eb3c75ec68404d01ff7b3c8f85a6651a6aefdc0687a06f0100001027000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c4026a4ba2eba339629ce40817053625dc315c294cea30863bb56d15a7fb2f3445d615fa0d201b940e3df662c71b200e355b8193e746b36143dcb9de3669962fc852b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb0100f86bb4ae521c7046" + "result": "AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768CAGUTt7+NSxXGAA7aoUS2kokAAAAAACYcEwAAAAAARzMAAAHNWK7P0zW+HrPTEeHcgAlj39ctnwEAXQMA5AtUAgAAAAwUzViuz9M1vh6z0xHh3IAJY9/XLZ8MFM1Yrs/TNb4es9MR4dyACWPf1y2fE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAFCDEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+KQwhAv3yei642bBp1hrlpk26E7iWN8VC2MdMXWurST/mONaPC0GVRA14" } ``` @@ -114,7 +114,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getblock", - "params": [10000, 1], + "params": [7368,1], "id": 1 } ``` @@ -126,27 +126,52 @@ verbose = 1,返回 JSON 格式的结果。 "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", - "size": 222, + "hash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", + "size": 474, "version": 0, - "previousblockhash": "0x86921b74bcf9bc323dc29344fdf44cef8d243d7ae089bf1ada1b86f02f9aff59", - "merkleroot": "0xef6a1a65a6858f3c7bff014d4068ec753cebb543e4820188eb5930d28c94c97a", - "time": 1578946201308, - "index": 10000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x7b895d302b435fb452e94f7938df416129da62caa0abbbb77a69a4c656281223", + "merkleroot": "0xc30fa2a389b4f9d86ec4e952c1fb010014b1aca0f17722f85c5b288d390b0aeb", + "time": 1605687708300, + "index": 7368, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAmpLouujOWKc5AgXBTYl3DFcKUzqMIY7tW0Vp/svNEXWFfoNIBuUDj32YscbIA41W4GT50azYUPcud42aZYvyF", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wC", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], "consensusdata": { "primary": 0, - "nonce": "46701c52aeb46bf8" + "nonce": "c6154b8dbfb71365" }, - "tx": [], - "confirmations": 129343, - "nextblockhash": "0xe5ee6885a736e194c14bb020dca34bd6effe4280fbaec4542e41e4bebd8d4870" + "tx": [ + { + "hash": "0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a", + "size": 252, + "version": 0, + "nonce": 1151457806, + "sender": "NedjwsfAJYFas9rn8UHWQftTW4oKAQyW9h", + "sysfee": "9015990", + "netfee": "1252390", + "validuntilblock": 13127, + "signers": [ + { + "account": "0x9f2dd7df630980dce111d3b31ebe35d3cfae58cd", + "scopes": "CalledByEntry" + } + ], + "attributes": [], + "script": "AwDkC1QCAAAADBTNWK7P0zW+HrPTEeHcgAlj39ctnwwUzViuz9M1vh6z0xHh3IAJY9/XLZ8TwAwIdHJhbnNmZXIMFLyvQdaEx9StbuDZnalwe50fDI5mQWJ9W1I4", + "witnesses": [ + { + "invocation": "DEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+", + "verification": "DCEC/fJ6LrjZsGnWGuWmTboTuJY3xULYx0xda6tJP+Y41o8LQZVEDXg=" + } + ] + } + ], + "confirmations": 2, + "nextblockhash": "0x1545a328149baf8037873793d7e45d27385221dd69ddb606ee55434eb173a3ff" } } ``` diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getblockheader.md b/docs/zh-cn/reference/rpc/latest-version/api/getblockheader.md index 1d8ed5633..ba51eaf1a 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/getblockheader.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/getblockheader.md @@ -23,7 +23,7 @@ { "jsonrpc": "2.0", "method": "getblockheader", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", 0], + "params": ["0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", 0], "id": 1 } ``` @@ -34,7 +34,7 @@ { "jsonrpc": "2.0", "id": 1, - "result": "0000000059ff9a2ff0861bda1abf89e07a3d248def4cf4fd4493c23d32bcf9bc741b92867ac9948cd23059eb880182e443b5eb3c75ec68404d01ff7b3c8f85a6651a6aefdc0687a06f0100001027000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c4026a4ba2eba339629ce40817053625dc315c294cea30863bb56d15a7fb2f3445d615fa0d201b940e3df662c71b200e355b8193e746b36143dcb9de3669962fc852b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb00" + "result": "AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768A" } ``` @@ -46,7 +46,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getblockheader", - "params": ["0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4",1], + "params": ["0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b",1], "id": 1 } ``` @@ -58,22 +58,22 @@ verbose = 1,返回 JSON 格式的结果。 "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xdf17b40c5627a45e83d61b286a6d6d14859136621760d0a5b58dd59d18fd53d4", + "hash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", "size": 213, "version": 0, - "previousblockhash": "0x86921b74bcf9bc323dc29344fdf44cef8d243d7ae089bf1ada1b86f02f9aff59", - "merkleroot": "0xef6a1a65a6858f3c7bff014d4068ec753cebb543e4820188eb5930d28c94c97a", - "time": 1578946201308, - "index": 10000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x7b895d302b435fb452e94f7938df416129da62caa0abbbb77a69a4c656281223", + "merkleroot": "0xc30fa2a389b4f9d86ec4e952c1fb010014b1aca0f17722f85c5b288d390b0aeb", + "time": 1605687708300, + "index": 7368, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAmpLouujOWKc5AgXBTYl3DFcKUzqMIY7tW0Vp/svNEXWFfoNIBuUDj32YscbIA41W4GT50azYUPcud42aZYvyF", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wC", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], - "confirmations": 91937, - "nextblockhash": "0xe5ee6885a736e194c14bb020dca34bd6effe4280fbaec4542e41e4bebd8d4870" + "confirmations": 12, + "nextblockhash": "0x1545a328149baf8037873793d7e45d27385221dd69ddb606ee55434eb173a3ff" } } ``` @@ -86,7 +86,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getblockheader", - "params": [6000, 0], + "params": [7368], "id": 1 } ``` @@ -97,7 +97,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "id": 1, - "result": "0000000020c213cb72392bd365e1e7e4ff9958e83761cd104d49dab0dd05903f7b651fec9939608fd01705162af2b399b57cf21dd2750c52cae18b5848f85f0ca7694983e014539f6f0100007017000057c8f7a5b8d6758f18fb906eaf03f007da0a9f2601420c400eb0087228a71228edf83e635ad0bbcd30a8e0ba04207d26657dbce334e8ea1fa7b6684a393bc6d1e054df39927e9bdf3d89e3cd9cf760a5f8639ae5b27ecc822b110c21021e1563aa32a5191ff7198e8c28ef02a8c6b33aecf326f5b32c6a620138d4201b110b413073b3bb00" + "result": "AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768A" } ``` @@ -109,7 +109,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getblockheader", - "params": [6000, 1], + "params": [7368, 1], "id": 1 } ``` @@ -121,22 +121,22 @@ verbose = 1,返回 JSON 格式的结果。 "jsonrpc": "2.0", "id": 1, "result": { - "hash": "0xf929babb2b10eed2e3af429c73648ef6d3c05d247494eb95dcdae53a77236ddf", + "hash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", "size": 213, "version": 0, - "previousblockhash": "0xec1f657b3f9005ddb0da494d10cd6137e85899ffe4e7e165d32b3972cb13c220", - "merkleroot": "0x834969a70c5ff848588be1ca520c75d21df27cb599b3f22a160517d08f603999", - "time": 1578926019808, - "index": 6000, - "nextconsensus": "NTv8iuL3yf4eiskKWWrtXLq9fKrX6LNGrG", + "previousblockhash": "0x7b895d302b435fb452e94f7938df416129da62caa0abbbb77a69a4c656281223", + "merkleroot": "0xc30fa2a389b4f9d86ec4e952c1fb010014b1aca0f17722f85c5b288d390b0aeb", + "time": 1605687708300, + "index": 7368, + "nextconsensus": "NikxdvEetzBKLHAddYJ7BHZT9USwm8qGFP", "witnesses": [ { - "invocation": "DEAOsAhyKKcSKO34PmNa0LvNMKjgugQgfSZlfbzjNOjqH6e2aEo5O8bR4FTfOZJ+m989iePNnPdgpfhjmuWyfsyC", - "verification": "EQwhAh4VY6oypRkf9xmOjCjvAqjGszrs8yb1syxqYgE41CAbEQtBMHOzuw==" + "invocation": "DEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wC", + "verification": "EQwhAvgv/9feMOkjIwvN7Sw81b7IVy5+usvdufM6Kl0mk0uLEQtBE43vrw==" } ], - "confirmations": 150220, - "nextblockhash": "0x17f3f1d81f2f442053a0bf8ca9a6addeb25646267127bb3b43884f61ed9a2822" + "confirmations": 16, + "nextblockhash": "0x1545a328149baf8037873793d7e45d27385221dd69ddb606ee55434eb173a3ff" } } ``` 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 diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getcontractstate.md b/docs/zh-cn/reference/rpc/latest-version/api/getcontractstate.md index aae5ca926..735dd9042 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/getcontractstate.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/getcontractstate.md @@ -17,7 +17,7 @@ script_hash:合约脚本散列。 { "jsonrpc": "2.0", "method": "getcontractstate", - "params": ["0x27c229e71e2e7b4aa8062f695586e4243ae60a49"], + "params": ["0x99042d380f2b754175717bb932a911bc0bb0ad7d"], "id": 1 } ``` @@ -27,145 +27,84 @@ script_hash:合约脚本散列。 ```json { "jsonrpc": "2.0", - "id": "1", + "id": 1, "result": { - "id": 4, - "hash": "0x27c229e71e2e7b4aa8062f695586e4243ae60a49", - "script": "VwUADBQcA1dGS3d+z2tfOsOJOs4fixYh9kH4J+yMELNyaiYJEHMj2gAAACFBm/ZnzgwCAgJQNToGAABwaAwLdG90YWxTdXBwbHlQNTcGAADYqnRsJh4MGUNvbnRyYWN0IGFscmVhZHkgZGVwbG95ZWQ6IUGb9mfODAIBAVA18wUAAHFpDBQcA1dGS3d+z2tfOsOJOs4fixYh9gwHAACNSf0aB9shUzX0BQAAaAwLdG90YWxTdXBwbHkMBwAAjUn9GgfbIVM16gUAAAsMFBwDV0ZLd37Pa186w4k6zh+LFiH2DAcAAI1J/RoH2yFTE8AMCFRyYW5zZmVyQZUBb2ERc2tAVwMCDBQcA1dGS3d+z2tfOsOJOs4fixYh9kH4J+yMELNwaCYGEHEiH3jKJgh5yhCzIgMRcmomBhBxIgx4eVBBMcYzHRFxaUBXAgAMFBwDV0ZLd37Pa186w4k6zh+LFiH2Qfgn7IwQs3BoJgYQcSIKIUHGnx3wEXFpQFcHAXhwaMoUsxCzcmomBhBzIj1oEM4MCFRyYW5zZmVyl6p0bCYGEHMiJmgSzkHb/qh0sxCzdW0mBhBzIhNoE85xaRC1dm4mBhBzIgRpc2tAVxYAQYQnEUMRsxCzdwtvCyYODAl1c2VyZXJyb3I6C0EnQzXxcGjKELN3DG8MJicMIkNvbnRyaWJ1dGlvbiB0cmFuc2FjdGlvbiBub3QgZm91bmQ6EHEQchB3DSJsIWhvDc53Dm8OEM4MFIl3INjNdvTwCr+jfA7diJwgj96bs3cPbw8mEGlvDhLONSb///+ecSIvbw4QzgwUO303EcbwzPmx3KkD0b+h2JbxI4yzdxBvECYOam8OEs419/7//55yIW8NEZ53DW8NaMq1dxFvESSNQZv2Z84MAgICUDXJAwAAc2sMC3RvdGFsU3VwcGx5UDXGAwAAdGzYdxJvEiYaDBVDb250cmFjdCBub3QgZGVwbG95ZWQ6bErYJgUQUEXbIXUMBwAAwW/yhiPbIW2fdmkMBADKmjvbIaBqEaCedwdvBxC2dxNvEyYODAl1c2VyZXJyb3I6bwdut3cUbxQmDgwJdXNlcmVycm9yOiFBm/ZnzgwCAQFQNS4DAAB3CEEtUQgwdwlvCG8JE85QNW8DAABKJAZFECIE2yF3Cm8IbwkTzm8KbweeUzUnAwAAawwLdG90YWxTdXBwbHltbweeUzUkAwAAC28JE85vCm8HnlMTwAwIVHJhbnNmZXJBlQFvYRF3FW8VQFcBAAwUHANXRkt3fs9rXzrDiTrOH4sWIfZB+CfsjHBoQFcBAAwKVG9rZW4gTmFtZXBoQFcBAAwLVG9rZW5TeW1ib2xwaEBXAQAYcGhAVwEAEsNKEAwFTkVQLTXQShEMBk5FUC0xMNBwaEBXAwF4ygwBFNshsxCzcGgmBhBxIhh4StgmBRBQRdshELNyaiYGEHEiBBFxaUBXAgF4QanFS0FwaCYHaBPOIgMRcWlAVwIAQZv2Z84MAgICUDUEAgAAcGgMC3RvdGFsU3VwcGx5UDUBAgAASiQGRRAiBNshcWlAVwMBeDSGELNxaSY5DDRUaGUgcGFyYW1ldGVyICdhY2NvdW50JyBTSE9VTEQgYmUgMjAtYnl0ZSBhZGRyZXNzZXMuOiFBm/ZnzgwCAQFQNZABAABwaHhQNd0BAABKJAZFECIE2yFyakBXDAN4NR7///8Qs3NrJjYMMVRoZSBwYXJhbWV0ZXIgJ2Zyb20nIFNIT1VMRCBiZSAyMC1ieXRlIGFkZHJlc3Nlcy46eTXe/v//ELN0bCY1DDBUaGUgcGFyYW1ldGVycyAndG8nIFNIT1VMRCBiZSAyMC1ieXRlIGFkZHJlc3Nlcy46eTXM/v//ELN1bSYJEHYj5AAAAHoQtncHbwcmMQwsVGhlIHBhcmFtZXRlciBhbW91bnQgTVVTVCBiZSBncmVhdGVyIHRoYW4gMC46eEH4J+yMELN3CG8IJgkQdiOXAAAAIUGb9mfODAIBAVA1iQAAAHBoeFA11gAAAErYJgUQUEXbIXFperV3CW8JJgYQdiJkehCzJAd4ebMiAxF3Cm8KJgYRdiJPaXqzdwtvCyYMaHhQNa8AAAAiCyFoeGl6n1M0X2h5UDWGAAAASiQGRRAiBNshcmh5anqeUzRFeHl6UxPADAhUcmFuc2ZlckGVAW9hEXZuQFcBAhLDSngQUNBKeRFQ0HBoQFcCAngRznnbMItweBDOaFBBkl3oMXFpQFcBA3gRznmLcHgQzmh6U0HmPxiEQFcBA3gRznnbMItweBDOaHpTQeY/GIRAVwICeBHOeYtweBDOaFBBkl3oMXFpQFcBAngRznmLcHgQzmhQQS9Yxe1AVgkMBwAAwW/yhiPbIWAMBwAAjUn9GgfbIWEMFBwDV0ZLd37Pa186w4k6zh+LFiH2YgwEAMqaO9shYxFkDBSJdyDYzXb08Aq/o3wO3YicII/em2UMFDt9NxHG8Mz5sdypA9G/odiW8SOMZgwCAQFnBwwCAgJnCEA=", + "id": 8, + "hash": "0x99042d380f2b754175717bb932a911bc0bb0ad7d", + "script": "DBQKo4e1Ppa3mJpjFDGgVt0fQKBC9kH4J+yMQDTkQFcBAAwFSGVsbG9Bm/ZnzkGSXegxcGhAVwQBEnAMF0ludm9rZSBTdHJvYWdlLlB1dCBmb3IgaBpQQXvjun0MByB0aW1lcy6Li9soQc/nR5YMBUhlbGxveFBBm/ZnzkHmPxiEDAJOb0Gb9mfOQZJd6DHYqnNrJiwMAk5vDAJOb0Gb9mfOQZJd6DFK2CYFEFBF2yERnlBBm/ZnzkHmPxiEIhMhDAJObxFQQZv2Z85B5j8YhAwCTm9Bm/ZnzkGSXegxcWlK2CYFEFBF2yEaUEF747p9chXDShAMBFB1dCDQShF40EoSDB0gaW50byBzdG9yYWdlIGNvbXBsZXRlbHkgZm9yINBKE2rQShQMBiB0aW1lc9DBShEyCJ1Ti1Ai+EXbKEHP50eWeBHADARXb3JkQZUBb2FpEcAMDkludm9rZVB1dENvdW50QZUBb2FAVwECNZL+//8Qs3BoJhYMEU5vIGF1dGhvcml6YXRpb24uOnh5UEExxjMdQFcBADVn/v//ELNwaCYWDBFObyBhdXRob3JpemF0aW9uLjohQcafHfBAVgEMFAqjh7U+lreYmmMUMaBW3R9AoEL2YEA=", "manifest": { "groups": [], - "features": { - "storage": true, - "payable": true - }, - "supportedstandards": [ - "NEP-5", - "NEP-10" - ], + "supportedstandards": [], "abi": { - "hash": "0x27c229e71e2e7b4aa8062f695586e4243ae60a49", + "hash": "0x99042d380f2b754175717bb932a911bc0bb0ad7d", "methods": [ - { - "name": "deploy", - "parameters": [], - "offset": 0, - "returntype": "Boolean" - }, - { - "name": "migrate", - "parameters": [ - { - "name": "script", - "type": "ByteArray" - }, - { - "name": "manifest", - "type": "String" - } - ], - "offset": 258, - "returntype": "Boolean" - }, - { - "name": "destroy", - "parameters": [], - "offset": 329, - "returntype": "Boolean" - }, - { - "name": "mint", - "parameters": [], - "offset": 459, - "returntype": "Boolean" - }, { "name": "verify", "parameters": [], - "offset": 946, + "offset": 28, "returntype": "Boolean" }, { - "name": "name", - "parameters": [], - "offset": 979, - "returntype": "String" - }, - { - "name": "symbol", - "parameters": [], - "offset": 997, - "returntype": "String" - }, - { - "name": "decimals", + "name": "myMethod", "parameters": [], - "offset": 1016, - "returntype": "Integer" + "offset": 31, + "returntype": "ByteArray" }, { - "name": "supportedStandards", - "parameters": [], - "offset": 1023, - "returntype": "Array" - }, - { - "name": "totalSupply", - "parameters": [], - "offset": 1119, - "returntype": "Integer" - }, - { - "name": "balanceOf", + "name": "put", "parameters": [ { - "name": "account", - "type": "ByteArray" + "name": "word", + "type": "String" } ], - "offset": 1170, - "returntype": "Integer" + "offset": 54, + "returntype": "Void" }, { - "name": "transfer", + "name": "update", "parameters": [ { - "name": "from", - "type": "ByteArray" - }, - { - "name": "to", + "name": "script", "type": "ByteArray" }, { - "name": "amount", - "type": "Integer" + "name": "manifest", + "type": "String" } ], - "offset": 1274, - "returntype": "Boolean" + "offset": 363, + "returntype": "Void" + }, + { + "name": "destroy", + "parameters": [], + "offset": 406, + "returntype": "Void" }, { "name": "_initialize", "parameters": [], - "offset": 1776, + "offset": 447, "returntype": "Void" } ], "events": [ { - "name": "Transfer", + "name": "Word", "parameters": [ { - "name": "arg1", - "type": "ByteArray" - }, + "name": "obj", + "type": "String" + } + ] + }, + { + "name": "InvokePutCount", + "parameters": [ { - "name": "arg2", + "name": "obj", "type": "ByteArray" - }, - { - "name": "arg3", - "type": "Integer" } ] } @@ -181,8 +120,9 @@ script_hash:合约脚本散列。 "safemethods": [], "extra": { "Author": "Neo", + "Name": "Sample", "Email": "dev@neo.org", - "Description": "This is a NEP5 example" + "Description": "This is a contract example" } } } diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getrawtransaction.md b/docs/zh-cn/reference/rpc/latest-version/api/getrawtransaction.md index 77cb34228..366e2ea3b 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/getrawtransaction.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/getrawtransaction.md @@ -21,7 +21,7 @@ { "jsonrpc": "2.0", "method": "getrawtransaction", - "params": ["0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", 0], + "params": ["0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a"], "id": 1 } ``` @@ -32,7 +32,7 @@ { "jsonrpc": "2.0", "id": 1, - "result": "0001fea4517673890000000000c863240000000000d4192000028a45f89ca928a5381de89efff2b93f7d66eea2a800fa9536fc792ce9b312f5784473717aa367e29de101005d0300a95cd21c0100000c1418ce11c9b14a89125247433c203a4d800ff520b10c14fa9536fc792ce9b312f5784473717aa367e29de113c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b523802420c40c8bbb4e871a321544cf6c42c5b5d18cb7eafcfa8d0fcde2c054469ae0dbd8b566dc7ced0b65a4d598c9a7ce8cbebeda04260a3248fc6d9a634b30136d2042bd5290c2102a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b0b4195440d78420c40f3120275f82c19813671c7f19c9d030094ad57dece03d6246c8199df98f8b53e37fa2642cd5241b87331b450a2f25e2e1d8a4187c48bb752304c71a30e6001c12b110c2102a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b110b41138defaf" + "result": "AA7aoUS2kokAAAAAACYcEwAAAAAARzMAAAHNWK7P0zW+HrPTEeHcgAlj39ctnwEAXQMA5AtUAgAAAAwUzViuz9M1vh6z0xHh3IAJY9/XLZ8MFM1Yrs/TNb4es9MR4dyACWPf1y2fE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAFCDEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+KQwhAv3yei642bBp1hrlpk26E7iWN8VC2MdMXWurST/mONaPC0GVRA14" } ``` @@ -44,7 +44,7 @@ verbose = 1,返回 JSON 格式的结果。 { "jsonrpc": "2.0", "method": "getrawtransaction", - "params": ["0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", 1], + "params": ["0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a", 1], "id": 1 } ``` @@ -54,41 +54,33 @@ verbose = 1,返回 JSON 格式的结果。 ```json { "jsonrpc": "2.0", - "id": "1", + "id": 1, "result": { - "hash": "0x5af8769d0a209e55c8d27dab8be6c8c6288e2083b02f11043d9586377cd30295", - "size": 384, + "hash": "0xdcdac54af951034bccc5079e8619f9ce9803a5e2fb90e351571657a62e38b28a", + "size": 252, "version": 0, - "nonce": 1369767425, - "sender": "NYX6FuequzNvtajBpKtHkiy6ggKFTmtDjv", - "sysfee": "9007990", - "netfee": "2384840", - "validuntilblock": 2103764, + "nonce": 1151457806, + "sender": "NedjwsfAJYFas9rn8UHWQftTW4oKAQyW9h", + "sysfee": "9015990", + "netfee": "1252390", + "validuntilblock": 13127, "signers": [ { - "account": "0xa8a2ee667d3fb9f2ff9ee81d38a528a99cf8458a", - "scopes": "FeeOnly" - }, - { - "account": "0xe19de267a37a71734478f512b3e92c79fc3695fa", + "account": "0x9f2dd7df630980dce111d3b31ebe35d3cfae58cd", "scopes": "CalledByEntry" } ], "attributes": [], - "script": "AwCpXNIcAQAADBQYzhHJsUqJElJHQzwgOk2AD/UgsQwU+pU2/Hks6bMS9XhEc3F6o2fineETwAwIdHJhbnNmZXIMFLyvQdaEx9StbuDZnalwe50fDI5mQWJ9W1I4", + "script": "AwDkC1QCAAAADBTNWK7P0zW+HrPTEeHcgAlj39ctnwwUzViuz9M1vh6z0xHh3IAJY9/XLZ8TwAwIdHJhbnNmZXIMFLyvQdaEx9StbuDZnalwe50fDI5mQWJ9W1I4", "witnesses": [ { - "invocation": "DEDIu7TocaMhVEz2xCxbXRjLfq/PqND83iwFRGmuDb2LVm3HztC2Wk1ZjJp86Mvr7aBCYKMkj8bZpjSzATbSBCvV", - "verification": "DCECqepoQswMs7DyMXsHyFDePR4rJDqY7S1Wo/9MpmqvMwsLQZVEDXg=" - }, - { - "invocation": "DEDzEgJ1+CwZgTZxx/GcnQMAlK1X3s4D1iRsgZnfmPi1Pjf6JkLNUkG4czG0UKLyXi4dikGHxIu3UjBMcaMOYAHB", - "verification": "EQwhAqnqaELMDLOw8jF7B8hQ3j0eKyQ6mO0tVqP/TKZqrzMLEQtBE43vrw==" + "invocation": "DEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+", + "verification": "DCEC/fJ6LrjZsGnWGuWmTboTuJY3xULYx0xda6tJP+Y41o8LQZVEDXg=" } ], - "blockhash": "0xecb6531e97a837db58f676ffc0b3038e638a483a5bd5729356cca48b9bd2748a", - "confirmations": 98, - "blocktime": 1595556303116, + "blockhash": "0x5f0b81b921eebf719f97e98e8c56e260db8720138b4a7def766b1498a3f4296b", + "confirmations": 44, + "blocktime": 1605687708300, "vmstate": "HALT" } } diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getstorage.md b/docs/zh-cn/reference/rpc/latest-version/api/getstorage.md index 07ca33b7d..7e56a6cb2 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/getstorage.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/getstorage.md @@ -7,7 +7,7 @@ ## 参数说明 -script_hash: 合约脚本散列。 +script_hash/id: 合约脚本散列或合约id。 key: 存储区的键(需要转化为hex string)。 @@ -17,10 +17,10 @@ key: 存储区的键(需要转化为hex string)。 ```json { - "jsonrpc": "2.0", - "method": "getstorage", - "params": ["03febccf81ac85e3d795bc5cbd4e84e907812aa3", "5065746572"], - "id": 15 + "jsonrpc": "2.0", + "method": "getstorage", + "params": ["0x99042d380f2b754175717bb932a911bc0bb0ad7d", "48656c6c6f"], + "id": 1 } ``` @@ -28,9 +28,9 @@ key: 存储区的键(需要转化为hex string)。 ```json { - "jsonrpc": "2.0", - "id": 15, - "result": "4c696e" + "jsonrpc": "2.0", + "id": 1, + "result": "776f726c64" } ``` diff --git a/docs/zh-cn/reference/rpc/latest-version/api/getvalidators.md b/docs/zh-cn/reference/rpc/latest-version/api/getvalidators.md deleted file mode 100644 index de632c8cd..000000000 --- a/docs/zh-cn/reference/rpc/latest-version/api/getvalidators.md +++ /dev/null @@ -1,79 +0,0 @@ -# getvalidators 方法 - -获取当前 NEO 共识节点的信息及投票情况。 -> [!Note] -> -> 此方法由插件提供,需要安装 [RpcServer](https://github.com/neo-project/neo-modules/releases) 插件才可以调用。 - -## 调用示例 - -请求正文: - -```json -{ - "jsonrpc": "2.0", - "method": "getvalidators", - "params": [], - "id": 1 -} -``` - -响应正文: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "result": [ - { - "publickey": "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70", - "votes": "46632420", - "active": true - }, - { - "publickey": "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d", - "votes": "46632420", - "active": true - }, - { - "publickey": "025bdf3f181f53e9696227843950deb72dcd374ded17c057159513c3d0abe20b64", - "votes": "0", - "active": false - }, - { - "publickey": "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e", - "votes": "46632420", - "active": true - }, - { - "publickey": "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554", - "votes": "46632420", - "active": true - }, - { - "publickey": "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", - "votes": "46632420", - "active": true - }, - { - "publickey": "032f7b887a43774c51927e44d4c471655cdf6257ad92e38c1cf50c67e1a10281b4", - "votes": "0", - "active": false - }, - { - "publickey": "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", - "votes": "46632420", - "active": true - }, - { - "publickey": "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", - "votes": "46632420", - "active": true - } - ] -} -``` - -- publickey: 候选人公钥 -- votes: 候选人所得票数 -- active: true 表示该候选人已经成为共识节点,反之,false 表示该候选人未成为共识节点。 \ No newline at end of file diff --git a/docs/zh-cn/reference/rpc/latest-version/api/invokefunction.md b/docs/zh-cn/reference/rpc/latest-version/api/invokefunction.md index 62a6ee86b..0f8f3a626 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/invokefunction.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/invokefunction.md @@ -15,8 +15,6 @@ - params:传递给智能合约操作的参数,可选。 -- sender:交易发送者,支付交易费的账户,默认是 singers 中第一个账户,可选。 - - signers: 签名账户列表,可选。 * account: 签名账户 * scopes: 签名的作用域,允许的值: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global @@ -70,7 +68,6 @@ "value":"8" } ], - "0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146", [ { "account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c", diff --git a/docs/zh-cn/reference/rpc/latest-version/api/invokescript.md b/docs/zh-cn/reference/rpc/latest-version/api/invokescript.md index 09e9e6927..62d06ff81 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/invokescript.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/invokescript.md @@ -10,7 +10,6 @@ ## 参数说明 - script:一个由虚拟机运行的脚本,与 invokefunction 返回的 script 相同; -- sender:交易发送者,支付交易费的账户,默认是 singers 中第一个账户,可选。 - signers:签名账户列表,可选 * account: 签名账户 * scopes: 签名的作用域,允许的值: FeeOnly, CalledByEntry, CustomContracts, CustomGroups, Global @@ -26,9 +25,7 @@ "jsonrpc": "2.0", "id": 1, "method": "invokescript", - "params": [ - "180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52", - ["0x1f5da2e47b37c4b96668a98da4ed8feb94bdf146"], + "params": [ "180c14e3137eddba5f6485cad334a79bdb67c43273171f0c141c0357464b777ecf6b5f3ac3893ace1f8b1621f613c00c087472616e736665720c14bcaf41d684c7d4ad6ee0d99da9707b9d1f0c8e6641627d5b52", [ { "account": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c", diff --git a/docs/zh-cn/reference/rpc/latest-version/api/sendrawtransaction.md b/docs/zh-cn/reference/rpc/latest-version/api/sendrawtransaction.md index 889e62ced..6331ec25f 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/sendrawtransaction.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/sendrawtransaction.md @@ -8,7 +8,7 @@ ## 参数说明 -hex:在程序中构造的已签名的交易序列化后的 16 进制字符串。 +hex:在程序中构造的已签名的交易序列化后的 Base64 加密字符串。 ## 调用示例 @@ -18,7 +18,7 @@ hex:在程序中构造的已签名的交易序列化后的 16 进制字符串 { "jsonrpc": "2.0", "method": "sendrawtransaction", - "params": ["004715897d2bf173f849d1d59123d097c009aa31624d39e73900e1f50500000000466a130000000000f699200000012bf173f849d1d59123d097c009aa31624d39e739015d0300d0ed902e0000000c1425275006800e73cc64286753a3a732422521c8e40c142bf173f849d1d59123d097c009aa31624d39e73913c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b523901420c40632d2abc04cce02a7d373a2def1b5d126ce75cdd6f40ef8ab9258960841c4123c48288a6f44bc86d94e83755faee3c17d059b99561a18d923202717796e0b68f290c2103b9c46c6d5c671ef5c21bc7aa7c30468aeb081a2e3895269adf947718d650ce1e0b410a906ad4"], + "params": ["ALmNfAb4lqIAAAAAAAZREgAAAAAA8S8AAAEKo4e1Ppa3mJpjFDGgVt0fQKBC9gEAKQwFd29ybGQRwAwDcHV0DBR9rbALvBGpMrl7cXVBdSsPOC0EmUFifVtSAUIMQACXF48H1VRmI50ievPfC042rJgj7ZQ3Y4ff27abOpeclh+6KpsL6gWfZTAUyFOwdjkA7CWLM3HsovQeDQlI0oopDCEDzqPi+B8a+TUi0p7eTySh8L7erXKTOR0ziA9Uddl4eMkLQZVEDXg="], "id": 1 } ``` diff --git a/docs/zh-cn/reference/rpc/latest-version/api/submitblock.md b/docs/zh-cn/reference/rpc/latest-version/api/submitblock.md index 6c0adc9df..ff7710ef2 100644 --- a/docs/zh-cn/reference/rpc/latest-version/api/submitblock.md +++ b/docs/zh-cn/reference/rpc/latest-version/api/submitblock.md @@ -8,7 +8,7 @@ ## 参数说明 -Hex: 序列化区块的十六进制字符串。 +Hex: 序列化区块的 Base64 加密字符串。 ## 调用示例 @@ -18,7 +18,7 @@ Hex: 序列化区块的十六进制字符串。 { "jsonrpc": "2.0", "method": "submitblock", - "params": ["0000000020101cfb80de52766575a91310fddd7bf4fbd4f904e5574373649092cffffcf154badd3ae13d8aa76e75ebf9a1b2fcff874e85798a940da9e21f9533625b5a135bf545ce74010000180000000b2222301e1d5984be6d5a928e946d269603505801420c40ffe24193611172117b7cb49915afe91ec7bf314c6f855f13f82f84329238e8e1649c1aea471873fb374f548a70bb04d0cb127ddb1d4765f67d3b29a2a10e42822b110c2102470d8f746f040f8b9355be5e6fd1dc280f0c6ba9270420290337b07a37f706bd110b41138defaf010088e65a74589edfbf"], + "params": ["AAAAACMSKFbGpGl6t7uroMpi2ilhQd84eU/pUrRfQyswXYl76woLOY0oW1z4InfxoKyxFAAB+8FS6cRu2Pm0iaOiD8OMCnLadQEAAMgcAAD6lrDvowCyjK9dBALCmE1fvMuahQFCDEAd8EoEFBcxOLCZfh8w0tUEHHmyn++KzW4I8oeJ1WyMmjHVcolpNzOnAOzXTn/xujwy93gJ9ijvVo6wAF5qC3wCKxEMIQL4L//X3jDpIyMLze0sPNW+yFcufrrL3bnzOipdJpNLixELQRON768CAGUTt7+NSxXGAA7aoUS2kokAAAAAACYcEwAAAAAARzMAAAHNWK7P0zW+HrPTEeHcgAlj39ctnwEAXQMA5AtUAgAAAAwUzViuz9M1vh6z0xHh3IAJY9/XLZ8MFM1Yrs/TNb4es9MR4dyACWPf1y2fE8AMCHRyYW5zZmVyDBS8r0HWhMfUrW7g2Z2pcHudHwyOZkFifVtSOAFCDEADRhUarLK+/BBjhqaWY5ieento21zgkcsUMWNCBWGd+v8a35zatNRgFbUkni4dDNI/BGc3zOgPT6EwroUsgvR+KQwhAv3yei642bBp1hrlpk26E7iWN8VC2MdMXWurST/mONaPC0GVRA14"], "id": 1 } ``` diff --git a/docs/zh-cn/reference/scapi/api.md b/docs/zh-cn/reference/scapi/api.md index 948f1a71e..3f2356da1 100644 --- a/docs/zh-cn/reference/scapi/api.md +++ b/docs/zh-cn/reference/scapi/api.md @@ -2,8 +2,6 @@ NeoContract 的 API 扩展了智能合约的功能,使其可以访问区块链账本数据、操作持久化存储区、访问执行环境等。它是NEO虚拟机(NeoVM)互操作服务层的一部分。 -有关 NeoVM 的相关信息,请参阅 [NeoVM](../../basic/technology/neovm.md)。 - 有关在高级语言中如何使用框架方便地调用 API,请参阅 [NEO智能合约框架](fw.md)。 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..c75351d63 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,40 @@ 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**: 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/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 new file mode 100644 index 000000000..c94bfdbcc --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md @@ -0,0 +1,29 @@ +# GAS 类 + +提供了原生合约GasToken的一系列属性与方法,合约哈希为`0x36a019d836d964c438c573f78badf79b9e7eebdd`。 + +命名空间:[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(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 new file mode 100644 index 000000000..c69ecd918 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/BalanceOf.md @@ -0,0 +1,48 @@ +# BalanceOf 方法 (UInt160) + +获取账户的GAS余额。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger BalanceOf(UInt160 account); +``` + +参数: + +- account: 所查询账户的脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = GAS.BalanceOf(account); + return result; + } +} +``` +响应正文: + +```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/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..2412b763b --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas/Transfer.md @@ -0,0 +1,52 @@ +# Transfer 方法 (UInt160, UInt160, BigInteger) + +GAS转账。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); +``` + +参数: + +- from: 转出账户的脚本哈希; +- to: 转入账户的脚本哈希; +- amount: 要转账的金额。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + + public static object Main() + { + 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/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..802113e34 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md @@ -0,0 +1,38 @@ +# Neo 类 + +提供了原生合约NeoToken的一系列属性与方法,合约哈希为`0xe22f9134cef8b03e53f71b3f960a20a65cddc972`。 + +命名空间:[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(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(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 new file mode 100644 index 000000000..cec2632bb --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/BalanceOf.md @@ -0,0 +1,49 @@ +# BalanceOf 方法 (UInt160) + +获取账户的NEO余额。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger BalanceOf(UInt160 account); +``` + +参数: + +- account: 所查询账户的脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = NEO.BalanceOf(account); + return result; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..6b8544107 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCandidates.md @@ -0,0 +1,52 @@ +# GetCandidates 方法 () + +获取候选人列表。由于账户NEO余额会随交易而不断变化,而且投票和注册的候选人也在不断变化,因此在每个区块都会根据以上变化更新候选人及相应投票结果。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern (ECPoint, BigInteger)[] GetCandidates(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + (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 new file mode 100644 index 000000000..c846fc8af --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetCommittee.md @@ -0,0 +1,46 @@ +# GetCommittee 方法 () + +获取委员会成员列表。候选人将根据得票数排序,最前面一定数量的候选人(默认21个)成为委员会成员。委员会名单将在每个区块根据最新投票更新。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern ECPoint[] GetCommittee(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + 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 new file mode 100644 index 000000000..e586b3b70 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetGasPerBlock.md @@ -0,0 +1,43 @@ +# 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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..d7925ac0a --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/GetNextBlockValidators.md @@ -0,0 +1,45 @@ +# GetNextBlockValidators 方法 () + +获取下个区块的验证人列表。候选人将根据得票数排序,取最前面一定数量的候选人(默认7个)作为共识节点。与委员会类似,共识节点名单将在每个区块根据最新投票更新。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern ECPoint[] GetNextBlockValidators(); +``` + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + public static object Main() + { + 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 new file mode 100644 index 000000000..ef4f57522 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/RegisterCandidate.md @@ -0,0 +1,53 @@ +# RegisterCandidate 方法 (ECPoint) + +注册成为候选人。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 注册候选人需要验证候选人地址的签名,即只有候选人自己才能执行注册/注销操作。 + +## 语法 + +```c# +public static extern bool RegisterCandidate(ECPoint pubkey); +``` + +参数: + +- pubkey: 要注册账户的公钥。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..af4478007 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/SetGasPerBlock.md @@ -0,0 +1,52 @@ +# SetGasPerBlock 方法 (BigInteger) + +设置每出一个区块所产生的GAS数。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..cf81605be --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/TotalSupply.md @@ -0,0 +1,43 @@ +# 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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..e96ffa374 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Transfer.md @@ -0,0 +1,56 @@ +# Transfer 方法 (UInt160, UInt160, BigInteger) + +NEO转账。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要校验付款人的签名,方法调用者是否为付款人,收款人是否能够收款,以及付款人余额是否充足。 + +## 语法 + +```c# +public static extern bool Transfer(UInt160 from, UInt160 to, BigInteger amount); +``` + +参数: + +- from: 转出账户的脚本哈希; +- to: 转入账户的脚本哈希; +- amount: 要转账的金额。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 from = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly UInt160 to = "NXjtqYERuvSWGawjVux8UerNejvwdYg7eE".ToScriptHash(); + + public static object Main() + { + BigInterger value = 1000; + bool result = NEO.Transfer(from, to, value); + 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/UnRegisterCandidate.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md new file mode 100644 index 000000000..3345ff032 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnRegisterCandidate.md @@ -0,0 +1,53 @@ +# UnRegisterCandidate 方法 (ECPoint) + +取消注册为候选人。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 注销候选人需要验证候选人地址的签名,即只有候选人自己才能执行注册/注销操作。 + +## 语法 + +```c# +public static extern bool UnRegisterCandidate(ECPoint pubkey); +``` + +参数: + +- pubkey: 要取消账户的公钥。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..99cccccb0 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/UnclaimedGas.md @@ -0,0 +1,49 @@ +# UnclaimedGas 方法 (UInt160, uint) + +获取未领取的Gas数. + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern BigInteger UnclaimedGas(UInt160 account, uint end); +``` + +参数: + +- account: 所查询账户的脚本哈希; +- end:截止到的区块高度 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + BigInteger result = NEO.UnclaimedGas(account, 100); + return result; + } +} +``` +响应正文: + +```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 new file mode 100644 index 000000000..cc6998d40 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo/Vote.md @@ -0,0 +1,55 @@ +# Vote 方法 (UInt160, ECPoint) + +每个地址均有投票给一个地址的权利,候选人票数为所有向该账户投票的地址的NEO余额之和。初始块所有默认候选人均会向自己投票。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> - 投给非候选人的地址的票数会被统计但不会被计入票数,只有当该地址注册为候选人投票才会生效。 +> - 投票需要验证投票者的签名。 + +## 语法 + +```c# +public static extern bool Vote(UInt160 account, ECPoint voteTo); +``` + +参数: + +- account: 投票账户的脚本哈希; +- voteTo: 目标账户的公钥。 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + private static readonly byte[] pubkey = "02e8ff17c567d62f274fe247cc884a2a6cd3b8fd0d779a8c5856289a560accacb4".HexToBytes(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..39dae1b6f --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md @@ -0,0 +1,25 @@ +# Oracle 类 + +提供了原生合约Oracle的一系列方法,合约哈希为`0x35e4fc2e69a4d04d1db4d755c4150c50aff2e9a9`。 + +命名空间:[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..b129a43e7 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md @@ -0,0 +1,30 @@ +# Policy 类 + +提供了原生合约Policy的一系列方法,合约哈希为`0x1ca594b36b6b6b3f05efce8b106c824053d18713`。 + +命名空间:[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(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(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 new file mode 100644 index 000000000..2bc8b4916 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/BlockAccount.md @@ -0,0 +1,52 @@ +# BlockAccount 方法 (UInt160) + +将指定账户加入黑名单。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```c# +public static extern bool BlockAccount(UInt160 account); +``` + +参数: + +- account: 待加入黑名单的账户脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + + public static object Main() + { + bool result = Policy.BlockAccount(account); + return result; + } +} +``` +响应正文: + +```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 new file mode 100644 index 000000000..ea20c7102 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetFeePerByte.md @@ -0,0 +1,43 @@ +# 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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..109f9c5aa --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSize.md @@ -0,0 +1,43 @@ +# 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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..efc2e77f9 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxBlockSystemFee.md @@ -0,0 +1,42 @@ +# 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; + } +} +``` +响应正文: + +```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 new file mode 100644 index 000000000..18e0f4caf --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/GetMaxTransactionsPerBlock.md @@ -0,0 +1,42 @@ +# 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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..1a4937fdb --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/IsBlocked.md @@ -0,0 +1,49 @@ +# IsBlocked 方法 (UInt160) + +验证是否为黑名单账户。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +## 语法 + +```c# +public static extern string[] IsBlocked(UInt160 account); +``` + +参数: + +- account: 待验证账户的脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NXsG3zwpwcfvBiA3bNMx6mWZGEro9ZqTqM".ToScriptHash(); + + public static object Main() + { + 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 new file mode 100644 index 000000000..fab4b62df --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetFeePerByte.md @@ -0,0 +1,50 @@ +# SetFeePerByte 方法 (long) + +设置每字节手续费。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```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; + } +} +``` +响应正文: + +```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 new file mode 100644 index 000000000..06f2c3d2b --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSize.md @@ -0,0 +1,51 @@ +# SetMaxBlockSize 方法 (uint) + +设置最大区块大小。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```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; + } +} +``` + +响应正文: + +```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 new file mode 100644 index 000000000..f37287630 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxBlockSystemFee.md @@ -0,0 +1,55 @@ +# SetMaxBlockSystemFee 方法 (uint) + +设置区块最大系统手续费。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```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; + } +} +``` + +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示设置区块最大系统手续费成功。 + +- 其他:失败。 + +> [!Note] +> +> 设置的手续费值应不小于4007600。 + +[返回上级](../Policy.md) \ 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..23cb07572 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/SetMaxTransactionsPerBlock.md @@ -0,0 +1,50 @@ +# SetMaxTransactionsPerBlock 方法 (uint) + +设置每区块最大交易数。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```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; + } +} +``` +响应正文: + +```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 new file mode 100644 index 000000000..3dad34099 --- /dev/null +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy/UnblockAccount.md @@ -0,0 +1,53 @@ +# UnblockAccount 方法 (UInt160) + +将指定账户解除黑名单。 + +命名空间:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) + +程序集:Neo.SmartContract.Framework + +> [!Note] +> +> 需要验证委员会的多签。签名超过委员会数量的一半的向上取整即为有效,相应操作将被执行。 + +## 语法 + +```c# +public static extern bool UnblockAccount(UInt160 account); +``` + +参数: + +- account: 待解除黑名单的账户脚本哈希 + +## 示例 + +```c# +public class Contract1 : SmartContract.Framework.SmartContract +{ + private static readonly UInt160 account = "NirHUAteaMr6CqWuAAMaEUScPcS3FDKebM".ToScriptHash(); + + public static object Main() + { + bool result = Policy.UnblockAccount(account); + return result; + } +} +``` + +响应正文: + +```json +{ + "type":"Boolean", + "value":"true" +} +``` + +响应说明: + +- Boolean类型:true表示解除屏蔽地址成功。 + +- 其他:失败。 + +[返回上级](../Policy.md) diff --git a/docs/zh-cn/reference/scapi/fw/dotnet/neo/TriggerType.md b/docs/zh-cn/reference/scapi/fw/dotnet/neo/TriggerType.md index 1161d3f6d..0f663ee24 100644 --- a/docs/zh-cn/reference/scapi/fw/dotnet/neo/TriggerType.md +++ b/docs/zh-cn/reference/scapi/fw/dotnet/neo/TriggerType.md @@ -2,7 +2,7 @@ 定义了触发器类型。触发器可以使合约根据不同的使用场景执行不同的逻辑。 -更多关于触发器的知识,请查看 [合约开发基础](../../../../../sc/write/basics.md)。 +更多关于触发器的知识,请查看 [合约开发基础](../../../../../develop/write/basics.md)。 命名[Neo.SmartContract.Framework.Services.Neo](../neo.md) diff --git a/docs/zh-cn/toc.yml b/docs/zh-cn/toc.yml index 1d301ba52..fc643faf6 100644 --- a/docs/zh-cn/toc.yml +++ b/docs/zh-cn/toc.yml @@ -2,6 +2,49 @@ href: /v3/docs/zh-cn/index.md - name: 术语表 href: /v3/docs/zh-cn/glossary.md +- name: 快速入门(C#) + items: + - name: 准备工作 + href: /v3/docs/zh-cn/gettingstarted/prerequisites.md + - name: 搭建网络环境 + href: /v3/docs/zh-cn/gettingstarted/enviroment.md + - name: 开发示例合约 + href: /v3/docs/zh-cn/gettingstarted/develop.md + - name: 部署并调用合约 + href: /v3/docs/zh-cn/gettingstarted/deploy.md +- name: Neo 基础 + items: + - name: 基本概念 + - name: 区块模型 + - name: 区块 + href: /v3/docs/zh-cn/basic/concept/blockchain/block.md + - name: 通证 + href: /v3/docs/zh-cn/basic/concept/blockchain/token_model.md + - name: 收费模型 + href: /v3/docs/zh-cn/basic/concept/charging_model.md + - name: 密码学 + href: + - name: 编码算法 + href: /v3/docs/zh-cn/basic/concept/cryptography/encode_algorithm.md + - name: 哈希算法 + href: /v3/docs/zh-cn/basic/concept/cryptography/hash_algorithm.md + - name: 加密算法 + href: /v3/docs/zh-cn/basic/concept/cryptography/encryption_algorithm.md + - name: 大小端序的使用 + href: /v3/docs/zh-cn/basic/concept/endian.md + - name: 钱包 + href: /v3/docs/zh-cn/basic/concept/wallets.md + - name: 交易 + href: /v3/docs/zh-cn/basic/concept/transaction.md + - name: 共识机制 + - name: 概述 + href: /v3/docs/zh-cn/basic/consensus/dbft.md + - name: 共识算法 + href: /v3/docs/zh-cn/basic/consensus/consensus_algorithm.md + - name: 共识协议 + href: /v3/docs/zh-cn/basic/consensus/consensus_protocol.md + - name: 投票 + href: /v3/docs/zh-cn/basic/consensus/vote_validator.md - name: Neo 节点 items: - name: 节点介绍 @@ -26,117 +69,67 @@ href: /v3/docs/zh-cn/node/gui/contract.md - name: 高级功能 href: /v3/docs/zh-cn/node/gui/advanced.md -- name: Neo 网络 - items: - - name: 主网与测试网 - href: /v3/docs/zh-cn/network/testnet.md - - name: 搭建私有链 - items: - - name: 单节点模式 - href: /v3/docs/zh-cn/network/private-chain/solo.md - - name: 在本地主机搭建 - href: /v3/docs/zh-cn/network/private-chain/private-chain2.md -- name: 智能合约开发 +- name: 开发指南 items: - - name: 快速入门(C#) + - name: Neo 网络 items: - - name: 介绍 - href: /v3/docs/zh-cn/sc/gettingstarted/introduction.md - - name: 准备工作 - href: /v3/docs/zh-cn/sc/gettingstarted/prerequisites.md - - name: 搭建网络环境 - href: /v3/docs/zh-cn/sc/gettingstarted/enviroment.md - - name: 开发示例合约 - href: /v3/docs/zh-cn/sc/gettingstarted/develop.md - - name: 部署并调用合约 - href: /v3/docs/zh-cn/sc/gettingstarted/deploy.md + - name: 主网与测试网 + href: /v3/docs/zh-cn/develop/network/testnet.md + - name: 搭建私有链 + items: + - name: 单节点模式 + href: /v3/docs/zh-cn/develop/network/private-chain/solo.md + - name: 在本地主机搭建 + href: /v3/docs/zh-cn/develop/network/private-chain/private-chain2.md - name: 合约编写 items: - name: 合约编写基础 - href: /v3/docs/zh-cn/sc/write/basics.md + href: /v3/docs/zh-cn/develop/write/basics.md - name: 编写限制 - href: /v3/docs/zh-cn/sc/write/limitation.md + href: /v3/docs/zh-cn/develop/write/limitation.md - name: NEP-5 - href: /v3/docs/zh-cn/sc/write/nep5.md - - name: 部署和调用 - - name: 部署合约 - href: /v3/docs/zh-cn/sc/deploy/deploy.md - - name: 调用合约 - href: /v3/docs/zh-cn/sc/deploy/invoke.md - - name: 合约升级 - href: /v3/docs/zh-cn/sc/migrate.md - - name: 手续费 - href: /v3/docs/zh-cn/sc/fees.md + href: /v3/docs/zh-cn/develop/write/nep5.md + - name: 合约升级 + href: /v3/docs/zh-cn/develop/write/migrate.md - name: 合约示例 items: - name: Hello World - href: /v3/docs/zh-cn/sc/sample/HelloWorld.md + href: /v3/docs/zh-cn/develop/sample/HelloWorld.md - name: Domain(域名系统) - href: /v3/docs/zh-cn/sc/sample/Domain.md + href: /v3/docs/zh-cn/develop/sample/Domain.md - name: 存证合约 - href: /v3/docs/zh-cn/sc/sample/storage.md - - name: Neo工具开发 - - name: 基本概念 - - name: 区块模型 - - name: 区块 - href: /v3/docs/zh-cn/tooldev/concept/blockchain/block.md - - name: 通证 - href: /v3/docs/zh-cn/tooldev/concept/blockchain/token_model.md - - name: 收费模型 - href: /v3/docs/zh-cn/tooldev/concept/charging_model.md - - name: 密码学 - href: - - name: 编码算法 - href: /v3/docs/zh-cn/tooldev/concept/cryptography/encode_algorithm.md - - name: 哈希算法 - href: /v3/docs/zh-cn/tooldev/concept/cryptography/hash_algorithm.md - - name: 加密算法 - href: /v3/docs/zh-cn/tooldev/concept/cryptography/encryption_algorithm.md - - name: 大小端序的使用 - href: /v3/docs/zh-cn/tooldev/concept/endian.md - - name: 共识机制 - - name: 共识算法 - href: /v3/docs/zh-cn/tooldev/consensus/consensus_algorithm.md - - name: 共识协议 - href: /v3/docs/zh-cn/tooldev/consensus/consensus_protocol.md - - name: 投票 - href: /v3/docs/zh-cn/tooldev/consensus/vote_validator.md - - name: 钱包 - href: /v3/docs/zh-cn/tooldev/wallets.md - - name: 交易 - - name: 交易 - href: /v3/docs/zh-cn/tooldev/transaction/transaction.md - - name: Neo SDK - items: - - name: 关于 Neo RPC SDK - href: /v3/docs/zh-cn/tooldev/sdk/introduction.md - - name: RPC 调用方法 - href: /v3/docs/zh-cn/tooldev/sdk/rpc.md - - name: 获取区块信息 - href: /v3/docs/zh-cn/tooldev/sdk/monitor.md - - name: 钱包相关接口 - href: /v3/docs/zh-cn/tooldev/sdk/wallet.md - - name: 构造交易 - href: /v3/docs/zh-cn/tooldev/sdk/transaction.md - - name: 合约部署与调用 - href: /v3/docs/zh-cn/tooldev/sdk/contract.md -- name: 交易所对接指南 + href: /v3/docs/zh-cn/develop/sample/storage.md + - name: 部署和调用 + - name: 部署合约 + href: /v3/docs/zh-cn/develop/deploy/deploy.md + - name: 调用合约 + href: /v3/docs/zh-cn/develop/deploy/invoke.md + - name: 开发工具 + - name: Neo SDK + items: + - name: 关于 Neo RPC SDK + href: /v3/docs/zh-cn/develop/tool/sdk/introduction.md + - name: RPC 调用方法 + href: /v3/docs/zh-cn/develop/tool/sdk/rpc.md + - name: 获取区块信息 + href: /v3/docs/zh-cn/develop/tool/sdk/monitor.md + - name: 钱包相关接口 + href: /v3/docs/zh-cn/develop/tool/sdk/wallet.md + - name: 构造交易 + href: /v3/docs/zh-cn/develop/tool/sdk/transaction.md + - name: 合约部署与调用 + href: /v3/docs/zh-cn/develop/tool/sdk/contract.md +- name: 进阶知识 items: - - name: 概述 + - name: 预言机 href: /v3/docs/zh-cn/exchange/general.md - - name: 部署 Neo 节点 - href: /v3/docs/zh-cn/exchange/deploynode.md - - name: 使用 Neo-CLI 客户端 - href: /v3/docs/zh-cn/exchange/client.md - - name: 处理资产交易 - href: /v3/docs/zh-cn/exchange/transaction.md - - name: 给用户分发 GAS - href: /v3/docs/zh-cn/exchange/gas.md - name: 开发参考 items: - name: RPC API - name: API 参考 href: /v3/docs/zh-cn/reference/rpc/latest-version/api.md + - name: calculatenetworkfee + href: /v3/docs/zh-cn/reference/rpc/latest-version/api/calculatenetworkfee.md - name: closewallet href: /v3/docs/zh-cn/reference/rpc/latest-version/api/closewallet.md - name: dumpprivkey @@ -175,10 +168,12 @@ 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: getvalidators - href: /v3/docs/zh-cn/reference/rpc/latest-version/api/getvalidators.md + - name: getcommittee + href: /v3/docs/zh-cn/reference/rpc/latest-version/api/getcommittee.md - name: getversion href: /v3/docs/zh-cn/reference/rpc/latest-version/api/getversion.md - name: importprivkey @@ -234,16 +229,22 @@ href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Crypto.md - name: Enumerator href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Enumerator.md + - name: Gas + href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Gas.md - name: Helper href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Helper.md - name: Iterator href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Iterator.md - name: Json href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Json.md - - name: Native - href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Native.md + - name: Neo + href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Neo.md - name: Notification href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Notification.md + - name: Oracle + href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Oracle.md + - name: Policy + href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Policy.md - name: Runtime href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/neo/Runtime.md - name: Storage @@ -264,5 +265,19 @@ href: /v3/docs/zh-cn/reference/scapi/fw/dotnet/System/ExecutionEngine.md - name: 治理 API href: /v3/docs/zh-cn/reference/governance_api.md + - name: 手续费 + href: /v3/docs/zh-cn/reference/fees.md - name: NeoVM 指令集 href: /v3/docs/zh-cn/reference/neo_vm.md +- name: 交易所对接指南 + items: + - name: 概述 + href: /v3/docs/zh-cn/exchange/general.md + - name: 部署 Neo 节点 + href: /v3/docs/zh-cn/exchange/deploynode.md + - name: 使用 Neo-CLI 客户端 + href: /v3/docs/zh-cn/exchange/client.md + - name: 处理资产交易 + href: /v3/docs/zh-cn/exchange/transaction.md + - name: 给用户分发 GAS + href: /v3/docs/zh-cn/exchange/gas.md \ No newline at end of file diff --git a/docs/zh-cn/tooldev/neo_cli_structure.md b/docs/zh-cn/tooldev/neo_cli_structure.md deleted file mode 100644 index 05e65edc1..000000000 --- a/docs/zh-cn/tooldev/neo_cli_structure.md +++ /dev/null @@ -1,229 +0,0 @@ -# Neo-CLI 结构 - -NEO是一个基于点对点网络的区块链系统。它提供基于UTXO模型的数字资产记账功能,以及一个基于NEO虚拟机的智能合约的执行环境。本文将描述网络中节点程序Neo-CLI的整体结构和基本行为。 - -## 整个网络 - -[![neo p2p network](images/neo_cli_structure/neo-p2p-network.png)](../images/neo_cli_structure/neo-p2p-network.png) - -网络中的每个节点运行一个 Neo-CLI 程序或者协议兼容程序。其中参与共识的是共识节点。不参与共识的是非共识节点。 - -## Neo-CLI - -Neo-CLI的结构如下图。(由于版本升级,部分结构可能会有变化 ) - -[![NEO-CLI structure](images/neo_cli_structure/NEO-CLI.png)](../images/neo_cli_structure/NEO-CLI.png) - -### Neo-CLI 命令行 - -Neo-CLI 是一个命令行程序。通过命令行控制台提供与区块链交互的基本功能。更多信息,请参考[Neo-CLI 命令行](../node/cli/cli.md)。 - -### 账本 API - -账本API定义了UTXO模型的基本数据类型,包括交易,区块,记账人等基础数据结构。细节将在后续章节中介绍。 - -### 钱包 - -NEO官方提供两种格式的钱包,一种是sqlite数据库格式的钱包,另一种是NEP-6钱包。sqlite格式钱包的优点是性能相对较好,缺点是适用的平台不如NEP-6钱包更广泛。 - -### LevelDBStore / Blockchain - -基于leveldb实现的区块链数据管理模块。向其它部分提供区块链数据的存储和查询服务。 - -### LocalNode - -节点的网络通信的模块。负责与网络中的其它节点交换信息。细节将在后续章节中介绍。 - -### RpcServer - -一个向外提供RPC调用接口的模块。关于RPC接口的细节,请参考[RPC API](../reference/rpc/latest-version/api.md)。 - -### ConsensusService - -在NEO网络中,只有共识节点需要启动共识服务。共识节点通过点对点网络与其它共识节点交换信息,完成区块链中生成新的区块的过程。细节将在后续章节中介绍。 - -### Plugin - -通过插件的形式实现区块链中一些特定模块的逻辑,方便特定功能的定制和调试。包括下述四个种类: - - - **ILogPlugin** : 智能合约的执行结果存储插件。 - - **IPolicyPlugin** : 生成新区块时交易的排序策略插件。 - - **IRpcPlugin** : 执行RPC调用的插件。 - - **IPersistencePlugin** : 节点收到新的区块,将其保存到本地数据库时的自定义行为插件。 - -### NeoVM - -NEO实现的虚拟机。用来执行验证脚本和智能合约。细节将在后续章节中介绍。 - -ApplicationEngine是对NeoVM的一层封装。NeoVM被设计成一个独立的模块。可以在区块链之外部署。而ApplicationEngine与区块链本身的联系更加紧密。 - -## 配置文件 - -Neo-CLI的节点程序在执行过程中会访问下述配置文件。 - - - **config.json** : 基础配置文件 - - **protocol.json** : 协议配置文件 - -### config.json - -定义数据库路径、网络配置、启动设置等基础配置。 - -```json -{ - "ApplicationConfiguration": { - "Paths": { - "Chain": "Chain_{0}", - "Index": "Index_{0}" - }, - "P2P": { - "Port": 10333, - "WsPort": 10334 - }, - "RPC": { - "BindAddress": "127.0.0.1", - "Port": 10332, - "SslCert": "", - "SslCertPassword": "" - }, - "UnlockWallet": { - "Path": "", - "Password": "", - "StartConsensus": false, - "IsActive": false - } - } -} -``` - -属性说明: - - - Paths/Chain : 区块链数据库的存储目录前缀。存储目录的后缀是Magic数的8位16进制表示。Magic数将在后续提及。 - - Paths/Index : 钱包索引的存储目录前缀。 - - P2P/Port : 网络节点之间 TCP/IP 协议连接的监听端口号。 - - P2P/WsPort : 网络节点之间 WebSocket 协议连接的监听端口号。 - - RPC/BindAddress : JSON-RPC 服务的监听 IP 地址。 - - RPC/Port : JSON-RPC 服务的监听端口号。 - - RPC/SslCert : JSON-RPC 服务的安全连接的认证。默认为空时,不使用安全连接。 - - RPC/SslCertPassword : JSON-RPC 服务的安全连接的密码。默认为空时,不使用安全连接。 - - UnlockWallet/IsActive : 启动网络节点时是否自动解锁钱包。 - - UnlockWallet/Path : 启动网络节点时解锁钱包的钱包文件地址。 - - UnlockWallet/Password : 启动网络节点时解锁钱包的密码。 - - UnlockWallet/StartConsensus : 启动网络节点时是否自动开始共识。自动开始共识依赖于自动解锁钱包。 - -`config.mainnet.json`和`config.testnet.json`是两个备份文件,分别存放主网和测试网的配置文件。 - -### protocol.json - -定义协议级的变量、备用共识节点公钥列表、种子节点列表、系统手续费价格。 - -```json -{ - "ProtocolConfiguration": { - "Magic": 7630401, - "AddressVersion": 23, - "SecondsPerBlock": 15, - "StandbyValidators": [ - "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", - "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", - "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", - "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554", - "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d", - "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e", - "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70" - ], - "SeedList": [ - "seed1.ngd.network:10333", - "seed2.ngd.network:10333", - "seed3.ngd.network:10333", - "seed4.ngd.network:10333", - "seed5.ngd.network:10333", - "seed6.ngd.network:10333", - "seed7.ngd.network:10333", - "seed8.ngd.network:10333", - "seed9.ngd.network:10333", - "seed10.ngd.network:10333", - "seed1.neo.org:10333", - "seed2.neo.org:10333", - "seed3.neo.org:10333", - "seed4.neo.org:10333", - "seed5.neo.org:10333" - ], - "SystemFee": { - "EnrollmentTransaction": 1000, - "IssueTransaction": 500, - "PublishTransaction": 500, - "RegisterTransaction": 10000 - } - } -} -``` - -属性说明: - - - Magic : 魔法数字。主网:7630401(0x00746E41) 测试网:1953787457(0x74746E41)。搭建私有链网络时,魔法数字可以改为任意整数,但是同一网络中的节点的魔法数字必须相同。 - - AddressVersion : 地址版本。固定值23 - - SecondsPerBlock : 出块时间间隔。同一网络中共识节点必须相同。 - - StandbyValidators : 备用共识节点的公钥列表。 - - SeedList : 种子节点列表。种子节点不是共识节点。种子节点向网络中的新节点提供其它节点的地址查询服务。 - - SystemFee : 系统手续费定义。 - -protocol.mainnet.json 和 protocol.testnet.json 是两个备份文件,分别存放主网和测试网的配置文件。 - -> [!NOTE] -> -> - Neo-CLI 2.7.6曾经使用过临时文件 peers.dat 保存已知的其它节点 IP 地址,2.9.0开始不再使用了。 -> - Neo-CLI运行过程中如果异常终止,那么会将错误内容写入文件error.log,方便查看错误原因。 - -## 启动的基本过程 - -### Neo-CLI 的启动过程 - -1. 初始化LevelDBStore,创建或者打开leveldb数据库。 - -2. 启动LocalNode,异步开始点对点网络通信。 - -3. 根据文件配置决定是否打开钱包,是否启动共识服务。 - -4. 根据命令行参数(rpc)决定是否启动JSON-RPC服务。 - -5. 开始命令行循环,执行命令行输入的命令。 - -6. 系统结束时,停止RPC服务,停止LocalNode点对点网络通信。关闭leveldb数据库。 - -### LevelDBStore 的初始化过程 - -1. 打开leveldb数据库,初次访问就创建数据库。 - -2. 读取数据格式版本号,如果版本号小于2.9.1 就清空数据库,然后写入最新的版本号。 - -### Blockchain 的初始化过程 - -1. 从数据库读取区块链的区块头的列表,保存在内存中实现快速索引访问(header_index)。 - -2. 如果数据库中没有任何区块信息,那么将创世区块写入数据库。 - -### LocalNode 的初始化过程 - -1. 扫描本地的所有网卡的IP地址并保存。 - -2. 启动一个后台循环,每5秒钟检查一次网络节点连接数,如果小于最大连接数(10),就主动尝试去连接其它节点。如果不知道其它节点地址,就首先连接种子节点,然后向种子节点询问其它节点的地址和端口号。 - -3. 如果设备在局域网且没有公网的IP地址,那么尝试寻找设备的UPnp外网IP,然后在外网启动TCP/IP的监听端口以及WebSocket的监听端口。 - -4. 在本地启动监听端口,接受其他网络节点的主动TCP/IP连接。 - -5. 在本地启动 WebSocket 服务,接受其他网络节点的主动WebSocket连接。 - -### 共识服务的初始化过程 - - 1. 初始化共识上下文 - - 2. 监听共识消息并处理 - -### JSON-RPC 服务的初始化过程 - -在指定的网卡地址和端口监听。如果有设置则启用安全链接(https) - -### 其他的初始化过程 - -初始化所有的插件。关于插件的种类,请参考[安装插件](../node/cli/setup.md)。 diff --git a/docs/zh-cn/tooldev/network-protocol.md b/docs/zh-cn/tooldev/network-protocol.md deleted file mode 100644 index 7bc232505..000000000 --- a/docs/zh-cn/tooldev/network-protocol.md +++ /dev/null @@ -1,121 +0,0 @@ -# 网络架构:P2P - -在网络结构上,NEO采用点对点网络结构,并使用TCP/IP协议进行通讯。 - -网络中存在两种节点类型,分别是普通节点和共识节点。普通节点可以广播、接收和转发交易、区块等,而共识节点可以创建区块。 - -NEO的网络协议规范与比特币的协议大致类似,但在区块、交易等的数据结构上有很大的不同。 - -> [!NOTE] -> -> - NEO网络中的种子节点不是共识节点,它们是普通节点的一种,向其它节点提供询问节点列表的服务。 -> - NEO网络还支持WebSocket链接,以及通过UPnP协议来实现在局域网提供节点服务(Optional)。 - -## 通讯协议和端口: - -| 协议 | 端口(主网) | 端口(测试网) | -|---|---|-----| -| TCP/IP | 10333 | 20333 | -| WebSocket | 10334 | 20334 | - -> [!NOTE] -> -> 搭建NEO私有链时,可以设置端口为任意未使用的端口。节点之间也可以使用不同的端口。 - -## 报文:Message - -报文(Message)的基本格式如下 - -| 类型 | 名称 | 说明 | -| --- | --- | --- | -| uint | Magic | 魔法数字用来避免网络冲突 | -| string(12) | Command | 字符串报文名称(不足12个字节时补零) | -| int | Payload length | Payload 长度 | -| uint | Payload Checksum | Payload 校验,避免篡改和传输错误 | -| byte[] | Payload | 报文的正文内容,根据报文种类不同而不同 | - -## 命令列表(Command List): - -| 名称 | 唯一性 | 高优先级 | 保留 | 说明 | -| --- | --- | --- | --- | --- | -| addr | 〇 | | | 应答getaddr消息。发送最多不超过200条成功连接的节点地址和端口号。| -| block | | | | 应答getdata消息。返回指定哈希值的Block。 | -| consensus | | 〇 | | 应答getdata消息。返回指定哈希值的共识数据。 | -| filteradd | | 〇 | | 向bloom_filter添加数据。用与轻量级钱包。 | -| filterclear | | 〇 | | 清空bloom_filter。用与轻量级钱包。 | -| filterload | | 〇 | | 初始化bloom_filter。用与轻量级钱包。 | -| getaddr | 〇 | 〇 | | 询问其它节点的地址和端口号。 | -| getblocks | 〇 | | | 指定开始和结尾的哈希值,获取若干连续区块的详细信息。 | -| getdata | | | | 询问其它节点获取指定种类和哈希的Inventory对象。
目前有以下场景发送getdata消息。
1)共识过程中发送获取交易(Transaction)的请求。
2)收到inv消息以后发送getdata消息。 | -| getheaders | 〇 | | | 在两个节点创建连接以后,少的一方向多的一方请求区块头。 | -| headers | | | | 应答getheaders消息。最多发送不超过2000条区块头。 | -| inv | | | | 发送指定种类和哈希值的若干个Inventory的哈希值数组(只有哈希值,没有完整数据)。Inventory的种类包括区块(Block)、交易(Transaction)、共识(Consensus)。目前有以下场景发送inv消息。
1)共识过程中发送交易。
2)应答getblocks消息。发送少于500个区块。
3)应答 mempool 消息。发送整个内存池中的交易。
4)传递(Relay)一个Inventory。
5)传递(Relay)一批交易。 | -| mempool | 〇 | 〇 | | 请求对方节点整个内存池中的交易。 | -| tx | | | | 应答getdata消息。返回指定哈希值的Transaction。 | -| verack | - | 〇 | - | 第二个指令:握手应答Version。 | -| version | - | 〇 | - | 第一个指令:携带区块头高度等信息。 | -| alert | | 〇 | 〇 | 未实现 | -| merkleblock | | | 〇 | 发送已经实现,接收未实现。用于轻量级钱包。 | -| notfound | | | 〇 | 未实现 | -| ping | | | 〇 | 未实现 | -| pong | | | 〇 | 未实现 | -| reject | | | 〇 | 未实现 | -| 其它 | | | 〇 | 忽略 | - -> [!NOTE] -> -> - 唯一性:同一时间在消息队列中只有一条此消息在排队。 -> - 高优先级:系统需要保证高优先级的消息在网络中优先传播,优先处理。 - -## 对话协议 - -1. 首先NEO节点会与种子节点连接。 - -2. 节点连接成功后,首先会发送`version`消息,并等待接收`version`消息。`version`中携带区块高度。 - -3. 然后会发`verack`消息,并等待接收`verack`消息,完成握手。 - -4. 如果自己的区块头高度小于对方的区块高度,则向对方发送`getheaders`消息。 - -5. 对方收到`getheaders`消息后,通过`headers`消息应答发送不超过2000个区块头。 - -6. 如果区块头已经同步完成,而区块高度低于对方,则向对方发送`getblocks`消息。 - -7. 对方收到`getblocks`消息后,通过`inv`消息应答发送不超过500个区块的哈希值。 - -8. 收到`inv`消息后,通过哈希值判定本地是否需要。如果需要则发送`getdata`消息申请区块。 - -9. 对方收到`getdata`消息之后,发送`block`消息发送区块的完整内容。 - -10. NEO节点每5秒检查一次连接数,如果连接数不足10个,会主动去连接后备连接节点。后备连接节点不足时,会向已经连接的节点发送`getaddr`消息询问网络中其它节点的信息。 - -11. 对方节点收到`getaddr`消息后,通过`addr`消息应答发送不超过200个节点的地址和端口号。 - -12. 对于共识信息、区块、交易这些较大的数据,通过哈希值管理来避免同时从不同节点获取重复的数据。 - -13. 节点有义务将收到的共识信息、区块、交易这些信息通过`inv`消息转发给其它节点。 - -## 对话序列实例 - -| 消息方向 | 消息种类 | 说明 | -| --- | --- | --- | -| send | version | 发送version进行第一次握手 | -| receive | version | 接收version进行第一次握手 | -| send | verack | 发送verack进行第二次握手 | -| receive | verack | 接收verack进行第二次握手 | -| send | getheaders | 发送getheaders获取区块头 | -| receive | headers | 接收区块头 | -| send | getblocks | 发送getblocks获取区块 | -| receive | inv(blocks) | 收到inv若干区块的哈希值 | -| send | getdata(blocks) | 发送getdata获取若干区块的完整区块 | -| receive | inv(consensus) | 收到inv一个共识数据的哈希值 | -| send | getdata(consensus) | 发送getdata获取指定哈希值的共识数据 | -| receive | consensus | 收到一个完整的共识数据 | -| send | inv(consensus) | 将收到的共识的哈希值转发给其它节点 | -| receive | block | 收到一个完整的区块 | -| send | inv(block) | 转发区块的哈希 | -| receive | block | 收到一个完整的区块 | -| send | inv(block) | 转发区块的哈希 | -| receive | block | 收到一个完整的区块 | -| send | inv(block) | 转发区块的哈希 | -| ... | ... | ... | diff --git a/docs/zh-cn/tooldev/sdk/monitor.md b/docs/zh-cn/tooldev/sdk/monitor.md deleted file mode 100644 index a86676a84..000000000 --- a/docs/zh-cn/tooldev/sdk/monitor.md +++ /dev/null @@ -1,76 +0,0 @@ -# 获取区块信息 - -基本的区块链数据和状态信息,如区块高度、区块内容、交易内容和合约等可以通过 `RPC` 模块直接获取,详细信息请参见 [RPC 调用方法](rpc.md)。 - -而某些特定的合约信息,如区块最大交易数量,每字节系统费,NEP5 合约信息等则需要调用特定的合约方法。 - - -## 通过 RPC 接口获取区块数据 - -获取最新区块高度或哈希: - -```c# -// choose a neo node with rpc opened -RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - -// get the highest block hash -string hash = client.GetBestBlockHash(); - -// get the highest block height -uint height = client.GetBlockCount() - 1; -``` - -获取某个区块内具体数据,包括交易列表等: - -```c# -// get block data -RpcBlock block = client.GetBlock("166396"); - -// get block data with block hash -RpcBlock block = client.GetBlock("0x953f6efa29c740b68c87e0a060942056382a6912a0ddeddc2f6641acb92d9700"); -``` - -通过 `RpcClient` 获取合约脚本、哈希与 manifest 的信息: - -```c# -// get NEO contract state -ContractState contractState = client.GetContractState(NativeContract.NEO.Hash.ToString()); -``` - -更多信息请参见 [RPC 调用方法](rpc.md)。 - -## 获取 Policy 相关信息 - -调用原生合约 `PolicyContract` 中的方法 `policyAPI` 获取 Policy 相关信息: - -```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 - -// get the system fee per byte -long feePerByte = policyAPI.GetFeePerByte(); // 1000, 0.00001000 GAS per byte - -// get the max size of one block -uint maxBlockSize = policyAPI.GetMaxBlockSize(); // 262144, (1024 * 256) bytes one block - -// get the max transaction count per block -uint maxTransactionsPerBlock = policyAPI.GetMaxTransactionsPerBlock(); // 512, max 512 transactions one block -``` - -## 获取 NEP5 合约信息 - -NEP5 是 Neo3 中的资产标准,NEO 和 GAS 都基于 NEP5 原生合约。调用 `Nep5API` 可以获取 NEP5 合约的名称、标记、小数位和总量等信息: - -```c# -// get nep5 token info -Nep5API nep5API = new Nep5API(client); -RpcNep5TokenInfo tokenInfo = nep5API.GetTokenInfo(NativeContract.NEO.Hash); -``` - -## 阅读下节 - -[钱包相关接口](wallet.md) - diff --git a/docs/zh-cn/tooldev/sdk/transaction.md b/docs/zh-cn/tooldev/sdk/transaction.md deleted file mode 100644 index e6937f9da..000000000 --- a/docs/zh-cn/tooldev/sdk/transaction.md +++ /dev/null @@ -1,284 +0,0 @@ -# 构造交易 - -`Neo RPC SDK` 封装了交易构造模块,通过该模块可以使用特定的参数和方法构造 Neo3 中的交易,完成个性化的功能,本篇主要介绍这部分的使用方法。 - -> [!Note] -> -> 如果使用 SDK 中构造交易并附有签名相关的方法,需要维护一份当前所在 NEO 区块链的 protocol.json 在程序运行目录下,例如 \bin 或 \publish 目录,以确保 SDK 使用的 `Magic` 和 区块链一致,否则 SDK 构造的交易在区块链中将无法验签通过。 - -## 交易构造步骤 - -1. 构造交易脚本,决定交易要执行什么样的功能,比如转账交易: - - ```c# - // construct the script, in this example, we will transfer 1 NEO to the receiver - UInt160 scriptHash = NativeContract.NEO.Hash; - byte[] script = scriptHash.MakeScript("transfer", sender, receiver, 1); - ``` - -2. 初始化 `TransactionManager` ,将 `RpcClient ` 和发起账户的 `ScriptHash ` 作为参数。 - - ```c# - // initialize the TransactionManager with rpc client and the sender scripthash - TransactionManager txManager = new TransactionManager(client, sender); - ``` - -3. 调用 `MakeTransaction` 方法,传入交易脚本、交易属性和cosigner。 - - ```c# - // fill the script, attributes and cosigners - txManager.MakeTransaction(script, null, cosigners); - ``` - -4. 添加签名(单签或者多签),将账户的 `KeyPair` 作为签名的参数。 - - - 单签 - - ```c# - // add signature for the transaction with sendKey - txManager.AddSignature(sendKey); - ``` - - 多签 - - ```c# - // add multi-signatures for the transaction with sendKey - txManager.AddMultiSig(receiverKey, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); - txManager.AddMultiSig(key2, 2, receiverKey.PublicKey, key2.PublicKey, key3.PublicKey); - ``` - - 多签合约 - - 多签的本质来源于多签合约,需要先构建多签合约才能获取多签地址,进行多签转账。下面的示例使用了3个账户构成多签,验签时需要至少2个账户签名 - - ```c# - // 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. 校验签名,并将 `Witness` 添加至交易体。 - - 如果签名数量不够或手续费不够会引发异常。 - - ```c# - // sign the transaction with the added signatures - txManager.Sign(); - Transaction tx = txManager.Tx; - ``` - -## 交易构造示例 - -### 构造 NEP5 转账交易 - -下面的示例实现了从send账户转账1个NEO到receiver账户的功能。构建不同交易时需要关注交易中脚本和所需签名的不同。 - -```c# -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; -using Utility = Neo.Network.RPC.Utility; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - - // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - 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 } }; - - // get the scripthash of the account you want to transfer to - UInt160 receiver = Utility.GetScriptHash("NVVwFw6XyhtRCFQ8SpUTMdPyYt4Vd9A1XQ"); - - // construct the script, in this example, we will transfer 1 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; - - // broadcasts the transaction over the Neo network. - client.SendRawTransaction(tx); - 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 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); -``` - -### 构造交易向多签账户转账 - -下面的示例实现了向多签账户转账 10 个 GAS 的功能。多签账户的 scripthash 由多签合约脚本的 hash 得来。因为发送方为普通账户,添加签名的过程与上一个示例没有区别。 - -```c# -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; -using Utility = Neo.Network.RPC.Utility; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - - // get the KeyPair of your account, which will pay the system and network fee - KeyPair sendKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - UInt160 sender = Contract.CreateSignatureContract(sendKey.PublicKey).ScriptHash; - - // get the KeyPair of your accounts - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); - - // 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 - // 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); - 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 vm state is {(await p).VMState}")); - - Console.ReadKey(); - } - } -} - -``` - -### 构造交易从多签账户转账 - -下面的示例实现了从多签账户转出1个GAS的功能。多签账户的scripthash由多签合约脚本的hash得来。因为需要从多签账户转账,添加签名时要根据多签合约要求的签名数量添加。 - -```c# -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; -using Utility = Neo.Network.RPC.Utility; - -namespace ConsoleApp1 -{ - class Program - { - static void Main(string[] args) - { - // choose a neo node with rpc opened - RpcClient client = new RpcClient("http://seed1t.neo.org:20332"); - - // get the KeyPair of your account - KeyPair receiverKey = Utility.GetKeyPair("L1rFMTamZj85ENnqNLwmhXKAprHuqr1MxMHmCWCGiXGsAdQ2dnhb"); - KeyPair key2 = Utility.GetKeyPair("L2ynA5aq6KPJjpisXb8pGXnRvgDqYVkgC2Rw85GM51B9W33YcdiZ"); - KeyPair key3 = Utility.GetKeyPair("L3TbPZ3Gtqh3TTk2CWn44m9iiuUhBGZWoDJQuvVw5Zbx5NAjPbdb"); - - // 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; - 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); - 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(); - } - } -} - -``` - -## 阅读下节 - -[合约部署与调用](contract.md) \ No newline at end of file diff --git a/faq/en-us/dev.md b/faq/en-us/dev.md index 10e0dad6d..0db92ebaa 100644 --- a/faq/en-us/dev.md +++ b/faq/en-us/dev.md @@ -8,8 +8,8 @@ Up to 1000 GAS and 1000 NEO per day can be requested via the [NGD faucet](https: To build a private chain, you have the following options: -- Build a private chain with one node. See [here](../../docs/en-us/network/private-chain/solo.md). -- Build a private chain on your local host. See [here](../../docs/en-us/network/private-chain/private-chain2.md). +- Build a private chain with one node. See [here](../../docs/en-us/develop/network/private-chain/solo.md). +- Build a private chain on your local host. See [here](../../docs/en-us/develop/network/private-chain/private-chain2.md). You can also refer to the [community articles](../../articles/en-us/index.md) to learn more options. diff --git a/faq/zh-cn/dev.md b/faq/zh-cn/dev.md index 305410712..5b5775780 100644 --- a/faq/zh-cn/dev.md +++ b/faq/zh-cn/dev.md @@ -8,8 +8,8 @@ 要搭建私链,有以下方法可供选择: -- [单节点模式快速搭建](../../docs/zh-cn/network/private-chain/solo.md) -- [在本地主机搭建私有链](../../docs/zh-cn/network/private-chain/private-chain2.md) +- [单节点模式快速搭建](../../docs/zh-cn/develop/network/private-chain/solo.md) +- [在本地主机搭建私有链](../../docs/zh-cn/develop/network/private-chain/private-chain2.md) 还可以参见 [社区文章](../../articles/zh-cn/index.md),学习更多私链搭建方法。