Skip to content

Commit

Permalink
Release 2.9.0 cli (neo-project#614)
Browse files Browse the repository at this point in the history
* 2.9.0

* updates for 2.9.0

* Update v2.9.0.md (neo-project#610)

Adjustment for instruction of getting nep-5 applicationlog.

* Update invokescript.md (neo-project#613)

Add tx

* Update invokefunction.md (neo-project#612)

Add tx for response.

* Create getwalletheight (neo-project#611)

Add getwalletheight api.

* updates for 2.9.0

* minor updates

* Update setup.md (neo-project#617)

Add introduction of Plugins.

* Update v2.9.0.md (neo-project#615)

Add introduction for setting config.json

* final updates

* Update v2.9.0.md (neo-project#618)

Add notes for install plugins.

* plugin related
  • Loading branch information
Celia18305 committed Sep 17, 2018
1 parent ebf40f5 commit 5406712
Show file tree
Hide file tree
Showing 73 changed files with 7,515 additions and 150 deletions.
Binary file added assets/plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
882 changes: 882 additions & 0 deletions en-us/exchange/v2.9.0.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion en-us/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Here is an exhaustive library of NEO technical docs, including development examp

| Smart Contract | Document for Exchange Developers |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [Introduction](sc/introduction.md)<br />[Quick Start](sc/quickstart/overview.md)<br />[Reference](sc/reference/api.md)<br />[Samples and Tutorials](sc/tutorial/HelloWorld.md)<br />[Contract Triggers](sc/trigger.md)<br />[System Fees](sc/systemfees.md) | [Version 2.8.0](exchange/v2.8.0.md)<br />[Version 2.7.6](exchange/v2.7.6.md)<br />[Version 2.7.4](exchange/v2.7.4.md)<br />[Version 2.7.3](exchange/v2.7.3.md)<br />[Version 2.7.1](exchange/v2.7.1.md)<br />[Version 2.6.0](exchange/v2.6.0.md) |
| [Introduction](sc/introduction.md)<br />[Quick Start](sc/quickstart/overview.md)<br />[Reference](sc/reference/api.md)<br />[Samples and Tutorials](sc/tutorial/HelloWorld.md)<br />[Contract Triggers](sc/trigger.md)<br />[System Fees](sc/systemfees.md) | [Version 2.9.0](exchange/v2.9.0.md)<br />[Version 2.8.0](exchange/v2.8.0.md)<br />[Version 2.7.6](exchange/v2.7.6.md) |

<link rel="stylesheet" href="../styles/index.css">
160 changes: 160 additions & 0 deletions en-us/node/cli/2.9.0/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# API Reference

Each node in the Neo-CLI provides an API interface for obtaining blockchain data from a node, making it easy to develop blockchain applications. The interface is provided via [JSON-RPC](http://wiki.geekdream.com/Specification/json-rpc_2.0.html), and the underlying protocol uses HTTP/HTTPS for communication. To start a node that provides an RPC service, run the following command:

`dotnet neo-cli.dll /rpc`

## Configuring the config.json file

To access the RPC server via HTTPS, you need to modify the configuration file config.json before starting the node and set the domain name, certificate, and password:

```json
{
"ApplicationConfiguration": {
"Paths": {
"Chain": "Chain"
},
"P2P": {
"Port": 10333,
"WsPort": 10334
},
"RPC": {
"Port": 10331,
"SslCert": "YourSslCertFile.xxx",
"SslCertPassword": "YourPassword"
}
}
}
```

To invoke some API methods that require you to open a wallet, you also need to make the following changes in `config.json` before starting the node:

- Change the UnlockWallet status `IsActive` to `true`.
- Specify the file name and password of the desired wallet.

```json
...
"UnlockWallet": {
"Path": "YourWallet.json",
"Password": "YourPassword",
"StartConsensus": false,
"IsActive": true
}
...
```

Thereafter, when you open NEO-CLI, the client will automatically open the specified wallet and download the wallet index after it has been synchronized to the latest block height.

## Listening ports

After the JSON-RPC server starts, it will monitor the following ports, corresponding to the Main and Test nets:

For P2P and WebSocket information see [Node/Introduction](../../introduction.md).

| | Main Net | Test Net |
| -------------- | -------- | -------- |
| JSON-RPC HTTPS | 10331 | 20331 |
| JSON-RPC HTTP | 10332 | 20332 |

## Command List

| Command | Reference | Explanation | Comments |
| ----------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------ | ---------------------------- |
| [dumpprivkey](api/dumpprivkey.md) | \<address> | Exports the private key of the specified address | Need to open the wallet |
| [getaccountstate](api/getaccountstate.md) | \<address> | Checks account asset information according to account address | |
| [getapplicationlog](api/getapplicationlog.md) | \<txid>[verbose=0] | Returns the contract log based on the specified txid. | Need to enable logging |
| [getassetstate](api/getassetstate.md) | \<asset_id> | Queries asset information according to the specified asset number | |
| [getbalance](api/getbalance.md) | \<asset_id> | Returns the balance of the corresponding asset in the wallet according to the specified asset number. | Need to open the wallet |
| [getbestblockhash](api/getbestblockhash.md) | | Gets the hash of the tallest block in the main chain | |
| [getblock](api/getblock.md) | \<hash> [verbose=0] | Returns the corresponding block information according to the specified hash value | |
| [getblock](api/getblock2.md) | \<index> [verbose=0] | Returns the corresponding block information according to the specified index | |
| [getblockcount](api/getblockcount.md) | | Gets the number of blocks in the main chain | |
| [getblockhash](api/getblockhash.md) | \<index> | Returns the hash value of the corresponding block based on the specified index | |
| [getblocksysfee](api/getblocksysfee.md) | \<index> | Returns the system fees before the block according to the specified index | |
| [getconnectioncount](api/getconnectioncount.md) | | Gets the current number of connections for the node | |
| [getcontractstate](api/getcontractstate.md) | \<script_hash> | Returns information about the contract based on the specified script hash | |
| [getnewaddress](api/getnewaddress.md) | | Creates a new address | Need to open the wallet |
| [getrawmempool](api/getrawmempool.md) | | Gets a list of unconfirmed transactions in memory | |
| [getrawtransaction](api/getrawtransaction.md) | \<txid> [verbose=0] | Returns the corresponding transaction information based on the specified hash value | |
| [getstorage](api/getstorage.md) | \<script_hash> \<key> | Returns the stored value based on the contract script hash and key | |
| [gettxout](api/gettxout.md) | \<txid> \<n> | Returns the corresponding transaction output (change) information based on the specified hash and index | |
| [getpeers](api/getpeers.md) | | Gets a list of nodes that are currently connected/disconnected by this node | |
| [getversion](api/getversion.md) | | Gets version information of this node | |
| [getvalidators](api/getvalidators.md) | | Gets NEO consensus nodes information | |
| [getwalletheight](api/getwalletheight.md) | | Gets the current wallet index height. | |
| [invoke](api/invoke.md) | \<script_hash> \<params> | Invokes a smart contract at specified script hash with the given parameters | |
| [invokefunction](api/invokefunction.md) | \<script_hash> \<operation> \<params> | Invokes a smart contract at specified script hash, passing in an operation and its params | |
| [invokescript](api/invokescript.md) | \<script> | Runs a script through the virtual machine and returns the results | |
| [listaddress](api/listaddress.md) | | Lists all the addresses in the current wallet. | Need to open the wallet |
| [sendrawtransaction](api/sendrawtransaction.md) | \<hex> | Broadcast a transaction over the network. See the [network protocol](../../../network/network-protocol.md) documentation. | |
| [sendfrom](api/sendfrom.md) | \<asset_id> \<address> \<value> [fee=0] | Transfers from the specified address to the destination address. | |
| [sendtoaddress](api/sendtoaddress.md) | \<asset_id> \<address> \<value> [fee=0] | Transfer to specified address | Need to open the wallet |
| [sendmany](api/sendmany.md) | \<outputs_array> \[fee=0] \[change_address] | Bulk transfer order | Need to open the wallet |
| submitblock | \<hex> | Submit new blocks | Needs to be a consensus node |
| [validateaddress](api/validateaddress.md) | \<address> | Verify that the address is a correct NEO address | |

## GET request example

A typical JSON-RPC GET request format is as follows:

The following is an example of how to get the number of blocks in the main chain.

Request URL:

```
http://somewebsite.com:10332?jsonrpc=2.0&method=getblockcount&params=[]&id=1
```

After sending the request, you will get the following response:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": 909129
}
```

## POST request example

The format of a typical JSON-RPC Post request is as follows:

The following is an example of how to get the number of blocks in the main chain.

Request URL:

```
http://somewebsite.com:10332
```

Request Body:

```json
{
"jsonrpc": "2.0",
"method": "getblockcount",
"params":[],
"id": 1
}
```

After sending the request, you will get the following response:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": 909122
}
```

## Test tools

You can use the Chrome extension in Postman to facilitate the test (Installation of the Chrome extension requires Internet connection), the following is a test screenshot:

![image](../../../../assets/api_3.jpg)

## Other

[C# JSON-RPC Command List](https://github.com/chenzhitong/CSharp-JSON-RPC/blob/master/json_rpc/Program.cs)

37 changes: 37 additions & 0 deletions en-us/node/cli/2.9.0/api/dumpprivkey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# dumpprivkey Method

Exports the private key of the specified address.

> [!Note]
> You need to open the wallet in the NEO-CLI node before you execute this command.
## Parameter Description

Address: To export the addresses of the private key, the address is required as a standard address.

## Example

Request body:

```json
{
"jsonrpc": "2.0",
"method": "dumpprivkey",
"params": ["ASMGHQPzZqxFB2yKmzvfv82jtKVnjhp1ES"],
"id": 1
}
```

Response body:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": "L3FdgAisCmV******************************9XM65cvjYQ1"
}
```

Response Description:

Returns the private key of the standard address.
57 changes: 57 additions & 0 deletions en-us/node/cli/2.9.0/api/getaccountstate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# getaccountstate Method

Queries the account asset information, according to the account address.

## Parameter Description

Account Address: A 34-bit length string beginning with A, such as AJBENSwajTzQtwyJFkiJSv7MAaaMc7DsRz.

## Example

Request body:

```json
{
"jsonrpc": "2.0",
"method": "getaccountstate",
"params": ["AJBENSwajTzQtwyJFkiJSv7MAaaMc7DsRz"],
"id": 1
}
```

Response body:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"version": 0,
"script_hash": "0x1179716da2e9523d153a35fb3ad10c561b1e5b1a",
"frozen": false,
"votes": [],
"balances": [
{
"asset": "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
"value": "94"
}
]
}
}
```

Response Description:

- Script_hash: Contract scipt hash; All accounts in NEO are contract accounts

- Frozen: Determine if the account is frozen

- Votes: Query the amount of NEO on that address used to vote

- Balance: Balance of assets at the address

- Asset: Asset ID

- Value: Amount of Assets


61 changes: 61 additions & 0 deletions en-us/node/cli/2.9.0/api/getapplicationlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# getapplicationlog Method

Returns the contract log based on the specified txid. The complete contract logs are stored under the ApplicationLogs directory.

## Parameter Description

txid:Transaction ID

## Example

Request body:

```json
{
"jsonrpc": "2.0",
"method": "getapplicationlog",
"params": ["0x0d03ad35eb8b0bb2e43e18896d22cd2a77fe54fc0b00794fb295bcf96257d0e3"],
"id": 1
}
```

Response body:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"txid": "0x0d03ad35eb8b0bb2e43e18896d22cd2a77fe54fc0b00794fb295bcf96257d0e3",
"vmstate": "HALT, BREAK",
"gas_consumed": "2.932",
"stack": [],
"notifications": [
{
"contract": "0xac116d4b8d4ca55e6b6d4ecce2192039b51cccc5",
"state": {
"type": "Array",
"value": [
{
"type": "ByteArray",
"value": "7472616e73666572"
},
{
"type": "ByteArray",
"value": "45fc40a091bd0de5e5408e3dbf6b023919a6f7d9"
},
{
"type": "ByteArray",
"value": "96da23f79685e1611b99633f7a37bf07b542d42b"
},
{
"type": "ByteArray",
"value": "00345cd65804"
}
]
}
}
]
}
}
```
59 changes: 59 additions & 0 deletions en-us/node/cli/2.9.0/api/getassetstate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# getassetstate Method

Queries the asset information, based on the specified asset number.

## Parameter Description

Asset_id: Asset ID (asset identifier), which is the transaction ID of the RegistTransaction when the asset is registered.

For NEO: c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b

For GAS: 602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7

The remaining asset IDs can be queried through the `list asset` command in [CLI Command](../../cli.md) or in the Block Chain Browser.

## Example

Request body:

```json
{
"jsonrpc": "2.0",
"method": "getassetstate",
"params": ["c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"],
"id": 1
}
```

Response body:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"version": 0,
"id": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
"type": "SystemShare",
"name": [
{
"lang": "zh-CN",
"name": "NEO"
},
{
"lang": "en",
"name": "NEO"
}
],
"amount": "100000000",
"available": "100000000",
"precision": 0,
"owner": "00",
"admin": "Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt",
"issuer": "Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt",
"expiration": 2000000,
"frozen": false
}
}
```

Loading

0 comments on commit 5406712

Please sign in to comment.