Integration Patterns
Shared dWallet Contracts
Shared dWallet contracts hold a dWallet capability and control signing through smart contract logic. This pattern is ideal for DAOs, treasuries, and any system that needs programmable, automated signing.
Overview
In this pattern:
- The contract owns the
DWalletCap - Uses public user share (shared mode) - network can sign without user interaction
- Contract logic controls who can sign and when
- Perfect for governance, treasuries, and automated systems
Already Have a Zero-Trust dWallet?
You can convert an existing zero-trust dWallet to shared mode using
request_make_dwallet_user_secret_key_shares_public(). This also works for imported key dWallets.
See Converting to Shared for details.
Architecture
Shared dWallet Flow
Create Shared dWallet
DKG with public user share
request_dwallet_dkg_with_public_user_secret_key_share()
▼
Contract Storage
DWalletCap
(stored in contract)
Presign Pool
Fee Balances
▼
▼
▼
Sign Without User
Contract controls signing
Business Logic
defines when to sign
Basic Implementation
Contract Structure
Initialization
Access Control
Signing Operation
DAO Treasury Example
A more complete example with voting:
Use Cases
1. Multi-Chain Treasury
A treasury that holds and manages assets across multiple chains:
2. Automated Trading Bot
A contract that signs trades based on oracle data:
3. Cross-Chain Bridge
A bridge contract that signs release transactions:
Best Practices
- Clear Access Control: Define who can sign and under what conditions
- Use Future Signing for Governance: Separate proposal creation from execution
- Maintain Presign Pool: Keep enough presigns for expected operations
- Emit Events: Track all signing operations for transparency
- Handle Failures: Plan for presign or signing failures
Next Steps
- See Presign Pool Management for managing presigns
- Check the Bitcoin Multisig Example for a complete implementation