Skip to content

Latest commit

 

History

History
93 lines (67 loc) · 2.28 KB

File metadata and controls

93 lines (67 loc) · 2.28 KB

AGENTS.md - OpenAI Agents Guide

This file provides context for OpenAI-based AI agents working with this CKB smart contract template.

Repository Purpose

Build and deploy smart contracts on CKB (Nervos) blockchain using TypeScript via ckb-js-vm runtime.

Key Actions

1. Create New Contract

pnpm run add-contract <contract-name>

Creates contracts/<name>/src/index.ts and test files.

2. Build Contracts

pnpm run build              # All contracts
pnpm run build:contract <n> # Specific contract

3. Test Contracts

pnpm test                   # All tests
pnpm test -- <name>         # Specific tests

4. Deploy Contracts

pnpm run deploy -- --network devnet|testnet|mainnet

Contract Code Pattern

import * as bindings from '@ckb-js-std/bindings';
import { log } from '@ckb-js-std/core';

function main(): number {
  // Load script info
  const script = bindings.loadScript();
  
  // Validation logic
  // Return 0 = success, non-zero = failure
  
  return 0;
}

bindings.exit(main());

Important Files

Path Purpose
contracts/*/src/index.ts Contract source code
tests/*.mock.test.ts Unit tests (no node)
tests/*.devnet.test.ts Integration tests
deployment/scripts.json Deployed contract info
app/ Next.js frontend
.skills/ AI skill patterns (Agent Skills format)

CKB-Specific APIs

  • bindings.loadScript() - Current script
  • bindings.loadCell(idx, src) - Load cell
  • bindings.loadCellData(idx, src) - Cell data
  • bindings.exit(code) - Exit contract

Constraints

  • No Node.js APIs in contracts (no fs, http, etc.)
  • No async/await in contract code
  • Must call bindings.exit() at end
  • Return 0 for validation success

AI Skills

The .skills/ folder contains structured patterns following the Agent Skills Open Standard:

Skill Purpose
ckb-contract-patterns Smart contract patterns for ckb-js-vm
ckb-ccc-frontend Frontend integration with CCC library

Reference SKILL.md in each skill folder for detailed patterns.

See Also

  • CLAUDE.md for detailed documentation
  • .skills/ for structured AI skill patterns
  • .cursorrules for code patterns