Full lesson
agentbond
What it does
From the project README:
[](https://solana.com) [](https://explorer.solana.com/address/5foUTphb99ztvEknWcEc5fNhvUsGx77pUiSsJi36d1L3?cluster=devnet) [](https://arena.colosseum.org/hackathon) [](LICENSE)
- Original
- DiveshK007/agentbond
- SuperStack fork
- Blockchains/agentbond @
c958d9f - Stars
- 0
- Last push (original)
- 2026-06-26
- Languages
- TypeScript, Rust, CSS, JavaScript, Shell
- Detected stack
- @solana/kitAnchorMetaplexNext.jsweb3.js
- Categories
- AI & Agents
- Licence
- MIT
- Homepage
- https://agentbond-three.vercel.app
Architecture
124 source files. By extension: .ts ×63, .tsx ×50, .rs ×11.
| Top-level directory | Source files |
|---|---|
app | 57 |
api | 17 |
agent_bond | 16 |
elizaos-plugin | 9 |
sdk | 9 |
bots | 8 |
scripts | 6 |
mcp | 2 |
On-chain programs: agent_bond/programs/agent_bond
Dapp: devnet deploy pending
⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/agentbond/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.
Key code, explained
Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.
agent_bond/programs/agent_bond/src/instructions/resolution.rs L13–36 @ c958d9f · MIT · original mut, seeds = [b"job", job.job_index.to_le_bytes().as_ref()], bump = job.bump, constraint = job.status == 1 @ AgentBondError::JobNotAssigned, constraint = job.agent == agent_owner.key() @ AgentBondError::NotAssignedAgent, )] pub job: Account<'info, Job>, #[account(mut)] pub agent_owner: Signer<'info>,} pub fn submit_result(ctx: Context<SubmitResult>, result_hash: [u8; 32]) -> Result<()> { let clock = Clock::get()?; require!( clock.unix_timestamp <= ctx.accounts.job.deadline, AgentBondError::DeadlinePassed ); ctx.accounts.job.result_hash = result_hash; ctx.accounts.job.status = 2; emit!(events::ResultSubmitted { job_index: ctx.accounts.job.job_index,- Line 14
seeds = [b"job", job.job_index.to_le_bytes().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 15
bump = job.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 22
pub agent_owner: Signer<'info>,: Requires this account to have signed the transaction. - Line 26
let clock = Clock::get()?;: Reads on-chain time from the Clock sysvar. - Line 27
require!(: An explicit validation that aborts the instruction with an error. - Line 35
emit!(events::ResultSubmitted {: Emits an Anchor event that clients can parse from the logs.
agent_bond/programs/agent_bond/src/instructions/job.rs L217–240 @ c958d9f · MIT · original #[account( seeds = [b"bid", job.key().as_ref(), agent_pubkey.as_ref()], bump = bid.bump, )] pub bid: Account<'info, Bid>, #[account(mut)] pub poster: Signer<'info>, pub system_program: Program<'info, System>,} pub fn assign_agent(ctx: Context<AssignAgent>, agent_pubkey: Pubkey) -> Result<()> { let clock = Clock::get()?; let reward = ctx.accounts.job.reward; let agent_stake = ctx.accounts.agent_profile.stake; let collateral = reward.min(agent_stake / 10); ctx.accounts.agent_profile.locked_stake = ctx.accounts.agent_profile.locked_stake .checked_add(collateral).ok_or(AgentBondError::Overflow)?; let job = &mut ctx.accounts.job;- Line 219
seeds = [b"bid", job.key().as_ref(), agent_pubkey.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 220
bump = bid.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 225
pub poster: Signer<'info>,: Requires this account to have signed the transaction. - Line 231
let clock = Clock::get()?;: Reads on-chain time from the Clock sysvar. - Line 234
let agent_stake = ctx.accounts.agent_profile.stake;: Touches staking state: the amount locked and when it was locked. - Line 238
.checked_add(collateral).ok_or(AgentBondError::Overflow)?;: Uses checked arithmetic so overflow fails instead of wrapping.
agent_bond/programs/agent_bond/src/instructions/admin.rs L13–35 @ c958d9f · MIT · original seeds = [b"protocol"], bump = protocol_config.bump, constraint = protocol_config.admin == admin.key() @ AgentBondError::NotAdmin, )] pub protocol_config: Account<'info, ProtocolConfig>, #[account(mut)] pub admin: Signer<'info>,} pub fn update_fee(ctx: Context<UpdateFee>, new_fee_bps: u16) -> Result<()> { require!(new_fee_bps <= 1000, AgentBondError::InvalidFeeBps); let old = ctx.accounts.protocol_config.platform_fee_bps; ctx.accounts.protocol_config.platform_fee_bps = new_fee_bps; emit!(events::FeeUpdated { old_fee_bps: old, new_fee_bps, }); Ok(())}- Line 13
seeds = [b"protocol"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 14
bump = protocol_config.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 20
pub admin: Signer<'info>,: Requires this account to have signed the transaction. - Line 24
require!(new_fee_bps <= 1000, AgentBondError::InvalidFeeBps);: An explicit validation that aborts the instruction with an error. - Line 29
emit!(events::FeeUpdated {: Emits an Anchor event that clients can parse from the logs.
agent_bond/programs/agent_bond/src/instructions/agent.rs L73–96 @ c958d9f · MIT · original profile.status = 0; profile.bump = ctx.bumps.agent_profile; system_program::transfer( CpiContext::new( ctx.accounts.system_program.to_account_info(), system_program::Transfer { from: ctx.accounts.owner.to_account_info(), to: ctx.accounts.stake_vault.to_account_info(), }, ), stake_amount, )?; ctx.accounts.protocol_config.total_agents = ctx.accounts.protocol_config.total_agents .checked_add(1).ok_or(AgentBondError::Overflow)?; emit!(events::AgentRegistered { owner: ctx.accounts.owner.key(), name: name_bytes, stake: stake_amount, }); Ok(())- Line 74
profile.bump = ctx.bumps.agent_profile;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 77
CpiContext::new(: Makes a cross-program invocation into another program. - Line 88
.checked_add(1).ok_or(AgentBondError::Overflow)?;: Uses checked arithmetic so overflow fails instead of wrapping. - Line 90
emit!(events::AgentRegistered {: Emits an Anchor event that clients can parse from the logs. - Line 93
stake: stake_amount,: Touches staking state: the amount locked and when it was locked.
How to run, build and test
These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.
| Directory | Command | Runs |
|---|---|---|
elizaos-plugin | npm run dev | tsc --watch |
elizaos-plugin | npm run build | tsc |
agent_bond | npm run lint | prettier */*.js "*/**/*{.js,.ts}" --check |
api | npm run dev | ts-node server.ts |
api | npm run start | ts-node server.ts |
mcp | npm run dev | ts-node src/server.ts |
mcp | npm run start | node dist/server.js |
mcp | npm run build | tsc |
sdk | npm run dev | tsc --watch |
sdk | npm run build | tsc |
app | npm run dev | next dev |
app | npm run start | next start |
app | npm run build | next build |
app | npm run lint | eslint |
agent_bond | anchor build | compile programs and generate IDLs |
agent_bond | anchor test | local validator + test suite |
What you could build from it
- Fork the SuperStack copy and extend it within the AI & Agents gaps listed on the idea page.
- Learn the pattern first: AI agents on Solana
- Learn the pattern first: Building and sending transactions from a client