Connection

Establish a connection to NextBlock's gRPC API using Tonic.

This page shows the connection pattern and authentication interceptor. Replace the placeholder generated client type with the client generated from nextblock-protoarrow-up-right.

Prerequisites

Add these dependencies to your Cargo.toml:

[dependencies]
tonic = "0.10"
tokio = { version = "1.0", features = ["full"] }
solana-sdk = "1.17"
solana-client = "1.17"
base64 = "0.21"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rand = "0.8"

# Add your generated proto dependencies here
# nextblock-proto = { path = "./generated" }

Connection Setup

Usage Example

Connection Best Practices

  1. Use TLS in production: Always enable TLS for production environments

  2. Configure keepalive: HTTP/2 keepalive helps maintain persistent connections

  3. Set appropriate timeouts: Configure timeouts based on your use case

  4. Handle authentication: Use the interceptor pattern for API key authentication

  5. Error handling: Implement proper error handling and retry logic

Available Endpoints

  • Frankfurt: frankfurt.nextblock.io (Europe)

  • Amsterdam: amsterdam.nextblock.io (Europe)

  • London: london.nextblock.io (Europe)

  • Singapore: singapore.nextblock.io (Asia)

  • Tokyo: tokyo.nextblock.io (Asia)

  • New York: ny.nextblock.io (US East)

  • Salt Lake City: slc.nextblock.io (US West)

  • Dublin: dublin.nextblock.io (Europe)

  • Vilnius: vilnius.nextblock.io (Europe)

Environment Configuration

Last updated