Walkthrough 1: Freelancer Payment

An end-to-end example of vericoding with ICME PreFlight and Certora.

A complete example of vericoding in practice. One freelancer payment policy becomes two enforcement layers: runtime guardrails that check every agent action, and a formally verified smart contract on-chain.


You tell your agent: "I need a logo designed. Budget is 500. Find someone good."

A freelancer tells their agent: "I'm available for design work. Accept jobs that pay at least 400."

The two agents find each other, negotiate, and agree on terms. Your agent deposits 500 into escrow. The freelancer's agent submits the completed work. Your agent approves and releases payment.

You never touched a smart contract. You never read a line of code. You just got your logo and the freelancer got paid.

But what actually happened under the hood? How do you know your agent didn't overpay? How does the freelancer know the payment can't be clawed back after delivery? How does either side know the escrow contract itself is correct?

That's where the two rule sets come in. One governs what the agents can do. The other guarantees the contract they interact through is correct. Both are generated from the same English policy.


Two rule sets from one policy

The developer building this agent workflow writes the policy once in plain English. PreFlight compiles it into two enforcement layers.

Rule Set 1: Agent Guardrails. Controls what each agent is allowed to do, in real time. Before your agent releases payment, the guardrail checks: is this the right agent? Is there a dispute? Is the amount correct? If any rule is violated, the action is blocked before it reaches the chain. The agent never has the opportunity to go off the rails.

Rule Set 2: Smart Contract. Controls what the contract enforces permanently on-chain. The contract is formally verified before deployment. A theorem prover has already checked every possible input, every state, every sequence of calls. Even if an agent finds a way around the guardrail and calls the contract directly, the contract itself will reject any invalid transaction.


Step 1: Compile the guardrail rules

These rules govern what each agent can do at runtime. Every action is checked against these before execution.

curl -s -N -X POST https://api.icme.io/v1/makeRules \
  -H 'Content-Type: application/json' \
  -H "X-API-Key: $ICME_API_KEY" \
  -d '{
    "policy": "1. Only the client agent can release payment to the freelancer.\n2. Only the client agent can file a dispute.\n3. Only the freelancer agent can submit completed work.\n4. If a dispute is active, no agent can release payment.\n5. If more than 14 days have passed since the payment was deposited, no agent can file a dispute.\n6. No agent can release payment to any address other than the designated freelancer.\n7. No agent can withdraw more than the original payment amount."
  }'

Save the policy_id from the response. This is your guardrail policy.


Step 2: Compile the contract rules

These rules define what the smart contract enforces on-chain. They describe the same policy from the contract's perspective.

Save this policy_id as well. You now have two policy IDs: one for runtime guardrails and one for the on-chain contract.


Step 3: Test the guardrails

Before going to production, verify the guardrails catch what they should. Each checkIt call runs the action through three independent solvers and returns a ZK proof receipt.

Client releases payment (should be allowed):

Expected: SAT. The client is authorized. No dispute. Within the time window.

Freelancer tries to release payment (should be blocked):

Expected: UNSAT. Only the client can release payment.

Release during active dispute (should be blocked):

Expected: UNSAT. Dispute is active, no releases allowed.

Filing a dispute after the deadline (should be blocked):

Expected: UNSAT. Disputes cannot be filed after 14 days.

Withdrawing more than the original payment (should be blocked):

Expected: UNSAT. Withdrawal cannot exceed the original deposit.


Step 4: Generate the verified smart contract

Closed beta. Contract generation from SMT policies is currently in closed beta. Contact [email protected] for access.

Once you have access, generate a formally verified Solidity contract directly from your policy:

The response contains a verified Solidity contract and a Certora CVL specification. The contract is mathematically proven to satisfy every rule in your policy before it's returned. Ready for deployment on any EVM chain (Ethereum, Base, Arbitrum, etc.).


The generated contract

This contract was generated from the English policy above and formally verified by the Certora Prover. Every rule is mathematically proven to hold for all possible inputs.

solidity


The formal verification spec

Each rule from the English policy maps to a CVL rule that is mathematically proven by the Certora Prover. The comments reference the original rule IDs from the compiled policy.


Why two rule sets?

The two rule sets are not checking the same thing.

Rule Set 1 asks: "Should this agent do this right now?" Your agent wants to release payment. Before it can, the guardrail checks: is this the client's agent? Is there an active dispute? Has the deadline passed? Is the recipient the right freelancer? This happens in real time, off-chain, on every single action. If any rule is violated, the agent is stopped before it touches the chain.

Rule Set 2 asks: "Can this contract ever behave incorrectly?" The smart contract is verified once, before deployment. A theorem prover mathematically proves it can never violate the policy. No matter what any agent sends it. No matter what order the calls come in. No matter what the inputs are. This isn't a test suite. It's a mathematical proof.

You need both because agents are unpredictable. The guardrail keeps your agent on the rails in real time. The contract guarantees the execution layer is sound even if an agent goes around the guardrail entirely. Neither layer trusts the other. Neither layer trusts the agents.


Where the ZK proofs fit

Every time an agent's action is checked, PreFlight returns a ZK proof receipt:

json

This is cryptographic evidence that the guardrail checked the action and approved it. The freelancer's agent can verify this proof without re-running the solver, without seeing your policy, and without trusting PreFlight. It just checks the math.

Here's what actually happens when you say "pay the freelancer":

Three layers of proof. The guardrail approved the action. The contract executed it correctly. The contract itself was proven correct before deployment. The ZK proof lets the other side verify the guardrail check without trusting anyone.

You got your logo. The freelancer got paid. Neither of you read a smart contract. Neither of you trusted the other's agent. The math handled it.


Try it yourself

Steps 1 through 3 are available today with any PreFlight API key. Write your policy, compile it, and test it with checkIt.

Step 4, generating formally verified smart contracts from your policy, is in closed beta. If you're building agents that handle real value on-chain, reach out for early access.

Email [email protected] or reach out on X

Last updated