Skip to content

Commit 9a49078

Browse files
committed
Add indexer endpoints
1 parent 37d16de commit 9a49078

File tree

5 files changed

+482
-39
lines changed

5 files changed

+482
-39
lines changed

README.md

Lines changed: 131 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sequence Builder CLI
22

3-
CLI for Sequence Builder - designed for AI agents and automation. Create wallets, authenticate, manage projects, and send transactions from the command line.
3+
CLI for Sequence Builder - designed for AI agents and automation. Create wallets, authenticate, manage projects, query blockchain data, and send transactions from the command line.
44

55
## Quick Start
66

@@ -21,22 +21,22 @@ sequence-builder --help
2121

2222
```bash
2323
# 1. Generate a wallet
24-
npx @0xsequence/builder-cli create-wallet
24+
npx @0xsequence/builder-cli create-wallet --json
2525

2626
# 2. Store the private key securely (shown in output)
2727

28-
# 3. Fund the wallet with native token for gas fees
29-
30-
# 4. Login with your private key
28+
# 3. Login with your private key
3129
npx @0xsequence/builder-cli login -k <your-private-key>
3230

33-
# 5. Create a project
31+
# 4. Create a project and get your access key
3432
npx @0xsequence/builder-cli projects create "My Project"
3533

36-
# 6. Get your API keys
37-
npx @0xsequence/builder-cli apikeys <project-id>
34+
# 5. Get your Sequence wallet address (where to send tokens)
35+
npx @0xsequence/builder-cli wallet-info -k <private-key> -a <access-key>
36+
37+
# 6. Fund the Sequence wallet with tokens
3838

39-
# 7. Send an ERC20 transfer
39+
# 7. Send an ERC20 transfer (gas paid with same token!)
4040
npx @0xsequence/builder-cli transfer \
4141
-k <private-key> \
4242
-a <access-key> \
@@ -48,16 +48,36 @@ npx @0xsequence/builder-cli transfer \
4848

4949
## Commands
5050

51-
| Command | Description |
52-
| ------------------------------ | ---------------------------------------------------------------- |
53-
| `create-wallet` | Generate new EOA keypair, display private key and wallet address |
54-
| `login -k <key>` | Authenticate with private key, get JWT |
55-
| `projects` | List all projects |
56-
| `projects create [name]` | Create new project |
57-
| `projects get <id>` | Get project details |
58-
| `apikeys <project-id>` | List API keys |
59-
| `apikeys default <project-id>` | Get default API key |
60-
| `transfer` | Send ERC20 transfer |
51+
| Command | Description |
52+
|---------|-------------|
53+
| `create-wallet` | Generate new EOA keypair |
54+
| `wallet-info` | Show EOA and Sequence wallet addresses |
55+
| `login -k <key>` | Authenticate with private key |
56+
| `projects` | List all projects |
57+
| `projects create [name]` | Create new project |
58+
| `projects get <id>` | Get project details |
59+
| `apikeys <project-id>` | List API keys |
60+
| `apikeys default <project-id>` | Get default API key |
61+
| `transfer` | Send ERC20 transfer via Sequence wallet |
62+
| `indexer balances <address>` | Get token balances |
63+
| `indexer native-balance <address>` | Get native token balance |
64+
| `indexer history <address>` | Get transaction history |
65+
| `indexer token-info <contract>` | Get token contract info |
66+
67+
## Understanding Wallet Addresses
68+
69+
This CLI uses **Sequence Smart Wallets** for transfers. When you create a wallet, you get:
70+
71+
- **EOA Address**: The standard Ethereum address derived from your private key (used for login/project ownership)
72+
- **Sequence Wallet Address**: A smart contract wallet that enables gas-free transactions (used for transfers)
73+
74+
Use `wallet-info` to see both addresses:
75+
76+
```bash
77+
npx @0xsequence/builder-cli wallet-info -k <private-key> -a <access-key>
78+
```
79+
80+
**Important**: Send tokens to the **Sequence Wallet Address** for use with the `transfer` command. The Sequence wallet can pay gas fees with ERC20 tokens (no native token needed!).
6181

6282
## Create Wallet
6383

@@ -76,10 +96,27 @@ Private Key: 0x4c0883a69102937d6231471b5dbb6204fe512961708279f9f4e7d1b3e6d1e3a1
7696
Address: 0x89D9F8f31817BAdb5D718CD6fb483b71DbD2dfeD
7797
7898
IMPORTANT: Store these credentials securely. They will not be shown again.
99+
```
100+
101+
## Wallet Info
102+
103+
Show both EOA and Sequence wallet addresses:
104+
105+
```bash
106+
npx @0xsequence/builder-cli wallet-info -k <private-key> -a <access-key>
107+
```
108+
109+
Output:
79110

