Running Spells
How to take a spell from validation through simulation to live onchain execution.
The Execution Pipeline
Every spell goes through the same safety pipeline:
validate → simulate → cast --dry-run → castEach step adds more confidence before you commit real value.
Validate
grimoire validate spells/my-strategy.spellChecks that the spell compiles, types are correct, and structural rules pass. No chain connection needed.
Simulate (Preview)
grimoire simulate spells/my-strategy.spell \
--chain 1 \
--rpc-url YOUR_RPC_URLRuns the full spell logic against live protocol data. The runtime plans all actions, evaluates constraints, and produces a receipt — but nothing is submitted onchain.
The receipt shows:
- Planned actions and their parameters
- Constraint evaluation results
- Expected value movements
- Status:
readyorrejected
Dry-Run Cast
grimoire cast spells/my-strategy.spell \
--dry-run \
--key-env PRIVATE_KEY \
--rpc-url YOUR_RPC_URLThis runs the full pipeline including wallet signing, but does not submit the transaction. Use this to verify everything works end-to-end before going live.
Live Cast
grimoire cast spells/my-strategy.spell \
--key-env PRIVATE_KEY \
--rpc-url YOUR_RPC_URLWithout --dry-run, this runs preview and then commits — submitting transactions onchain.
Wallet Setup
Grimoire manages wallets through its own keystore.
Generate a new wallet:grimoire wallet generategrimoire wallet import --key-env PRIVATE_KEYgrimoire wallet address
grimoire wallet balance --chain 1 --rpc-url YOUR_RPC_URLgrimoire wallet wrap --amount 0.1 --chain 1 --rpc-url YOUR_RPC_URL
grimoire wallet unwrap --amount 0.1 --chain 1 --rpc-url YOUR_RPC_URLSimulation on a Fork
For thorough testing, you can simulate against a local Anvil fork:
# Start Anvil fork
anvil --fork-url YOUR_RPC_URL --fork-block-number 12345678
# Run against the fork
grimoire simulate spells/my-strategy.spell \
--chain 1 \
--rpc-url http://127.0.0.1:8545Reviewing Results
After any run:
# List all runs
grimoire history
# Show detailed event ledger for the last run
grimoire log --last
# Show a specific run
grimoire log --run-id <id>Parameter Overrides
Override default spell parameters at runtime:
grimoire simulate spells/my-strategy.spell \
--chain 1 \
--params '{"amount": 5000}'Cross-Chain Execution
For spells that span multiple chains:
grimoire cast spells/bridge-and-swap.spell \
--key-env PRIVATE_KEY \
--rpc-url YOUR_RPC_URL \
--destination-chain 8453 \
--destination-spell spells/swap-on-base.spell