Use when a user provides a smart contract address and wants to generate a reusable SKILL.md file for interacting with that contract through keypo-wallet. Analyzes verified contracts by fetching their ABI, categorizes functions, and outputs a complete agent skill file with verified addresses, function signatures, calldata encoding instructions, and keypo-wallet execution commands. Also use when a user says "make a skill for this contract", "generate a skill", or "I want to interact with this contract using keypo-wallet". Requires Foundry (cast) to be installed.
Given a deployed smart contract address, this skill generates a complete, portable SKILL.md file that teaches any agent how to interact with that contract using keypo-wallet as the execution backend.
This skill does not execute transactions itself. It produces SKILL.md files that do.
Before doing anything else, resolve these two dependencies. Do not proceed until both are confirmed.
Foundry's cast is required. Check for it in this order:
# Check PATH first
which cast 2>/dev/null || \
# Foundry's default install location
ls ~/.foundry/bin/cast 2>/dev/null || \
echo "CAST_NOT_FOUND"
If found at ~/.foundry/bin/cast, use the full path for all commands in this skill (e.g., ~/.foundry/bin/cast call ...). Set a variable for convenience:
CAST=$(which cast 2>/dev/null || echo ~/.foundry/bin/cast)
If not found at either location, tell the user to install Foundry: curl -L https://foundry.paradigm.xyz | bash && foundryup
An Etherscan API key is required to fetch contract ABIs. Check for it immediately:
echo $ETHERSCAN_API_KEY
If the variable is set, use it silently — do not print it or include it in any output.
If empty, tell the user to set it in their shell environment. Do not ask them to paste the key into the chat — keys entered in conversation are stored in chat history and may be synced or logged. Instead, instruct them:
Please set your Etherscan API key as an environment variable before proceeding.
Add this to your ~/.zshrc (or ~/.bashrc) and restart your terminal:
export ETHERSCAN_API_KEY="your-key-here"
Free keys are available at https://etherscan.io/myapikey and work across all chains.
Then re-run this command.
Do not proceed without the key. Do not attempt to fetch ABIs without a key — it will fail.
The user provides:
0x... (42 characters, required)Map the user's chain input to a chain ID and RPC URL:
| Chain | Chain ID | RPC URL | Explorer API Base |
|---|---|---|---|
| Ethereum | 1 | https://eth.llamarpc.com | https://api.etherscan.io/v2/api?chainid=1 |
| Base | 8453 | https://mainnet.base.org | https://api.etherscan.io/v2/api?chainid=8453 |
| Base Sepolia | 84532 | https://sepolia.base.org | https://api.etherscan.io/v2/api?chainid=84532 |
| Arbitrum | 42161 | https://arb1.arbitrum.io/rpc | https://api.etherscan.io/v2/api?chainid=42161 |
| Optimism | 10 | https://mainnet.optimism.io | https://api.etherscan.io/v2/api?chainid=10 |
| Polygon | 137 | https://polygon-rpc.com | https://api.etherscan.io/v2/api?chainid=137 |
| Sepolia | 11155111 | https://rpc.sepolia.org | https://api.etherscan.io/v2/api?chainid=11155111 |
Only use the Etherscan API to fetch ABIs. Never try to scrape or fetch block explorer web pages (basescan.org, etherscan.io, etc.) — they return 403 errors and HTML, not ABI data.
Use cast interface with the API key:
$CAST interface <address> --chain <chain-id> --etherscan-api-key $ETHERSCAN_API_KEY
If cast interface fails, fall back to the Etherscan V2 REST API:
curl -s "https://api.etherscan.io/v2/api?chainid=<chain-id>&module=contract&action=getabi&address=<address>&apikey=$ETHERSCAN_API_KEY"
The response JSON has result containing the ABI as a JSON string. Parse it to get the function list.
If the contract is not verified: Stop and tell the user. You cannot generate a skill for an unverified contract. They can provide the ABI manually as a JSON file.
If the contract is a proxy: Detect proxy patterns (implementation(), upgradeTo()). Follow the proxy to the implementation:
$CAST call <proxy-address> "implementation()(address)" --rpc-url <rpc-url>
$CAST interface <implementation-address> --chain <chain-id> --etherscan-api-key $ETHERSCAN_API_KEY
Use the proxy address in the generated skill (that's what users send transactions to) but note it's a proxy in the skill's description.
Before generating the skill, collect these details using read calls:
# For tokens — try these, they may revert on non-token contracts
$CAST call <address> "name()(string)" --rpc-url <rpc-url>
$CAST call <address> "symbol()(string)" --rpc-url <rpc-url>
$CAST call <address> "decimals()(uint8)" --rpc-url <rpc-url>
# Verify the contract has code deployed
$CAST code <address> --rpc-url <rpc-url>
If name/symbol return values, this is likely a token contract. Include the decimals value in the generated skill — this is critical for correct amount encoding.
From the ABI, sort functions into three groups:
view or pure, these require keypo-wallet to executeview or pure, these use cast call directly--value flagProduce a SKILL.md file following the output template below. Replace all <placeholders> with actual values from the contract analysis. Remove any sections that don't apply (e.g., remove the Payable section if there are no payable functions).
Write the file to ./<skill-name>/SKILL.md.
The generated SKILL.md must follow this structure exactly. This ensures consistency across all generated skills and compatibility with keypo-wallet.
---