Quickstart

Get Brain running in under five minutes. This guide walks you through installation, account setup, and deploying your first agent.

circle-info

Brain runs primarily on Base for low-cost execution, and uses Ethereum as a settlement and identity anchor. Make sure you have a funded wallet on Base before proceeding.

1

Step 1: Install the Brain SDK

npm install @brain-protocol/sdk
2

Step 2: Initialize a Client

import { BrainClient } from '@brain-protocol/sdk';

const client = new BrainClient({
  rpcUrl: 'https://mainnet.base.org',
  bundlerUrl: 'https://api.alchemy.com/bundler/...',
  signerKey: process.env.SIGNER_PRIVATE_KEY,
});
3

Step 3: Create a Brain Smart Account

const account = await client.accounts.create({
  owner: '0xYourEOAAddress',
});

console.log('Account deployed at:', account.address);
4

Step 4: Deploy an Agent

const agent = await client.agents.deploy({
  accountAddress: account.address,
  name: 'my-first-agent',
  metadataUri: 'ipfs://Qm...',
  policy: {
    spendLimit: '100 USDC/day',
    allowedAssets: ['USDC', 'ETH'],
    timeWindow: '00:00-23:59 UTC',
  },
});

console.log('Agent ID:', agent.agentId);
5

Step 5: Fund the Agent and Run

// Transfer 10 USDC to the agent's execution account
await client.accounts.fund({
  agentId: agent.agentId,
  asset: 'USDC',
  amount: '10',
});

// Execute an action — policy is automatically enforced
const result = await agent.execute({
  target: '0xContractAddress',
  calldata: encodedCalldata,
});
circle-check

Next Steps

Last updated