/davinci-sdk:davinci-sdkfrom davinci-sdk
Use this skill whenever the user is building, debugging, or asking about code that uses the Vocdoni Davinci SDK (`@vocdoni/davinci-sdk`) — the TypeScript SDK for the Davinci zk-based voting protocol. Triggers on imports from `@vocdoni/davinci-sdk`; mentions of the `DavinciSDK` class, `createProcess` / `submitVote` / `waitForVoteStatus`, the census classes (`OffchainCensus`, `CspCensus`, `OnchainCensus`, `PublishedCensus`), `CensusOrigin`, `VoteStatus` / `TxStatus`, `ProcessRegistryService`, the sequencer or census services, encrypted/homomorphic ballots, zk-SNARK ballot proofs, ballot modes (approval/ranked/quadratic/budget), token-holder / on-chain censuses, or CSP voting. Also load it for high-level intents like "create an election", "let users vote privately", "encrypt a ballot", or "submit a vote to the sequencer" — the SDK has specific class/method shapes (a high-level `DavinciSDK` facade, a two-status async vote flow, and a parametric ballot model) the agent will not recall accurately unaided.
Ships in davinci-sdk. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
@vocdoni/davinci-sdk)The TypeScript SDK for Davinci, Vocdoni's zk-based voting protocol. It runs private, verifiable elections where ballots are homomorphically encrypted (ElGamal) and accompanied by zk-SNARK validity proofs, collected and aggregated off-chain by a sequencer, with canonical state and results anchored in Ethereum smart contracts.
The SDK ships a single high-level facade, DavinciSDK, that orchestrates all of this. Almost every task goes through it. Lower-level services (ProcessRegistryService, the sequencer/census REST clients, the crypto primitives) exist and are reachable, but you reach for them only when the facade doesn't cover a case.
This is the entry point. Read the section matching the task, load the matching references/ file for the exhaustive API, and lift a recipes/ file when you need a complete working flow.
choices: number[] ballot model whose length must equal ballot.numFields, two different status enums (TxStatus for on-chain transactions, VoteStatus for vote processing), and bigint results. The references spell these out.| Goal | Read | Recipe |
|---|---|---|
Install, construct & init() the SDK, signer vs provider, env | references/setup.md | recipes/bootstrap.ts |
| Create a process/election; lifecycle (end/pause/cancel/resume) | references/process.md | recipes/create-process.ts |
| Choose & build a census (Merkle, dynamic, CSP, on-chain, prebuilt) | references/census.md | recipes/create-process.ts |
| Cast an encrypted vote; check/await status; eligibility | references/voting.md | recipes/cast-vote.ts |
| Configure a voting system (approval/ranked/quadratic/budget…) | references/ballot-modes.md | — |
| Token-holder / on-chain (ERC20/721) census | references/census.md | recipes/token-census.ts |
| Read results / tally; vote & voter counts | references/process.md | recipes/read-results.ts |
Talk to the sequencer REST API directly (sdk.api.sequencer) | references/sequencer.md | — |
Drop to the raw contract service (sdk.processes) | references/contracts.md | — |
| Debug a runtime error / revert / proof / "not accepting votes" | references/errors.md | — |
| Understand the protocol itself (crypto, lifecycle, why) | references/protocol.md | — |
| Run the whole thing end to end | — | recipes/full-election.ts |
@vocdoni/davinci-sdk is published with a single root export — there are no /sequencer, /contracts, or /core subpaths. Import everything from the root:
import {
DavinciSDK, // the facade you'll use 95% of the time
OffchainCensus, // + OffchainDynamicCensus, CspCensus, OnchainCensus, PublishedCensus
CensusOrigin, // enum: OffchainStatic=1, OffchainDynamic=2, Onchain=3, CSP=4
VoteStatus, // pending | verified | aggregated | processed | settled | error
TxStatus, // pending | completed | reverted | failed
} from "@vocdoni/davinci-sdk";
It depends on ethers v6, @noble/curves, @noble/hashes, circomlibjs, and snarkjs. Node ≥ 18 (global fetch) or a browser.
⚠️ If you see code importing
@vocdoni/davinci-sdk/sequencer,OrganizationRegistryService,VocdoniContracts, ordeployedAddresses, it is wrong / from an older imagined API. None of those exist. There is no "organization" object in this SDK — the process creator is simply the signer's Ethereum address.
DavinciSDK instance acts as whoever its signer is. The organizer (a signer with a provider) calls createProcess and the lifecycle methods. A voter (a signer, no provider needed) calls submitVote. The sequencer is a remote service you talk to via REST — you never run it. To act as a different person, construct a second DavinciSDK with that wallet.createProcess coordinates both; you don't.init() is mandatory. Every facade method throws until you await sdk.init(). init() resolves contract addresses from the sequencer's /info and wires the services.createProcess, getProcess, and lifecycle methods need signer.provider. submitVote, getVoteStatus, hasAddressVoted do not — a bare new Wallet(pk) is fine for voting.submitVote({ processId, choices }) builds the ballot, ElGamal-encrypts it against the process key, generates the zk-SNARK proof with snarkjs (downloading circuits from the sequencer once, then caching), signs, and submits. It returns a voteId with an initial VoteStatus. The vote only counts after the sequencer drives it to settled — always waitForVoteStatus.choices is number[], length === ballot.numFields. Each entry is the value for one ballot field. A single-choice question with N options is encoded as N one-hot fields ([0,1,0,0]). Multi-question elections concatenate the fields. See references/ballot-modes.md.TxStatus (pending|completed|reverted|failed). Vote processing reports VoteStatus (pending|verified|aggregated|processed|settled|error).choices/maxVoters/numFields/costExponent are number; ballot bounds (maxValue/minValue/maxValueSum/minValueSum) are decimal strings; on-chain results/weights come back as bigint (or numeric strings from the sequencer).import { JsonRpcProvider, Wallet } from "ethers";
import { DavinciSDK, OffchainCensus, VoteStatus } from "@vocdoni/davinci-sdk";
// 1. Organizer SDK — signer WITH a provider (on-chain ops need it).
const organizer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));
const sdk = new DavinciSDK({
signer: organizer,
sequencerUrl: process.env.SEQUENCER_API_URL!, // e.g. https://sequencer-dev.davinci.vote
censusUrl: process.env.CENSUS_API_URL!, // needed to publish a Merkle census
});
await sdk.init();
// 2. Census of eligible voters (auto-published during createProcess).
const census = new OffchainCensus();
census.add(["0xVoterA…", "0xVoterB…"]); // weight defaults to 1
// 3. Create the process. One question, two options → 2 one-hot ballot fields.
const { processId } = await sdk.createProcess({
title: "Is the sky blue?",
census, // maxVoters auto = participant count
ballot: { numFields: 2, minValue: "0", maxValue: "1",
uniqueValues: false, costExponent: 1, minValueSum: "0", maxValueSum: "1" },
timing: { duration: 3600 }, // startDate defaults to now+60s
questions: [{ title: "Pick one",
choices: [{ title: "Yes", value: 0 }, { title: "No", value: 1 }] }],
});
// 4. Vote AS a voter — a fresh SDK with the voter's wallet (no provider needed).
const voterSdk = new DavinciSDK({ signer: new Wallet(VOTER_PK),
sequencerUrl: process.env.SEQUENCER_API_URL!, censusUrl: process.env.CENSUS_API_URL! });
await voterSdk.init();
const { voteId } = await voterSdk.submitVote({ processId, choices: [1, 0] }); // votes "Yes"
await voterSdk.waitForVoteStatus(processId, voteId, VoteStatus.Settled);
// 5. Read results (bigint per ballot field).
const info = await sdk.getProcess(processId);
console.log(info.result); // e.g. [ 1n, 0n ] → 1 vote on field 0 ("Yes")
The full, runnable version with real-time status streaming is recipes/full-election.ts. Don't hand-roll the encrypt/prove step — the facade owns it; you only ever supply choices.
references/setup.md — construct & init(), signer-vs-provider rule, env vars.references/process.md — createProcess config, lifecycle, getProcess / results.references/census.md — pick a census class; the maxVoters rule per type.references/voting.md — submitVote, the choices model, status polling.references/ballot-modes.md — only when the user wants a specific voting system.recipes/*.ts for the closest scenario.references/sequencer.md and references/contracts.md are escape hatches for when the facade isn't enough; references/errors.md is the gotcha catalogue; references/protocol.md explains the cryptography and the why.
recipes/bootstrap.ts (opens in a new tab)recipes/cast-vote.ts (opens in a new tab)recipes/create-process.ts (opens in a new tab)recipes/full-election.ts (opens in a new tab)recipes/read-results.ts (opens in a new tab)recipes/token-census.ts (opens in a new tab)references/ballot-modes.md (opens in a new tab)references/census.md (opens in a new tab)references/contracts.md (opens in a new tab)references/errors.md (opens in a new tab)references/process.md (opens in a new tab)references/protocol.md (opens in a new tab)references/sequencer.md (opens in a new tab)references/setup.md (opens in a new tab)references/voting.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub vocdoni/skills --plugin davinci-sdk