TypeScript client and schemas for the Helium Blockchain API
npm install @helium/blockchain-apiTypeScript client and schemas for the Helium Blockchain API.
``bash`
npm install @helium/blockchain-apior
yarn add @helium/blockchain-api
`typescript
import { apiContract } from "@helium/blockchain-api";
import { createORPCClient, onError } from "@orpc/client";
import { RPCLink } from "@orpc/client/fetch";
import { ContractRouterClient } from "@orpc/contract";
const link = new RPCLink({
url: "
headers: () => ({
//...
}),
// fetch: <-- provide fetch polyfill fetch if needed
interceptors: [
onError((error) => {
console.error(error);
}),
],
});
// Create a client using an imported contract
const client: ContractRouterClient
`
All Zod schemas are exported for direct use:
`typescript
import {
GetBalancesInputSchema,
TokenBalanceDataSchema,
} from "@helium/blockchain-api";
// Validate input
const input = GetBalancesInputSchema.parse({
walletAddress: userInput,
});
`
See https://orpc.dev/docs/client/error-handling
Typed error definitions are available:
`typescript`
import { INSUFFICIENT_FUNDS } from "@helium/blockchain-api";
- health - Health checktokens
- - Token balances and transfershotspots
- - Hotspot management and rewardsswap
- - Token swaps via Jupitertransactions
- - Transaction submission and trackingwelcomePacks
- - Welcome pack managementfiat
- - Fiat offramp and bank accountswebhooks` - Webhook handlers
-
Apache-2.0