# gRPC Server
gRPC Server is a node extension that allows running gRPC services on a node. gRPC interaface can be used to run apps on your own node.
gRPC services provide information about:
You can run gRPC Server on a light-node.
# Client Generation
The clients generated from proto files are used to connect to gRPC services.
Example of usage of gRPC client generated from .proto files: Retrieving blocks in C#
To create a TypeScript or JavaScript client, we recommend using the node-api-grpc library.
# gRPC Server Installation
The gRPC Server extension can be installed on the node by two methods: using DEB package or TGZ archive.
# Installation via DEB Package
Download the latest version of the DEB package from the Releases page (Assets section).
The extension package name is as follows:
• for Mainnet
grpc-server_{version number}_all.deb
• for Testnet
grpc-server-testnet_{version number}_all.deb
• for Stagenet
grpc-server-stagenet_{version number}_all.deb
Install the package.
Mainnet:
sudo dpkg -i grpc-server_{version number}_all.deb
Testnet:
sudo dpkg -i grpc-server-testnet_{version number}_all.deb
Stagenet:
sudo dpkg -i grpc-server-stagenet_{version number}_all.deb
Edit the node configuration file as described in the Node Configuration article. For Mainnet, the configuration file is located at
/etc/waves/waves.conf
, for Testnet at/etc/waves-testnet/waves.conf
, for Stagenet at/etc/waves-stagenet/waves.conf
.3.1. Add gRPC Server to the
waves.extensions
section:waves { ... extensions = [ com.wavesplatform.api.grpc.GRPCServerExtension ] }
3.2. If you want to change the port for client connection (default is 6870), add the following setting:
waves { ... grpc { port = 6877 # Specify port }
3.3. If you need to provide external access to your node's grpc server, use Nginx’s proxy pass module or SSH port forwarding.
An easier, but not recommended way is to add the following setting:
waves { ... grpc { ... host = 0.0.0.0 # Specify IP address }
Restart the node.
Mainnet:
sudo systemctl restart waves
Testnet:
sudo systemctl restart waves-testnet
Stagenet:
sudo systemctl restart waves-testnet
# Installation via TGZ Archive
Download the TGZ archive with the extension from the Releases page (Assets section) on Github.
The TGZ archive name is as follows:
• for Mainnet
grpc-server-{version number}.tgz
• for Testnet
grpc-server-testnet-{version number}.tgz
• for Stagenet
grpc-server-stagenet-{version number}.tgz
Unpack the archive to the directory containing node's JAR-file.
Create a new configuration file or open the existing one, see the Node Configuration article.
3.1. Add gRPC Server to the
waves.extensions
section:waves { ... extensions = [ com.wavesplatform.api.grpc.GRPCServerExtension ] }
3.2. If you want to change the port for client connection (default is 6870), add the following setting:
waves { ... grpc { port = 6877 # Specify port }
Run the command:
Mainnet
java -cp 'waves-all-{version number}.jar:grpc-server-{version number}/lib/*' com.wavesplatform.Application {configuration file name}.conf
Testnet:
java -cp 'waves-all-{version number}.jar:grpc-server-testnet-{version number}/lib/*' com.wavesplatform.Application {configuration file name}.conf
Stagenet:
java -cp 'waves-all-{version number}.jar:grpc-server-stagenet-{version number}/lib/*' com.wavesplatform.Application {configuration file name}.conf
On Windows, use
;
instead of:
, for example:java -cp 'waves-all-{version number}.jar;grpc-server-{version number}/lib/*' com.wavesplatform.Application {configuration file name}.conf
# gRPC on Public Nodes
You can connect to the public gRPC services provided by the Waves team for getting acquainted:
- Mainnet: nodes.wavesnodes.com:6870
- Testnet: nodes-testnet.wavesnodes.com:6870
- Stagenet: nodes-stagenet.wavesnodes.com:6870
Limitations:
- The maximum number of simultaneous requests per IP address is 5.
- The maximum number of the requests per second (r/s) from IP address is 20.
# Debugging with gRPCurl
gRPCurl is a command-line tool that lets you interact with gRPC servers. It's basically curl
for gRPC servers. You can use gRPCurl to make requests to the gRPC Server of the Waves node and get data in a command-line interface, without writing any code.
gRPCurl usage:
Get the list of services
Example request:
grpcurl -plaintext nodes.wavesnodes.com:6870 list
Example response:
grpc.reflection.v1alpha.ServerReflection waves.node.grpc.AccountsApi waves.node.grpc.AssetsApi waves.node.grpc.BlockchainApi waves.node.grpc.BlocksApi waves.node.grpc.TransactionsApi
Get the list of service functions
grpcurl -plaintext nodes.wavesnodes.com:6870 describe waves.node.grpc.AssetsApi
service AssetsApi { rpc GetInfo ( .waves.node.grpc.AssetRequest ) returns ( .waves.node.grpc.AssetInfoResponse ); rpc GetNFTList ( .waves.node.grpc.NFTRequest ) returns ( stream .waves.node.grpc.NFTResponse ); }
Get the description of a message
grpcurl -plaintext nodes.wavesnodes.com:6870 describe waves.node.grpc.AssetRequest
waves.node.grpc.AssetRequest is a message: message AssetRequest { bytes asset_id = 1; }
Request the gRPC server
Specify the
-d
parameter and arguments in JSON.grpcurl -plaintext \ -d '{ "asset_id": "PFrWEj4csGLWzPmlsjs/xccLxChfBm27mGoHZtYJSzU=" }' \ nodes.wavesnodes.com:6870 waves.node.grpc.AssetsApi/GetInfo
{ "issuer": "+DXhXpxJzivkcqVUIh0dPuze4ThmLFnYVutb7RRxrSs=", "name": "DogWhite", ... "sequenceInBlock": 1, "issueHeight": 2563608 }
⚠️ All byte arrays in JSON must be base64 encoded, including addresses, asset IDs, and other data that are base58 encoded in the Node REST API. The response also contains base64 encoded data.