Skip to content

Commit

Permalink
Merge pull request #150 from chenzhitong/rpc-error
Browse files Browse the repository at this point in the history
RPC Exception
  • Loading branch information
Celia18305 authored Oct 25, 2024
2 parents 9996b60 + eab5c58 commit ab61d2a
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 5 deletions.
58 changes: 58 additions & 0 deletions docs/n3/reference/rpc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,61 @@ After sign in or sign up a Posmtan account, you can directly import the Postman
![](../../assets/api_6.jpg)

Reference: [Import data into Postman](https://learning.postman.com/docs/getting-started/importing-and-exporting/importing-data/).

## Exception

During RpcServer execution, when errors occur in request handling, contract execution, transaction validation, or other processes, exception codes and corresponding messages are thrown. These exceptions help developers quickly diagnose issues and take appropriate action. The exception codes and messages are as follows:

- Error codes prefixed with `-32xxx` typically relate to the RPC protocol itself, such as parsing errors, invalid requests, or methods not found. [See specification](https://www.jsonrpc.org/specification).
- Error codes prefixed with `-1xx` generally involve unknown entities, such as unknown blocks, contracts, transactions, or state roots.
- Error codes prefixed with `-3xx` pertain to wallet operations, mainly indicating issues like insufficient funds or incorrect wallet states.
- Error codes prefixed with `-5xx` are related to transactions and memory pool operations, indicating issues like transaction validation failures, duplicate transactions, or insufficient network fees.
- Error codes prefixed with `-6xx` are mostly associated with access control, state management, and Oracle services, indicating denied operations or disabled services.

The following table lists all error codes and corresponding messages. For more information, refer to Error Codes in [NEP-23](https://github.com/neo-project/proposals/blob/master/nep-23.mediawiki#user-content-Error_codes).

| code | message |
| :----- | :------------------------------------- |
| -32700 | Parse error |
| -32600 | Invalid Request |
| -32601 | Method not found |
| -32602 | Invalid params |
| -32603 | Internal error |
| -101 | Unknown block |
| -102 | Unknown contract |
| -103 | Unknown transaction |
| -104 | Unknown storage item |
| -105 | Unknown script container |
| -106 | Unknown state root |
| -107 | Unknown session |
| -108 | Unknown iterator |
| -109 | Unknown height |
| -300 | Insufficient funds in wallet |
| -301 | Wallet fee limit exceeded |
| -302 | No opened wallet |
| -303 | Wallet not found |
| -304 | Wallet not supported |
| -500 | Inventory verification failed |
| -501 | Inventory already exists |
| -502 | Memory pool capacity reached |
| -503 | Already in pool |
| -504 | Insufficient network fee |
| -505 | Policy check failed |
| -509 | Invalid transaction script |
| -507 | Invalid transaction attribute |
| -508 | Invalid signature |
| -509 | Invalid inventory size |
| -510 | Expired transaction |
| -511 | Insufficient funds for fee |
| -512 | Invalid contract verification function |
| -600 | Access denied |
| -601 | State iterator sessions disabled |
| -602 | Oracle service disabled |
| -603 | Oracle request already finished |
| -604 | Oracle request not found |
| -605 | Not a designated oracle node |
| -606 | Old state not supported |
| -607 | Invalid state proof |
| -608 | Contract execution failed |


4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/dumpprivkey.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Before you can invoke this method you must:

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

## Exception

- -302, No opened wallet.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/findstorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul
- The Base64-encoded storage key prefix as the second element
- Optional, start index as the third element

## Exception

- -102, Unknown contract.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getblock.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul
* When verbose is false, serialized information of the block is returned in a Base64-encoded string. If you need the detailed information, use SDK for deserialization.
* When verbose is true or 1, detailed information of the block is returned in Json format.

## Exception

- -101, Unknown block.

## Example

**Example 1 - Get serialized information of the block**
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getblockhash.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul

index: Block index (block height)

## Exception

- -109, Unknown height.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getblockheader.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul
* When verbose is false, serialized information of the block is returned in a hexadecimal string. If you need the detailed information, use the SDK for deserialization.
* When verbose is true or 1, detailed information of the block is returned in Json format.

## Exception

- -101, Unknown block.

## Example

**Example 1 - invoke with block hash**
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getcontractstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul
| RoleManagement | -8 | 0x49cf4e5378ffcd4dec034fd98a174c5491e395e2 |
| OracleContract | -9 | 0xfe924b7cfe89ddd271abaf7210a80a7e11178758 |

## Exception

- -102, Unknown contract.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getnewaddress.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Before you can invoke this method you must:

:::

## Exception

- -302, No opened wallet.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getrawtransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul
* When verbose is false, serialized information of the block is returned in a Base64-encoded string. If you need the detailed information, use the SDK for deserialization.
* When verbose is true or 1, detailed information of the block is returned in Json format string.

## Exception

- -103, Unknown transaction.

## Example

Request body:
Expand Down
5 changes: 5 additions & 0 deletions docs/n3/reference/rpc/getstorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul

* key: The key to look up in storage (Base64-encoded)

## Exception

- -102, Unknown contract.
- -104, Unknown storage item.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/gettransactionheight.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul

txid: Transaction id.

## Exception

- -103, Unknown transaction.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getwalletbalance.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Gas is 0xd2a4cff31913016155e38e474a2c06d08be276cf

You can query asset ID using the [CLI command](../../node/cli/cli.md) `list asset` or using the blockchain browser.

## Exception

- -302, No opened wallet.

## Example

:::note
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/getwalletunclaimedgas.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Before you can invoke this method you must:

:::

## Exception

- -302, No opened wallet.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/importprivkey.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Before you can invoke this method you must:

key: The WIF-format private key.

## Exception

- -302, No opened wallet.

## Example

Request body:
Expand Down
14 changes: 10 additions & 4 deletions docs/n3/reference/rpc/invokecontractverify.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,35 @@ Invokes the contract method `Verify`. Unlike the method `invokefunction` which e
- allowedcontracts: contracts of the signature can take effect, if scopes is CustomContracts
- allowedgroups: pubkeys of the signature can take effect, if scopes is CustomGroups


:::note
You need to use the proper byte order of the address passed according to its data type. If the data type is Hash160, use the big endian script hash; if the data type is ByteArray, use the little endian scripthash.
:::

For example:

```json
{
"type": "String",
"value": "Hello"
}

{
"type": "Hash160",
"value": "0xf621168b1fce3a89c33a5f6bcf7e774b4657031c"
}

{
"type": "ByteArray",
"value": "7472616e73666572"
}
```

## Exception

- -102, Unknown contract.
- -512, Invalid contract verification function.

## Example

Request body:
Expand Down
4 changes: 4 additions & 0 deletions docs/n3/reference/rpc/listaddress.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Before you can invoke this method you must:

:::

## Exception

- -302, No opened wallet.

## Example

Request body:
Expand Down
6 changes: 6 additions & 0 deletions docs/n3/reference/rpc/openwallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul
- path: The wallet file path
- password: In plain text.

## Exception

- -303, Wallet not found.
- -304, Wallet not supported.
- -600, Access denied.

## Example

Request body:
Expand Down
6 changes: 6 additions & 0 deletions docs/n3/reference/rpc/sendfrom.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Before you can invoke this method you must:
* value: Transfer amount
* signers: The signature account of transaction

## Exception

- -301, Wallet fee limit exceeded.
- -302, No opened wallet.
- -511, Insufficient funds for fee.

## Example

Request body:
Expand Down
6 changes: 6 additions & 0 deletions docs/n3/reference/rpc/sendmany.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Before you can invoke this method you must:

* `signers`: The signature account of transaction

## Exception

- -301, Wallet fee limit exceeded.
- -302, No opened wallet.
- -511, Insufficient funds for fee.

## Example

Request text:
Expand Down
14 changes: 13 additions & 1 deletion docs/n3/reference/rpc/sendrawtransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul

transaction: A Base64-encoded string that has been serialized after the transaction signed in the program.

## Example
## Exception

- -500, Inventory verification failed.
- -501, Inventory already exists.
- -502, Memory pool capacity reached.
- -503, Already in pool.
- -505, Policy check failed.
- -506, Invalid transaction script.
- -507, Invalid transaction attribute.
- -508, Invalid signature.
- -509, Invalid inventory size.
- -510, Expired transaction.
- -511, Insufficient funds for fee.

Request body:

Expand Down
6 changes: 6 additions & 0 deletions docs/n3/reference/rpc/sendtoaddress.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ Before you can invoke this method you must:

* value: Amount transferred

## Exception

- -301, Wallet fee limit exceeded.
- -302, No opened wallet.
- -511, Insufficient funds for fee.

## Example

Request body:
Expand Down
14 changes: 14 additions & 0 deletions docs/n3/reference/rpc/submitblock.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ You must install the plugin [RpcServer](https://github.com/neo-project/neo-modul

base64: A Base64-encoded string of a serialized block.

## Exception

- -500, Inventory verification failed.
- -501, Inventory already exists.
- -502, Memory pool capacity reached.
- -503, Already in pool.
- -505, Policy check failed.
- -506, Invalid transaction script.
- -507, Invalid transaction attribute.
- -508, Invalid signature.
- -509, Invalid inventory size.
- -510, Expired transaction.
- -511, Insufficient funds for fee.

## Example

Request body:
Expand Down
6 changes: 6 additions & 0 deletions docs/n3/reference/rpc/traverseiterator.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Gets the Iterator value from `session` and `Iterator id` returned by [invokefunc
>
> The validity of the `session` and `iterator id` is set by `SessionExpirationTime` in the `config.json` file of the `RpcServer` plug-in, in seconds.
## Exception

- -107, Unknown session.
- -108, Unknown iterator.
- -601, State iterator sessions disabled.

## Example

Request body:
Expand Down

0 comments on commit ab61d2a

Please sign in to comment.