@fidesbuild/sub
v0.2.1
Published
FIDES SUB-FIDES: scoped agent-to-agent delegation. An agent hands part of its FIDES to another agent, who can never exceed it.
Maintainers
Readme
@fidesbuild/sub
FIDES is a Transaction Builder for autonomous agents. SUB-FIDES is scoped agent-to-agent delegation: an agent working under a FIDES hands part of its authority to another agent, and the contract makes sure the child can never exceed the parent.
Get started
The fastest way to try it is the guided tour, which includes SUB-FIDES:
npm install @fidesbuild/sdk viem
npx @fidesbuild/sdk init
npm run delegatenpx @fidesbuild/sub prints this guide. In your own code:
npm install @fidesbuild/sub @fidesbuild/sdk viemimport { createSubClient, SubFidesKit, SubAgent } from "@fidesbuild/sub"
import { Fides, deployAccount } from "@fidesbuild/sdk"
const client = createSubClient({ chainId: 4663, rpc }) // V2 FIDES Accounts, which can delegate
// the owner signs a FIDES for agent A, on a V2 account
await deployAccount(client, owner, owner.address)
const parent = await (await Fides.create(client, { owner: owner.address, agent: agentA.address, expiry, limits, targets })).sign(owner)
// agent A hands agent B a slice: its own budget, contracts and expiry, inside A's
const sub = await SubFidesKit.sign(SubFidesKit.create(parent, { agent: agentB.address, spend: [{ asset: USDG, amount: 20_000000n }] }), agentA, client, parent)
// agent B acts on its own key, inside its slice
const b = new SubAgent({ client, parent, sub, agent: agentB, relayer })
await b.execute(await b.plan(actions))- A slice bigger than the parent, a contract or function the parent does not allow, or an expiry past the parent's is refused when the SUB-FIDES is made, and again by the contract.
- Everything a child spends also counts against the parent, so no set of children can exceed what the owner signed.
- The owner or the parent agent can revoke a child; revoking the parent stops every child.
- The child has its own nonces, and every action it takes traces back to the owner's signature.
Links
- Docs: https://fidesbuilder.xyz/docs
- App: https://fidesbuilder.xyz/app
MIT licensed.
