diff --git a/Makefile b/Makefile index 28d1f8642..e0d85b568 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ devtools: go install mvdan.cc/gofumpt@latest go install github.com/rakyll/statik@v0.1.7 go install github.com/pacviewer/jrpc-gateway/protoc-gen-jrpc-gateway@v0.3.2 - go install github.com/pacviewer/jrpc-gateway/protoc-gen-jrpc-doc/cmd/protoc-gen-jrpc-doc@v0.1.7 ######################################## ### Building diff --git a/www/grpc/buf/json-rpc-md.tmpl b/www/grpc/buf/json-rpc-md.tmpl index aef588647..bf2f37433 100644 --- a/www/grpc/buf/json-rpc-md.tmpl +++ b/www/grpc/buf/json-rpc-md.tmpl @@ -10,7 +10,57 @@ All the amounts and values in gRPC endpoints are in NanoPAC units, which are atomic and the smallest unit in the Pactus blockchain. Each PAC is equivalent to 1,000,000,000 or 109 NanoPACs. -

JSON-RPC Services

+## Example + +To call JSON-RPC methods, you need to create the JSON-RPC request: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "pactus.network.get_node_info", + "params": {} +} +``` + +> Make sure you always add the `params` field, even if no parameters are needed, and ensure you use curly braces. + +Then you use the `curl` command to send the request to the node: + +```bash +curl --location 'http://localhost:8545/' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "id": 1, + "method": "pactus.network.get_node_info", + "params": {} +}' +``` + +> Before sending the request, you need to enable the JSON-RPC service inside the +> [configuration](/get-started/configuration/). + +### Using Basic Auth + +If you have enabled the [gRPC Basic Authentication](/tutorials/grpc-sign-transactions/), +then you need to set the `Authorization` header. + +```bash +curl --location 'http://localhost:8545/' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Basic ' \ +--data '{ + "jsonrpc": "2.0", + "id": 1, + "method": "pactus.blockchain.get_account", + "params": { + "address": "pc1z2r0fmu8sg2ffa0tgrr08gnefcxl2kq7wvquf8z" + } +}' +``` + +

JSON-RPC Methods