credible-std, then test them with pcl before deployment. You can develop them independently or work with our forward deployed engineers to define and implement the policies.
Prerequisites
Have the protocol source, contract interfaces or storage layouts, and a local project with PCL installed. If you are new to assertion testing, first run the starter tutorial.Set Up Your Project
Keep assertion contracts inassertions/src/ and their tests in assertions/test/. Pin the credible-std version used by your project and confirm that your target deployment supports the assertion specification you choose. See the library reference and published releases.
Define the Policy and Its Exceptions
Describe the behavior your policy should reject and the legitimate operations it must allow. Identify:- The protected contracts, assets, and execution paths.
- The property being checked, including units, thresholds, and any measurement window.
- Approved exceptions, such as migrations, ownership transfers, or large withdrawals.
Implement the Assertion
Inherit fromAssertion and register the assertion functions in triggers(). For Reshiram assertions, call registerAssertionSpec(AssertionSpec.Reshiram) in the constructor.
Match the trigger to the property:
- Use
registerTxEndTriggerfor a property that must hold after the complete transaction. - Use
registerFnCallTriggerfor a check around each matching function call. Its call context is available throughph.context(). - Use the supported token-change or cumulative-flow triggers when the policy concerns token movements or rolling limits.
_preTx() and _postTx() identify transaction boundaries; _preCall() and _postCall() identify call boundaries. Read values through ph.loadStateAt or ph.staticcallAt, and derive storage slots from the actual contract layout.
Keep each assertion focused on one property. Check helper mutability when calling it from a view function, and decode events and calldata according to the protocol’s interfaces. Use Triggers, the Cheatcodes Reference, and your pinned library source for exact signatures.
Test Allowed and Rejected Transactions
UseCredibleTest and register the assertion with cl.assertion(...) immediately before the monitored external call. Select the assertion test profile defined in your project’s foundry.toml; see profile configuration. With that profile selected, run:
Review and Deploy
After the local tests pass, prepare a release withpcl apply. Choose the intended environment explicitly, then review and authorize the prepared release. Use Alerting to observe policy behavior, investigate unexpected rejections, and retest changes before production.
Your team controls policy deployment through its authorized signers. See Managing Policy Deployments for authorization. Ethereum protection also requires the agreed guard and routing integration.
