safe_module) grants its permission when the Safe enables the Safe adapter as a module. The owner revokes the permission with disableModule. See the Safe adapter and the Safe account flow.
Relayed and owner-sent execution
Each owner operation of a Safe is one Safe transaction. The client sends it in one of two ways.
The client reads the sponsorship before each operation. It never assumes it. A failed sponsorship read rejects the operation, with one exception:
disableSafeModule falls back to the owner-sent way (see below).
In the relayed way, the owner signs the SafeTx typed data (safeTxTypedData). The client then posts { network, account, execTransactionCalldata }. After the relay answers, the client waits up to 60 seconds for its own RPC to return the receipt (waitForRelayedTransaction). If the receipt does not arrive, confirmedBlock is null, and the method still resolves.
In the owner-sent way, the owner sends execTransaction to the Safe with the pre-validated signature (buildSafePreValidatedSignature). The Safe accepts it only because msg.sender is the owner, so there is no typed-data prompt. The client waits up to 180 seconds for the receipt. A reverted receipt rejects with Error("owner transaction <hash> reverted").
Anafi relays only Safe transactions whose calls are on its list. The list has enableModule and disableModule of the configured Safe adapter at the Safe, and commitDsl and commitDslDirect at the DSL registry that name that adapter. On a network with an off-ramp handler, the list also has the off-ramp setup calls of the Safe. The calls can be alone or in a MultiSend. Each transaction must have value, gasPrice and safeTxGas at 0, as the client builds them. The Anafi API refuses other calls. For another call, use executeSafeOwnerCalls with ownerSent: true. See the API reference for the status codes of the route.
Single-owner limits
The client signs and sends Safe transactions for a Safe with threshold 1 only. Before an owner operation it readsgetThreshold() and isOwner(eoa). It throws:
Error("Safe <safe> has threshold <n>; this client can submit only single-owner Safe transactions")when the threshold is not 1.Error("<eoa> is not an owner of Safe <safe>")wheneoais not an owner.
The arm flow
provisionPredictedSafe
eoa, or returns the Safe that exists.
Prompts: relayed 0, owner-sent 1 transaction (or 0 for
already_deployed).
stageDsl
commitStagedDsl.
What write changes
Order of work
- For
armof a Safe with no code:provisionPredictedSafe, thenonProvisioned. The later checks read at or above the provision block. - These checks, and the seal of the document, run at the same time:
adaptermust equaldelegationAdapters.safe, elseError("<adapter> is not this chain's configured Safe adapter").- The registry must list
adapter, elseError("<adapter> is not the live configured safe_module adapter"). - The adapter must admit the Safe (code hash and singleton), else
Error("<safe> is not a Safe admitted by adapter <adapter>"). - Threshold 1, and
eoais an owner (see single-owner limits). isModuleEnabled(adapter)decidesenableAdapter.- The seal reads
engineEncKey()and seals0x02 ‖ adapter ‖ parent ‖ salt ‖ yamlto the engine underdslSealInfo(network, safe).
POST /api/wallets/:safe/dsl/commit/stagewith{ sealed }.- The client checks the reply. The echoed adapter must equal
adapter. The echoed commitment must equaldslCommitment(salt, yaml).attestationValidUntilmust be in the future and at most 3600 seconds away. Each failed check throws anErrorthat starts withstageDsl:. - The client opens the sealed warnings of the engine. If they cannot be opened,
warningsis empty.
Return value: StagedSafeDsl
warnings holds findings that do not stop the commit, for example a rule that can never fire. Show them to the owner before the commit.
Throws
Prompts: 0, or the prompt of the provision for
arm of a Safe with no code when Anafi does not pay.
commitStagedDsl
- Throws
Error("commitStagedDsl: the engine's attestation over this staged document has lapsed; stage it again")whenattestationValidUntilUnixSecondsis now or earlier. - Builds the call
AnafiDslRegistry.commitDsl(commitment, validUntil, engineSig, adapter). - Reads the Safe
nonce(), at or abovestaged.minReadBlock, and reads the sponsorship. - Builds the Safe transaction. With
enableAdapter: true, it is a MultiSenddelegatecallof 2 calls:Safe.enableModule(adapter), thencommitDsl. Else it is one plain call ofcommitDsl. - Calls
onStep("safe")before the wallet prompt. - Relayed: the owner signs the
SafeTx, thenonSigned(), thenPOST /api/wallets/:safe/safe/sponsor_exec. Owner-sent: the owner sendsexecTransaction, andonSigned()runs when the wallet returns the hash.
The
commitDsl call reverts when the attestation deadline passes before inclusion, or when another commit landed since the stage. See the DSL registry.
armSafe
stageDsl with write: "arm", then commitStagedDsl. Use it for the first document of an account. The warnings of the stage are not returned. To show them before the commit, call the two methods yourself.
Prompts in order, worst case (Anafi does not pay): 1 deploy transaction, then 1 execTransaction. Best case (Anafi pays): 1 typed-data signature.
commitDslFromSafe
stageDsl with write: "update", then commitStagedDsl. The Safe must have enabled the adapter. Prompts: 1.
To pause all rules, commit a document with no rules (rules: {}). See update, pause and revoke.
readSafeModuleEnabled
Safe.isModuleEnabled(adapter). With options, the read is pinned under the retry rule.
enableSafeModule
Safe.enableModule(adapter), sent to the Safe itself. It commits no document. Use it to restore the permission after a disableSafeModule, with the same committed document.
Checks: adapter is delegationAdapters.safe, the registry lists it, the adapter admits the Safe, threshold 1, and eoa is an owner. Prompts: 1.
disableSafeModule
Safe.disableModule(prevModule, adapter). After it lands, the adapter is no longer a module of the Safe. See the Safe adapter.
- Checks that
adapterisdelegationAdapters.safeand that the adapter admits the Safe. It does not need the adapter to be live for an owner-sent revoke. - Reads the sponsorship. If that read fails, the client chooses the owner-sent way, so the revoke does not depend on the Anafi API. It then reads the native balance of
eoa:- If the balance read fails, it throws an
Errorthat says so. - If the balance is 0, it throws
Error("This deployment could not say whether it pays for the revoke, and owner <eoa> holds no gas to send it. Use the self-funded path instead: disable the module from the Safe itself, for example in its own wallet UI.").
- If the balance read fails, it throws an
- For a relayed revoke, the registry must list the adapter. Else it throws
Error("This deployment will not pay for the revoke because Safe adapter <adapter> is not live. Use the self-funded path instead: ..."). - Checks threshold 1 and that
eoais an owner. - Reads the module list with
getModulesPaginated(pages of 50, at most 20 pages) and finds the module beforeadapter. ThrowsError("<safe> does not have adapter <adapter> enabled")when the adapter is not in the list. - Sends the Safe transaction.
disableModule from the Safe in any Safe wallet.
executeSafeOwnerCalls
The method resolves with the verdict of the Safe in
success. It rejects on a reverted receipt of an owner-sent transaction. It does not check adapter or any other target: you are responsible for the calls.
waitForRelayedTransaction
null when the receipt did not arrive or had no valid block. It never rejects. The relay can read a node that is ahead of yours, so a read right after its answer can miss the write. This wait closes that gap. The client calls it after each relayed write.
Sponsorship
fetchWalletSponsorship(aa) returns { feesOn, sponsored }. The client relays an owner operation of a Safe when !feesOn || sponsored. See activity and fees.