Wallet and signer policy layers are in early access. Talk to us if you’d like to participate.
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: { walletId } for the wallet layer, or { shareSetId } for the caller’s own signer layer.
Wallet-Layer
Usescope: { walletId }, where walletId is the wallet’s verifiedCredentialId. Only the wallet owner can set this layer.
- JavaScript
- React
Signer-Layer
Usescope: { shareSetId } to set rules for the caller’s own signer. A wallet account has one own share set that signs transactions, and it can also have other active share sets, such as delegated access.
- JavaScript
- React
A
shareSetId is the current identifier for a signer. It rotates when the wallet shares are refreshed or reshared, so do not store it. Re-read walletAccount.shareSetId before each update.Read rules
getPolicy fetches a layer and converts the underlying rules back into a PolicyRules map. Rules with fields that PolicyRules does not include go into unmapped, so they are never silently dropped.
- JavaScript
- React
Remove rules
removePolicyRules removes the rules for one or more PolicyRules keys in one batch. Pass the keys to remove in the rules array.
- JavaScript
- React
Who can update a rule
Business accounts extend this: an owner or admin can also manage every wallet and signer in the account, plus an account-wide layer that applies to all of them. See business account policies.
Next steps
Policy Layers
How environment, wallet, and signer rules combine.
Business account policies
The extra account-layer rule for business-account wallets.