Massa GRPC API

Through the API documentation, you can find out how to make calls and handle responses.

  • gRPC API: used for blockchain interactions. Default port: 33037 e.g. grpc://localhost:33037

Find the complete Massa gRPC specification here.

Note

We provide the generated API documentation which documents every available methods in gRPC Massa service.

Warning

Massa gRPC support is experimental. This API is not yet stable and may change in the future.

To enable gRPC support in your Massa node, edit file massa-node/config/config.toml (or create it if absent) with the following contents:

[api]
   # whether to broadcast for blocks, endorsement and operations
   enable_broadcast = true
[grpc]
    # whether to enable gRPC
    enabled = true

The complete gRPC configuration is available in node configuration .

Integrations

Postman: is a tool for software developers to create, test and debug API requests. More details can be found in Postman learning center. Find all maintained Massa Postman collections in our official workspace.

Code generation

Step 1: Download the `massa-proto` folder from GitHub

  1. Go to the GitHub repository for massa.

  2. Click the green Code button and select Download ZIP to download the entire repository as a ZIP file.

  3. Extract the ZIP file to a folder on your computer.

  4. Navigate to the massa-proto folder, which contains the .proto files we’ll be using to generate gRPC clients.

Step 2: Install Buf CLI

  1. Download the latest version of Buf CLI from the official website.

  2. Extract the downloaded file to a folder on your computer.

  3. Add the buf binary to your system PATH environment variable.

Step 3: Set up Buf

  1. Create a new file called buf.work.yml

  2. Add the following content:

version: v1
directories:
    - proto/massa/api/v1
    - proto/third-party

By specifying the directories in the configuration file, Buf knows which .proto files to include in the build process.

  1. Create another file called buf.gen.yml in the massa-proto folder.

  2. Add the following content to buf.gen.yml:

version: v1
managed:
  enabled: true
plugins:
  - remote: buf.build/stephenh/plugins/ts-proto
    out: gen/ts
    opt:
      - outputServices=...
      - useExactTypes=...

This tells Buf to use the official ts-proto plugin to generate gRPC client in TypeScript.

Note

The complete list of official Buf plugins.

Step 4: Generate gRPC client in TypeScript

  1. Open a command prompt or terminal window and navigate to the massa-proto folder.

  2. Run the following command to generate the gRPC clients:

buf generate

This will generate the gRPC client in a new gen/ts folder in the massa-proto folder.

Note

More information about gRPC in developer documentation.