FOUNDATIONS · QUICKSTART
Eight minutes, end to end.
From an empty repo to a live agent watching the market for you. We will install the SDK, connect a wallet, write an intent, summon an agent, and see the first cast settle.
Before you begin
You will need:
- A wallet on Base with at least 0.001 ETH for gas and 50 USDC for the example intent.
- Node.js 20+,
npm, andgit. - An RPC URL for Base. Alchemy, QuickNode, or the public
https://mainnet.base.orgall work.
Install the CLI
bash# Recommended
npm install -g @magicscodes/cli
# Or, for one-off use without install
npx @magicscodes/cli --help
# From source (for contributors)
git clone https://github.com/magics-codes/magics-cli.git
cd magics-cli
npm install && npm run build
npm linkConnect a wallet
magics is wallet-agnostic. It accepts any WalletClient from viem — the easiest path is RainbowKit + wagmi, the same stack this docs site uses.
If you already have a wagmi setup in your app, you can skip ahead. If not, the RainbowKit Getting Started guide takes about five minutes.
Write your first intent
An intent is a declarative goal with a budget and a fence around what the agent may do. Here is the simplest useful one:
typescriptimport { defineIntent, USDC, BASE } from "@magicscodes/sdk";
export const myFirstIntent = defineIntent({
goal: "Hold USDC on Base, maximize stable yield",
budget: { asset: USDC, amount: 100n * 10n ** 6n }, // 100 USDC
bounds: {
chains: [BASE],
venues: ["aave", "morpho"],
maxImpactBps: 30,
haltLossBps: 100,
},
cadence: { rebalanceEveryMin: 60 },
});That intent says: find me the best USDC yield on Base, within Aave or Morpho only, never move the market more than 30 bps, and halt entirely if my position drops 1%. Notice that nowhere did you specify how— that is the agent's job.
Summon an agent
Bind that intent to an agent. The Wraith of Yield is designed for exactly this shape of intent.
typescriptimport { summonAgent } from "@magicscodes/sdk";
import { wraithOfYield } from "@magicscodes/spells";
import { myFirstIntent } from "./intents";
const session = await summonAgent({
intent: myFirstIntent,
agent: wraithOfYield,
walletClient, // from wagmi useWalletClient()
});
console.log("Agent bound:", session.sealAddress);Your wallet will pop up a single signature request — the seal. Sign it. From that moment, the agent can act within your bounds, and only within your bounds.
Watch the cast
Open the app. Within a few seconds you should see an entry in the activity feed: Wraith of Yield · Rotated 100 USDC to Morpho · gas $0.003.
That is one full cycle. The agent will keep watching rates and recast whenever the edge is meaningful.