80-
To use this wallet:
81-
1. Fund it with native token for gas fees
82-
2. Run: sequence-builder login -k <your-private-key>
111+
```
112+
Wallet Addresses:
113+
114+
EOA Address: 0x742BDb3bEEB7aDCe50294665a7388ADB7519a6eA
115+
Sequence Wallet: 0xA715064b5601Aebf197aC84A469b72Bb7Dc6A646
116+
117+
Important:
118+
Send tokens to the Sequence Wallet address for use with the transfer command.
119+
The Sequence Wallet can pay gas fees with ERC20 tokens (no ETH needed).
83120
```
84121

85122
## Login
@@ -113,6 +150,7 @@ npx @0xsequence/builder-cli projects create "My Game"
113150
Options:
114151

115152
- `--chain-ids <ids>` - Comma-separated list of chain IDs
153+
- `-k, --private-key <key>` - Show Sequence wallet address in output
116154

117155
### Get Project Details
118156

@@ -136,16 +174,16 @@ npx @0xsequence/builder-cli apikeys default 12345
136174

137175
## Transfer (ERC20)
138176

139-
Send an ERC20 token transfer:
177+
Send an ERC20 token transfer using Sequence smart wallet:
140178

141179
```bash
142180
npx @0xsequence/builder-cli transfer \
143181
-k 0x4c0883a... \
144182
-a AQAAAAAAAABnD... \
145-
-t 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 \
183+
-t 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
146184
-r 0x1234567890123456789012345678901234567890 \
147185
-m 10.5 \
148-
-c 137
186+
-c 8453
149187
```
150188

151189
Options:
@@ -157,6 +195,60 @@ Options:
157195
- `-m, --amount <amount>` - Amount to send in token units (required)
158196
- `-c, --chain-id <chainId>` - Chain ID (required)
159197

