Installation
Install the HoodLayer TypeScript SDK and get it configured.
Requirements
| Requirement | Version |
|---|---|
| Node.js | 18.0 and up |
| TypeScript | 5.0 and up (optional, but worth using) |
| viem | 2.0 and up (for local account/key handling) |
Install the package
npm install @hoodlayerorg/sdk
Or with other package managers:
yarn add @hoodlayerorg/sdk
pnpm add @hoodlayerorg/sdk
TypeScript configuration
Type definitions come bundled with @hoodlayerorg/sdk, so there’s no separate @types package to install. Point your tsconfig.json at ES2020 or newer:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true
}
}
Environment variables
You can configure both the agent and provider SDKs directly in code, but environment variables keep credentials out of your source tree. Here’s the setup we recommend:
# .env
HOODLAYER_API_KEY=rk_live_...
CHAIN_NETWORK=mainnet
WALLET_PRIVATE_KEY=0x... # never commit this
import "dotenv/config";
import { HoodLayerProvider } from "@hoodlayerorg/sdk";
import { privateKeyToAccount } from "viem/accounts";
const hoodlayer = new HoodLayerProvider({
wallet: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`),
apiKey: process.env.HOODLAYER_API_KEY!,
network: process.env.CHAIN_NETWORK as "mainnet" | "testnet",
});
privateKeyToAccount turns a raw 0x-prefixed private key into a viem local account, which satisfies the SDK’s signer interface. Working with an embedded wallet provider (Privy, Dynamic, Turnkey)? Pass a compatible signer object instead. Details are in the Agent SDK reference.
Robinhood Chain RPC configuration
Out of the box, the SDK talks to the public Robinhood Chain RPC endpoint. Production workloads should point at a dedicated RPC node:
const agent = new HoodLayerAgent({
wallet: account,
network: "mainnet",
rpcUrl: "https://rpc.mainnet.chain.robinhood.com",
});
HoodLayer runs its own infrastructure against a hosted RPC endpoint. Any standard Robinhood Chain JSON-RPC endpoint will do.
Verifying the installation
import { HoodLayerAgent } from "@hoodlayerorg/sdk";
const agent = new HoodLayerAgent({ wallet: account, network: "testnet" });
const info = await agent.getInfo();
console.log(info.version); // e.g. "0.1.0"
console.log(info.network); // "testnet"
Next steps
- Work through the Quickstart and make your first payment
- Browse the complete Agent SDK or Provider SDK reference