Dynamic Store Challenges
Require transfer initiators to pass checks against dynamic stores. Typically, these are used in combination with smart contracts or other custom extensions.
Dynamic stores are standalone (address -> boolean) stores controlled by whoever creates them. They are stored and maintained by the creator. These are powerful for creating dynamic approval criteria with smart contracts and other custom use cases.
How It Works
Dynamic store challenges check if the transfer initiator has a value of true in specified dynamic stores. The system:
Checks Global Kill Switch: First checks if the dynamic store's
globalEnabledfield istrue. IfglobalEnabled = false, the approval fails immediately with error: "dynamic store storeId {id} is globally disabled"Checks Initiator: If the store is globally enabled, looks up the initiator's address in the specified dynamic store
Evaluates Boolean: Returns the boolean value for the initiator (or
defaultValueif not set)Requires All True: All challenges must return
truefor approvalFails if Any False: If any challenge returns
false, transfer is denied
Interface
interface DynamicStoreChallenge {
storeId: string; // Dynamic store ID to check
}Usage in Approval Criteria
{
"dynamicStoreChallenges": [
{ "storeId": "1" }, // Member store (must be true)
{ "storeId": "2" } // Subscription store (must be true)
]
}Global Kill Switch
Each dynamic store has a globalEnabled field that acts as a global kill switch. When globalEnabled = false, all approvals using that store via DynamicStoreChallenge will fail immediately, regardless of per-address values.
This is useful for quickly halting all approvals that depend on a specific dynamic store (e.g., if a protocol is compromised and needs to be disabled immediately).
Behavior
New stores:
globalEnableddefaults totrue(enabled by default)Existing stores: All existing stores are set to
globalEnabled = truefor backward compatibilityDisabling: Set
globalEnabled = falsevia MsgUpdateDynamicStore to halt all dependent approvalsRe-enabling: Set
globalEnabled = trueto restore normal operation
Usage Example
Managing Dynamic Stores
Creating Stores
Use MsgCreateDynamicStore to create new dynamic stores with a default boolean value. New stores are created with globalEnabled = true by default.
Updating Stores
Use MsgUpdateDynamicStore to update the store's defaultValue, globalEnabled, uri, and customData fields. The uri and customData fields allow storing additional metadata and arbitrary data associated with the store.
Setting Values
Use MsgSetDynamicStoreValue to set boolean values for specific addresses.
Querying Values
Use GetDynamicStoreValue to check current values for addresses.
Use GetDynamicStore to retrieve the store's configuration, including globalEnabled status, uri, and customData fields.
Alternatives
For fully off-chain solutions, consider:
Merkle Challenges to save gas costs
ETH Signature Challenges for direct authorization
Last updated