198+
**Note**: Gas fees are automatically paid using the same token you're transferring (e.g., transfer USDC, pay gas in USDC). No native token (ETH/MATIC) needed!
199+
200+
## Indexer Commands
201+
202+
Query blockchain data using Sequence Indexer.
203+
204+
### Get Token Balances
205+
206+
```bash
207+
npx @0xsequence/builder-cli indexer balances <address> \
208+
-a <access-key> \
209+
-c <chain-id> \
210+
--include-metadata
211+
```
212+
213+
### Get Native Token Balance
214+
215+
```bash
216+
npx @0xsequence/builder-cli indexer native-balance <address> \
217+
-a <access-key> \
218+
-c <chain-id>
219+
```
220+
221+
### Get Transaction History
222+
223+
```bash
224+
npx @0xsequence/builder-cli indexer history <address> \
225+
-a <access-key> \
226+
-c <chain-id> \
227+
--limit 20
228+
```
229+
230+
### Get Token Info
231+
232+
```bash
233+
npx @0xsequence/builder-cli indexer token-info <contract-address> \
234+
-a <access-key> \
235+
-c <chain-id>
236+
```
237+
238+
## Supported Networks
239+
240+
| Network | Chain ID |
241+
|---------|----------|
242+
| Ethereum | 1 |
243+
| Polygon | 137 |
244+
| Base | 8453 |
245+
| Arbitrum | 42161 |
246+
| Optimism | 10 |
247+
| BSC | 56 |
248+
| Avalanche | 43114 |
249+
250+
See all supported networks at [Sequence Status](https://status.sequence.info/).
251+
160252
## JSON Output Mode
161253

162254
All commands support `--json` flag for machine-readable output:
@@ -165,6 +257,7 @@ All commands support `--json` flag for machine-readable output:
165257
npx @0xsequence/builder-cli projects --json
166258
npx @0xsequence/builder-cli apikeys 12345 --json
167259
npx @0xsequence/builder-cli create-wallet --json
260+
npx @0xsequence/builder-cli indexer balances <address> -a <key> -c 8453 --json
168261
```
169262

170263
Example JSON output:
@@ -178,16 +271,16 @@ Example JSON output:
178271

179272
## Exit Codes
180273

181-
| Code | Meaning |
182-
| ---- | ------------------- |
183-
| 0 | Success |
184-
| 1 | General error |
185-
| 10 | Not logged in |
186-
| 11 | Invalid private key |
187-
| 20 | Insufficient funds |
188-
| 30 | No projects found |
189-
| 31 | Project not found |
190-
| 40 | API error |
274+
| Code | Meaning |
275+
|------|---------|
276+
| 0 | Success |
277+
| 1 | General error |
278+
| 10 | Not logged in |
279+
| 11 | Invalid private key |
280+
| 20 | Insufficient funds |
281+
| 30 | No projects found |
282+
| 31 | Project not found |
283+
| 40 | API error |
191284

192285
## Configuration
193286

@@ -213,13 +306,14 @@ npx @0xsequence/builder-cli login -k <key> --api-url https://custom-api.example.
213306

214307
## Requirements
215308

216-
- Node.js 18+ (recommended)
309+
- Node.js 18+
217310

218311
## Local Development
219312

220313
```bash
221314
# Clone and install
222-
cd cli
315+
git clone https://github.com/0xsequence/builder-cli.git
316+
cd builder-cli
223317
pnpm install
224318

225319
# Run in development mode

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@0xsequence/builder-cli",
33
"version": "0.1.0",
4-
"description": "CLI for Sequence Builder - designed for AI agents and automation",
4+
"description": "CLI for Sequence Builder - manage wallets, projects, transfers, and query blockchain data. Designed for AI agents and automation.",
55
"main": "./dist/bin.js",
66
"type": "module",
77
"bin": {
@@ -26,7 +26,12 @@
2626
"wallet",
2727
"ethereum",
2828
"web3",
29-
"ai-agents"
29+
"ai-agents",
30+
"smart-wallet",
31+
"indexer",
32+
"erc20",
33+
"transfer",
34+
"blockchain"
3035
],
3136
"author": "Sequence Platforms Inc.",
3237
"license": "MIT",
@@ -52,6 +57,7 @@
5257
"dependencies": {
5358
"0xsequence": "2.3.39",
5459
"@0xsequence/auth": "2.3.39",
60+
"@0xsequence/indexer": "^2.3.39",
5561
"@0xsequence/network": "2.3.39",
5662
"@0xsequence/relayer": "2.3.39",
5763
"chalk": "^5.3.0",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {projectsCommand} from "./commands/projects.js";
99
import {apikeysCommand} from "./commands/apikeys.js";
1010
import {transferCommand} from "./commands/transfer.js";
1111
import {walletInfoCommand} from "./commands/wallet-info.js";
12+
import {indexerCommand} from "./commands/indexer.js";
1213

1314
const program = new Command();
1415

@@ -24,6 +25,7 @@ program.addCommand(loginCommand);
2425
program.addCommand(projectsCommand);
2526
program.addCommand(apikeysCommand);
2627
program.addCommand(transferCommand);
28+
program.addCommand(indexerCommand);
2729

2830
// Note: --json, --env, and --api-url are defined on each subcommand
2931
// This allows subcommands to properly receive and handle these options

0 commit comments

Comments
 (0)