Skip to content

rafiulhc/grpc-blockchain-endpoints

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


A gRPC server and client (server streaming) that will listen and send requests through the gRPC protocol with requirements

Built With versions

  • go1.18.3
  • gRPC
  • Protocol Buffer : libprotoc 3.21.1
  • grpcurl.exe dev build
  • GNU Make 4.3

Getting Started

To get a local copy up and running follow these simple steps.

  1. Clone the repo
git clone https://github.com/rafiulhc/grpc-blockchain-endpoints.git
  1. Install required packages mentioned above

To get executable binaries, please open a terminal under project directory and run

make grpc

Run local server

MAC or Linux
./bin/grpc/server

for windows
./bin/grpc/server.exe

Make request from client to get block data

MAC or Linux
./bin/grpc/client

for windows
./bin/grpc/client.exe

Response from server with 5 block data and created a JSON file with Block height and Hash

grpc

From CLI using grpcurl

To list all services exposed by a server, use the "list" verb.

grpcurl -plaintext localhost:50051 list

It will list the gRPC service in the project

grpcurl

The "list" verb also lets us see all methods in a particular service:

grpcurl -plaintext localhost:50051 list grpc.GetLatestBlockService

Describe with

grpcurl -plaintext localhost:50051 describe grpc.GetLatestBlockService.GetLatestBlock

GETlATESTbLOCK

Invoking gRPC

Invoking an RPC on a trusted server (e.g. TLS without self-signed key or custom CA) that requires no client certs and supports server reflection is the simplest thing to do with grpcurl. This minimal invocation sends an empty request body:

grpcurl -plaintext localhost:50051 grpc.GetLatestBlockService.GetLatestBlock

invoke gRPC

Testing

  go test

After running the command in terminal if block from gRPC call and direct API call match, should show the tests results....

Tests

License

None

Contact

Rafiul Hasan - Linkedin Twitter - rafiul.hasan.chowdhury@gmail.com

Project Link: https://github.com/rafiulhc/grpc-blockchain-endpoints

(back to top)

Releases

No releases published

Packages

No packages published