Business Accounts are in early access. See Business Accounts for the model.
- Environment-Layer: rules set by the developer for the whole environment. For how to set environment-wide rules, see Creating & Managing Rules in the general Policies & Rules guide.
- Account-Layer: one policy that applies to every wallet in the business account. Only a business-account owner or admin can edit it.
- Wallet-Layer: rules for a specific wallet. On a business-account wallet, only a business-account owner or admin can edit it.
- Signer-Layer: rules for an individual signer. A signer can edit their own layer; a business-account owner or admin can edit any signer’s layer.
The helpers on this page write legacy rules. A layer holds legacy rules or declarative rules, never both, and a write that would mix them is refused. To write declarative rules from the SDK, see Declarative rules for business accounts. For the underlying API, see the account layer, wallet layer, and signer layer pages, and for wallet and signer layers outside a business account, Manage declarative rules.
Before you start
Before this: create and initialize a Dynamic client (see Creating a Dynamic Client, Initializing the Dynamic Client). The policy helpers are exported from@dynamic-labs-sdk/client/waas and the matching React hooks are exported from @dynamic-labs-sdk/react-hooks.
PolicyRules keys
createPolicy and removePolicyRules work with a PolicyRules map. Each key maps to at most one underlying WaasPolicyRule, so calling createPolicy again with the same key updates that rule in place instead of duplicating it.
For the raw fields these keys produce, see Rule fields.
Create or update rules
createPolicy writes a PolicyRules map to a layer in one batch. The scope object decides which layer is updated. For a layer of declarative rules, use upsertAccountPolicyRule, upsertWalletPolicyRule, or upsertSignerPolicyRule instead; see Declarative rules for business accounts.
- JavaScript
- React
The policy layer to update. Use
{ businessAccountId } for the account layer, { walletId } for a wallet layer, { walletId, shareSetId } for a specific signer, or { shareSetId } for the caller’s own signer.The chain IDs the rules apply to. Omit this to target the wildcard rule that matches every chain ID for
chain.Account-Layer
Usescope: { businessAccountId } to apply rules to every wallet in the business account.
Wallet-Layer
Usescope: { walletId }, where walletId is the wallet’s verifiedCredentialId.
Signer-Layer
The signer layer applies to one share set. A wallet account has one own share set that signs transactions. It can also have other active share sets, such as delegated access and additional business-account signers.addBusinessAccountSigner returns the shareSetId of the signer it grants access to, so capture it when you add a signer. If adding the signer requires quorum approval, it returns a pending action instead. See Manage signers.
scope: { walletId, shareSetId }. For the caller’s own signer, scope: { shareSetId } also works if the wallet account is in the client’s state.
A
shareSetId is the current identifier for a signer. It rotates when the wallet shares are refreshed or reshared, so do not store it. The policy is bound to a stable signerId that the enclave mints, so a rotated shareSetId still points to the same policy. Re-read shareSetId before each update. A stale shareSetId is rejected with a stale-share-set error.scope with removePolicyRules or getPolicy.
Read rules
getPolicy fetches a layer and converts the underlying rules back into a PolicyRules map. Declarative rules are not part of that map; read them with readPolicyLayerRules as shown in Declarative rules for business accounts. Rules with fields that PolicyRules does not include go into unmapped, so they are never silently dropped.
A layer can also hold declarative rules — entries written in the phase / when / then shape rather than the legacy field-per-rule shape. isDeclarativePolicyRule (typed WaasPolicyDeclarativeRule) identifies them in a layer’s layerContent.rules, and the rule-by-rule helpers such as createPolicy, upsertWalletPolicyRule, and removePolicyRules skip them when matching. Declarative rules are not authored through these helpers: upsertAccountPolicyRule, upsertSignerPolicyRule, and upsertWalletPolicyRule throw InvalidParamError rather than send one.
A declarative rule can carry approvalRequirements typed WaasPolicyDeclarativeApprovalRequirement: the same fields as PolicyApprovalRequirement but without when, because the rule’s own when is the condition.
- JavaScript
- React
Remove rules
removePolicyRules removes the rules for one or more PolicyRules keys in one batch. To remove a declarative rule, remove it by ruleId; see Declarative rules for business accounts. Pass the keys to remove in the rules array.
- JavaScript
- React
The
PolicyRules keys to remove, for example ['allowAddresses', 'maxAmountPerTransaction'].Require approvals for a rule change
A governance requirement on theupdatePolicyLayer action holds a policy change for member approval, through the same proposal mechanism described in Approvals. Set the requirement with setBusinessAccountGovernance, then make the change with the update helper for the layer: updateBusinessAccountPolicyLayer for the account layer, updateWalletPolicyLayer for a wallet layer, or updateSignerPolicyLayer for a signer layer.
For the account layer, read the layer with getAccountPolicyLayer and pass it as layer, so the call signs an intent that binds the layer’s current digest. If the layer moved since the read, the call fails with a layer_changed error: read it again and propose again.
layer the change goes unsigned: it applies on an account that does not govern updatePolicyLayer, and throws BusinessAccountIntentRequiredError on one that does. Sign error.intent with signBusinessAccountIntent and retry the call, as in Handle BusinessAccountIntentRequiredError.
Passing layer is how you build the intent: updateBusinessAccountPolicyLayer constructs an updatePolicyLayer intent that binds the layer’s layerDigest and rbacVersion plus the exact request the approvers consent to, and signs it with the member’s session key. To sign an intent yourself, for example one a BusinessAccountIntentRequiredError returns, call signBusinessAccountIntent({ intent }) and pass the result as signedIntent. Sign the intent object verbatim: re-serializing or editing it invalidates the signature.
Wallet and signer layer edits always go the unsigned-first way: their layer reads carry no digest to bind up front, so the first call throws BusinessAccountIntentRequiredError on a governed account and the signed intent goes on the retry. Target the wallet with walletId, or with walletAccount when the caller holds it; walletId also reaches a wallet another member holds, such as an admin editing it. On updateSignerPolicyLayer, shareSetId names the signer to edit and defaults to the caller’s own.
updateWalletPolicyLayer takes the same shape without shareSetId.
The request takes the operations the write helpers send: upsert with rule, remove with ruleId, batch with operations, or replace with the full rules list. A governed change resolves to BusinessAccountActionRequired while approvals are missing. Approvers sign with approveBusinessAccountProposal, and the last approval applies the change unless the initiator set autoExecute: false. A held change completes with executeBusinessAccountProposal or a repeat call that passes proposalId.
Replace the whole rule list
replacePolicyLayerRules writes a layer’s complete list of rules in one call, so every rule left out of rules is removed, including rules another actor wrote. To add or change a single rule, prefer createPolicy or the upsertAccountPolicyRule, upsertWalletPolicyRule, and upsertSignerPolicyRule helpers, which leave every other rule alone. Use replacePolicyLayerRules to set the whole list at once, for example to move a layer from legacy rules to declarative rules.
Keep the ruleId of every rule you are keeping: a rule without a ruleId is a new rule and the backend generates its id. Concurrent writers are last-write-wins, and a layer that holds deletion markers — the records of removed rules that readPolicyLayerRules returns — can’t be replaced, because a replacement has no place for them; change such a layer rule by rule instead.
The layer’s full new list of rules, in one format only. A
PolicyRuleToUpsert is a legacy WaasPolicyRule, a declarative WaasPolicyDeclarativeRuleInput, or a stored WaasPolicyDeclarativeRule.APIError; branch on its code. Notable codes are rule_syntax_disabled (declarative rules are not enabled for the environment), composition_layer_edit_mixed_rule_syntax (the list mixes legacy and declarative rules), composition_layer_edit_deletion_marker_dropped (the layer holds deletion markers), composition_layer_edit_approval_requirement_actor_forbidden (the caller’s role can’t write approval rules), and composition_layer_edit_approval_rule_scope_forbidden (approval rules can’t go on this layer).
Declarative rules
A declarative rule has the shape{ phase, when, then, approvalRequirements }: phase is the stage the rule applies at, when is the condition, then is the action, and approvalRequirements lists the quorums required when the condition holds. buildRequireApprovalRule builds a transaction-phase rule whose then is REQUIRE_APPROVAL, and two helpers build the when condition: buildMinTransactionSpendCondition holds once a single transaction sends at least minAmount of one asset, and ALWAYS_POLICY_CONDITION holds for every transaction.
- JavaScript
- React
eligibleApproverRoles: ['admin'], using the built-in roles owner, admin, and viewer.
Read a layer’s raw entries
getAccountPolicyLayer, getWalletPolicyLayer, and getSignerPolicyLayer fetch a layer directly. Pass the response to readPolicyLayerRules to read its rule entries: legacy rules are decoded to WaasPolicyRule, while declarative rules (WaasPolicyDeclarativeRule) and deletion markers (PolicyRuleDeletionMarker) pass through unchanged, so no fields are lost. PolicyLayerRule is the union of the two live rule formats.
Who can update a rule
The enclave knows who makes the request. It uses that identity to decide which layers the caller can change and which rules they can edit or remove.Which layers each caller can change
What you can do to a rule
Every rule stores who created it. The enclave uses this to decide what you can change.- Rules you created: You can fully edit or remove them.
- Rules shared with you: A rule marked
modifiableBySignerlets the signer it applies to edit or remove the rule. The signer can change constraint fields, such as addresses and value limits. The signer cannot change security fields. - Rules created by someone else: Admins can revoke or replace these rules. Wallet owners and signers cannot edit or remove rules created by someone else, unless those rules are shared with them.
Guardrails
- A rule with security fields, such as
disableBlockaidSecurityChecksoroperationRestrictions, cannot also bemodifiableBySigner. modifiableBySigneronly works on wallet and signer layers.- A rule must enforce at least one of: an address list, a per-call value limit, or an operation restriction.
createPolicydoes not lock the layer before it updates. Two calls at the same time can create duplicate rules. Avoid concurrent updates to the same scope.
modifiableBySigner and disableBlockaidSecurityChecks, see upsertWalletPolicyRule and upsertSignerPolicyRule.
Rule fields
AWaasPolicyRule has the following fields:
For allowlist semantics, address evaluation, and value limits, see Policies & Rules.
These helpers do not expose
modifiableBySigner or disableBlockaidSecurityChecks. Use the lower-level upsertWalletPolicyRule or upsertSignerPolicyRule functions from @dynamic-labs-sdk/client/waas when you need those fields.Next steps
Declarative rules
Write declarative rules and approval rules on business-account layers.
Manage signers
Add and remove signers on a business-account wallet.
Sign transactions
Sign with a business-account wallet.