Skill: Writing a Function
Project anatomy
my-function/
├── manifest.yaml # Inputs, ABIs, and metadata
├── src/
│ ├── function.ts # Your function logic (entry point)
│ └── types/ # Auto-generated by `mimic codegen`
│ ├── index.ts # Typed inputs
│ └── ERC20.ts # Generated ABI wrapper (one per ABI)
└── build/
├── function.wasm # Compiled output
└── manifest.json # Validated manifestManifest
version: 1.0.0
name: My Automation Function
description: Swaps USDC to ETH when balance exceeds a threshold.
inputs:
- chainId: uint32
- account: address
- tokenIn: address
- tokenOut: address
- threshold: uint256
- slippage: uint32
abis:
- ERC20: "./abis/ERC20.json"Function structure
Library reference (@mimicprotocol/lib-ts)
@mimicprotocol/lib-ts)Primitives
Tokens and amounts
Result type
Environment queries
Token price
Relevant token balances
EVM contract read (raw)
Native token balance
Account code
Subgraph query
Execution context
Generated ABI wrappers
Solidity
AssemblyScript
Intent builders
Transfer — move tokens between addresses
Swap — exchange tokens
EVM Call — execute contract functions
Common builder options
Method
Purpose
Persistent storage
Logging
EVM utilities
Putting it together — annotated example
Last updated