forked from neo-project/neo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix broken links - 1 (neo-project#751)
- Loading branch information
1 parent
48d5af1
commit 70aa0c3
Showing
73 changed files
with
3,927 additions
and
6,397 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | | | ||
| [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 | | | ||
| [getblockheader](api/getblockheader.md) | \<hash> [verbose=0] | Returns the corresponding block header information according to the specified script hash | | | ||
| [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. | Need to open the wallet | | ||
| [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. | Need to open the wallet | | ||
| [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¶ms=[]&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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
``` | ||
|
Oops, something went wrong.