Skip to main content
This guide sets up the shared building blocks — chain definition, read/write clients, addresses, and ABIs — used by every other Robinhood Chain guide. The examples use viem, but the same calls translate directly to ethers or any EVM library.

Prerequisites

Before starting, make sure you have:
  • Node.js 18+ and a TypeScript project. If you’re starting fresh, follow the TypeScript & Node.js Setup Guide for the base project, then install the EVM dependencies below.
  • Some ETH on Robinhood Chain (chain ID 4663) in the wallet you’ll sign with.
  • Read the Robinhood Chain Overview for the token lifecycle and address book.
No Bags API key is required for Robinhood Chain. You interact with the public smart contracts directly.

1. Install Dependencies

2. Set Up Environment Variables

Create a .env file. The public RPC works out of the box but is rate-limited; set a dedicated endpoint if you have one.
Never commit your .env file. Add it to .gitignore. Treat your private key as a secret.

3. Define the Chain

Save this as chain.ts. It defines Robinhood Chain and tunes viem for the chain’s ~100 ms blocks.
chain.ts

4. Addresses & Protocol Constants

Save this as addresses.ts. These are the protocol singletons and shared infrastructure (see the full address book).
addresses.ts

5. Create the Clients

Save this as clients.ts. The public client is for reads and simulations; the wallet client signs and sends transactions.
clients.ts
In a browser dApp, replace getWalletClient with a wallet-backed client, e.g. createWalletClient({ account, chain: robinhoodChain, transport: custom(window.ethereum) }), and switch the wallet to chain 4663 before writing.

6. Get the ABIs

The Bags contract ABIs are published in the public robinhood-abi-v2 directory of the bagsfm/bags-idl repository. It contains eight JSON files:
  • BagsFactory.json, BagsBondingCurve.json, BagsFeeShare.json, BagsLens.json, BagsToken.json, BagsV4Hook.json, BagsVault.json, BagsBeacon.json
Import each JSON as an ABI, for example:
abi/index.ts
Import the full ABIs including their custom error definitions — viem uses them to decode revert reasons into readable errors (e.g. BagsBondingCurve_SlippageExceeded). See the Contracts Reference for the error catalog.

Periphery ABIs (hand-written)

The Uniswap-style infrastructure (UniversalRouter, Permit2, WETH, V4Quoter, StateView) is not part of the Bags ABI export. The Trade Tokens guide includes the minimal hand-written ABIs you need for post-migration swaps. The full definitions are also listed in the Contracts Reference.

7. Verify Your Setup

Read a value from the factory to confirm everything is wired up.
verify.ts
If you see the creation fee (default 0.02 ETH = 20000000000000000 wei) and a token count printed, you’re ready to move on.

Next steps

Launch a Token

Create a token through the BagsFactory.

Trade Tokens

Buy and sell across both phases.

Read State & Discover

Query state and list tokens with BagsLens.

Claim Creator Fees

Claim accrued fees from BagsFeeShare.