Typescript SDK
Objective
Installation
$ npm install @bloxroute/solana-trader-client-tsUsage
import {
MAINNET_API_GRPC_PORT,
MAINNET_API_NY_GRPC,
GrpcProvider,
GetRecentBlockHashRequest,
loadFromEnv
} from "@bloxroute/solana-trader-client-ts";
// Calls to provider must be made inside async function
async function main(): Promise<void> {
try {
// Load configuration from environment variables
const config = loadFromEnv();
// Initialize the GrpcProvider with necessary credentials and endpoint
const provider = new GrpcProvider(
config.authHeader,
config.privateKey,
`${MAINNET_API_NY_GRPC}:${MAINNET_API_GRPC_PORT}`,
true
);
// Prepare the request for fetching the recent block hash
const request: GetRecentBlockHashRequest = {};
// Fetch the recent block hash from the provider
const response = await provider.getRecentBlockHash(request);
// Log the response
console.info("Recent Block Hash Response: ");
console.info(JSON.stringify(response, null, 2));
} catch (error) {
console.error("Error fetching recent block hash:", error);
}
}
// Execute the main function
main();Last updated