E2E Demo
Pre-alpha. The devnet pre-alpha is a mock network with no MPC. Read the warning in the introduction first.
The voting demo runs the whole story against a live network: a council of three votes on a message, and the network signs it with a dWallet the council controls. It uses the SDK as an app does, in mock mode for the pre-alpha.
The demo is examples/voting/e2e/main.ts, run with Bun.
Before you run it
-
Get a devnet keypair with about 1 SOL from https://faucet.solana.com.
-
Build the voting program and deploy it to devnet, as the examples overview shows. Note the program id the deploy prints.
-
Install and build the SDK and the examples once, from the repository root:
pnpm install pnpm build
Running the TypeScript demo
cd examples
PAYER_KEYPAIR=<your-keypair.json> \
bun voting/e2e/main.ts 8siGnE3tCZbu4LTuX8QoBPErvWeGBF4pRSJDnaGdHyQv <voting program id>
The first argument is the ika program, and the second is your voting program. The environment variables:
| Variable | Default | What it is |
|---|---|---|
PAYER_KEYPAIR | ~/.config/solana/id.json | The keypair that pays for every transaction and owns the dWallet. |
RPC_URL | https://api.devnet.solana.com | The Solana RPC. |
GRPC_URL | https://solana-alpha-dev-1.ika-network.net | The ika network. An https:// URL is gRPC-Web. http://host:port is plaintext gRPC, for a mock on your machine. |
What the demo does
1/9 Make the payer a user: new keys, the encryption key registered on Solana,
and a gas deposit for the request key
2/9 Run a key generation over gRPC
3/9 Accept the user's share on Solana and wait until the dWallet is active
4/9 Create the council (quorum 3: Alice, Bob, Charlie), signed by the payer
while it still owns the dWallet
5/9 Transfer the dWallet to the voting program's CPI authority
6/9 Alice proposes the message
7/9 Three yes votes. The third reaches the quorum, and the program issues the
signature voucher in the same transaction
8/9 Take a presign from the network
9/9 Ask the network to sign, naming the voucher. Check that the signature is the
one written into the voucher account, and that it verifies under the
dWallet's public key
The order matters twice:
- The council must exist before the transfer. The dWallet’s owner signs
CreateCouncil, and after the transfer the owner is the program’s CPI authority, which only the program can sign for. - The voucher must be on Solana, finalized, before the sign request. The request names the voucher, and the network reads it on Solana for itself.
Expected output
═══ dWallet Voting E2E Demo (TypeScript) ═══
[1/9] Registering new keys and a gas deposit for the payer...
✓ Encryption key registered, gas deposit created
[2/9] Running a distributed key generation over gRPC...
[3/9] Accepting the user's share and waiting for the dWallet...
✓ dWallet account: ...
[4/9] Creating the council (quorum 3)...
✓ Council: ...
[5/9] Handing the dWallet to the voting program...
✓ Owner is now the voting program's signing address: ...
[6/9] A council member proposes the message...
✓ Proposal: ...
[7/9] Vote 1/3: Alice votes yes...
✓ Alice voted yes
[7/9] Vote 2/3: Bob votes yes...
✓ Bob voted yes
[7/9] Vote 3/3: Charlie votes yes...
✓ Charlie voted yes
✓ Proposal approved (3/3 yes)
✓ Voucher issued on chain: ...
[8/9] Taking a presign from the network...
✓ Presign allocated
[9/9] Asking the network to sign...
✓ The network returned a signature
✓ The same signature is committed in the voucher account
✓ The signature verifies under the dWallet's public key
═══ The demo ran to the end ═══
How the shared code is split
The TypeScript demo imports its common steps from examples/_shared/:
network.tsis the SDK side.connectToIkacreates theIkaClientin mock mode.newUsermakes the keys, registers the encryption key and opens the gas deposit.createDWalletruns the key generation, accepts the share and waits for the dWallet.takePresignandsignWithVouchertake a presign and sign under a voucher.chain.tsis the program side the SDK does not cover: the CPI authority’s address, the message digest the program stores, and waiting for the voucher on Solana.helpers.tshas the logging and the transaction sending.
The voting instructions themselves are in voting/e2e/instructions.ts.