Tutorial: Voting dWallet
Pre-Alpha Disclaimer: This is an early pre-alpha release for exploring the SDK and starting development only. There is no real MPC signing — all signatures are generated by a single mock signer, not a distributed network. Do not submit any real transactions for signing or rely on any security guarantees. The dWallet keys, trust model, and signing protocol are not final; do not rely on any key material until mainnet. All interfaces, APIs, and data formats are subject to change without notice. The Solana program and all on-chain data will be wiped periodically and everything will be deleted when we transition to Ika Alpha 1. This software is provided “as is” without warranty of any kind; use is entirely at your own risk and dWallet Labs assumes no liability for any damages arising from its use.
This tutorial builds a complete voting-controlled dWallet program on Solana. A proposal specifies a message to sign; when enough “yes” votes reach quorum, the program automatically approves the message for signing via CPI.
What You Will Build
A Solana program with two instructions:
| Instruction | Discriminator | Description |
|---|---|---|
create_proposal | 0 | Creates a proposal PDA with a target dWallet, message hash, and quorum |
cast_vote | 1 | Records a vote; when quorum is reached, CPI-calls approve_message |
How It Works
- A dWallet is created and its authority transferred to the voting program’s CPI authority PDA
- The creator submits a proposal referencing the dWallet, message hash, and required quorum
- Voters cast yes/no votes – each vote creates a
VoteRecordPDA (prevents double voting) - When yes votes reach quorum, the program automatically CPI-calls
approve_messageon the dWallet program - The Ika network detects the
MessageApprovaland produces a signature - The proposal status changes to
Approved
Key Concepts Covered
- CPI authority pattern – transferring dWallet control to a program
DWalletContext– the CPI wrapper for calling dWallet instructionsapprove_message– creating a MessageApproval PDA to trigger signing- PDA-based vote records – preventing double voting via account existence
- Mollusk tests – unit testing individual instructions
- E2E tests – full lifecycle against Solana devnet and the pre-alpha gRPC service
Source Code
The complete example is at chains/solana/examples/voting/.
voting/
src/lib.rs -- program logic (2 instructions)
tests/mollusk.rs -- Mollusk instruction-level tests
e2e/src/main.rs -- full E2E demo
Cargo.toml
Prerequisites
- Installation complete
- Familiarity with Core Concepts
- Basic Solana program development experience