/davinci-sdk:davinci-sdkfrom davinci-sdk
Guides code using the Vocdoni DAVINCI SDK for private, verifiable elections on OP Mainnet. Covers encrypted ballots, Groth16 proofs, zkVM-settled batches, key modes, censuses, and sequencer nodes.
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 private, verifiable voting protocol. An election lives in a ProcessRegistry contract (the OP Mainnet pre-production deployment is built in). Voters encrypt their ballot under the election key, prove it valid with a Groth16 proof they compute themselves, sign the vote and send it to a sequencer node. Nodes batch ballots, re-encrypt them, prove each batch in a zkVM and settle it on the registry with the data in EIP-4844 blobs. After the end and a short grace window, the tally is decrypted by whoever holds the election key (a node, or a committee: the DKG key network or a Council) and stored on-chain.
Not the Vochain sequencer. Here "sequencer" and "node" mean a DAVINCI sequencer node,
vocdoni/davinci-sequencer(its predecessor wasvocdoni/davinci-node, once namedvocdoni-sequencer). The currentvocdoni/vocdoni-sequencerrepo is something else: the single-node Vochain (voconed) behind the Vocdoni SaaS API, covered by thevocdoni-sequencerskill of the vocdoni/skills marketplace. If a task namesvoconed, the Vochain/v2API, saas-backend or@vocdoni/sdk, it is not about DAVINCI.
One facade, DavinciSDK, does all of it. The layers below it (ProcessRegistryService, the node clients, the census classes, the crypto primitives, the prover) are exported too, for the cases the facade does not cover.
This is the entry point. Find the task in the table below, read the matching references/ file, and start from a recipes/ file when one fits.
choices is one integer per ballot field; TxStatus (transactions) and VoteStatus (votes) are different enums; weights, results and secrets are bigint; node URLs and hosting are always configuration.| Goal | Read | Recipe |
|---|---|---|
Install, configure and init() the SDK; networks, node URLs, RPCs | references/setup.md | recipes/bootstrap.ts |
| Create an election; end, pause, resume, cancel, extend, max voters | references/process.md | recipes/create-process.ts |
| Choose who holds the election key (Automatic or an Election committee on OP Mainnet); the organizer secret | references/key-modes.md | recipes/dkg-locked.ts |
| Close early with notice; the grace window; a live meeting | references/grace.md | recipes/close-early.ts |
| Build a census: Merkle file, updatable, on-chain contract, CSP | references/census.md | recipes/onchain-census.ts |
| Titles and questions: the metadata document and its hash | references/metadata.md | — |
| Cast a vote; follow its status; eligibility | references/voting.md | recipes/cast-vote.ts |
| Several nodes: routing, failover, revotes | references/nodes.md | — |
| Prove a vote was recorded | references/receipts.md | recipes/receipt.ts |
| Wait for and read results | references/results.md | recipes/read-results.ts |
| Configure a voting system (approval, ranking, quadratic…) | references/ballot-modes.md | — |
| Call a node's REST API directly | references/sequencer.md | — |
| Use the registry directly: events, raw writes, pins | references/contracts.md | — |
| Debug an error or a revert | references/errors.md | — |
| Understand the protocol | references/protocol.md | — |
| Run everything end to end | — | recipes/full-election.ts |
The package has a single root export. There are no /sequencer, /contracts or /core subpaths:
import {
DavinciSDK, // the facade
OffchainCensus, // + OffchainDynamicCensus, OnchainCensus, CspCensus, PublishedCensus, CspSigner
CensusOrigin, // OffchainStatic=1, OffchainDynamic=2, Onchain=3, CSP=4
KeyMode, // Sequencer=0, DkgAutomatic=1, DkgLocked=2, Council=3
VoteStatus, // pending | aggregated | processed | settled | error
TxStatus, // pending | completed | reverted | failed
VoteError, // a refused vote, with a `reason`
BallotProver, // BallotProver.terminate() lets a Node script exit
type Uploader, // publishes census files and metadata documents
} from '@vocdoni/davinci-sdk';
It builds on ethers v6, snarkjs and circomlibjs, and runs in Node 18 or newer (ESM import or CommonJS require) and in browsers, through a bundler.
DavinciSDK works with one network (default 'optimism': chain 10 and its registry) and the sequencer nodes you configure. The SDK embeds no node URL and no hosting; you pass sequencerUrls and, to create elections, an uploader.init() is mandatory. It picks the read RPC, checks that the registry pins what this release proves and verifies, and checks every node's /info against the registry. Nodes that are down or observers are left out for the session (sdk.nodeChecks).Wallet: the SDK reads the chain through rpcUrls or the network's public RPCs. To act as someone else, build another DavinciSDK.submitVote returns once a node queued the ballot (pending). Nodes batch votes, so settled can take minutes to a quarter of an hour on default nodes; the end flushes everything. A voter may vote again: the latest ballot counts.graceEnd); only then can the tally be decrypted: by the key node (sequencer key) or the committee (DKG or Council, the latter once its ceremony opens decryption). waitForResults follows it.TxStatus; votes report VoteStatus. Organizer methods come as a stream (…Stream, yields TxStatusEvents) and as a plain promise that throws the typed error.choices are numbers or bigints, one per ballot field; ballot bounds are decimal strings; weights, results, k and the organizer secret are bigint.import { BallotProver, DavinciSDK, OffchainCensus, type Uploader } from '@vocdoni/davinci-sdk';
import { JsonRpcProvider, Wallet } from 'ethers';
const sequencerUrls = ['https://sequencer-1.example.org', 'https://sequencer-2.example.org'];
// Your hosting: census files and metadata documents must be served over public https.
const uploader: Uploader = {
async upload({ data, contentType, sha256 }) {
const key = `davinci/${sha256.slice(2)}.json`;
await bucket.put(key, data, { contentType });
return `https://files.example.org/${key}`;
},
};
// 1. The organizer: a signer with a provider on OP Mainnet.
const organizerWallet = new Wallet(process.env.ORGANIZER_KEY!, new JsonRpcProvider(rpcUrl));
const sdk = new DavinciSDK({ signer: organizerWallet, sequencerUrls, uploader });
await sdk.init();
// 2. The census, published through the uploader when the process is created.
const voterWallet = Wallet.createRandom();
const census = new OffchainCensus();
census.add([voterWallet.address, '0x2222222222222222222222222222222222222222']);
// 3. The election: one question, two choices, open for an hour from its creation block.
const { processId } = await sdk.createProcess({
title: 'Is the sky blue?',
census,
electionPreset: { type: 'single_choice' },
timing: { duration: 3600 },
questions: [{ title: 'Pick one', choices: [{ title: 'Yes', value: 0 }, { title: 'No', value: 1 }] }],
});
// 4. A voter, from its own SDK: a bare wallet is enough.
const voter = new DavinciSDK({ signer: voterWallet, sequencerUrls });
await voter.init();
const { voteId } = await voter.submitVote({ processId, choices: [1, 0] }); // "Yes"
await voter.waitForVoteStatus(processId, voteId); // settled, or error with the reason
// 5. After the end and the grace window: the decoded tally.
const results = await sdk.waitForResults(processId);
console.log(results.questions[0].choices.map(c => `${c.title}: ${c.total}`));
await BallotProver.terminate(); // Node: stop snarkjs's worker threads
recipes/full-election.ts is the runnable version, with an early close. Never hand-roll the encrypt, prove and sign steps: submitVote builds the ballot from the registry's parameters and checks every step.
references/setup.md: configuration and init().references/process.md: creating and running an election.references/census.md: which census, and the maxVoters rule.references/voting.md: the vote and its statuses.references/results.md: when and how results come.references/key-modes.md and references/grace.md when the election needs a committee key or a quick close.recipes/*.ts.references/sequencer.md and references/contracts.md are for when the facade is not enough, references/errors.md is the catalogue of failures, and references/protocol.md explains the protocol underneath.
recipes/bootstrap.ts (opens in a new tab)recipes/cast-vote.ts (opens in a new tab)recipes/close-early.ts (opens in a new tab)recipes/create-process.ts (opens in a new tab)recipes/dkg-locked.ts (opens in a new tab)recipes/full-election.ts (opens in a new tab)recipes/onchain-census.ts (opens in a new tab)recipes/read-results.ts (opens in a new tab)recipes/receipt.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/grace.md (opens in a new tab)references/key-modes.md (opens in a new tab)references/metadata.md (opens in a new tab)references/nodes.md (opens in a new tab)references/process.md (opens in a new tab)references/protocol.md (opens in a new tab)references/receipts.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (vocdoni/davinci-sdk) — no native marketplace selected
npx claudepluginhub p/vocdoni-davinci-sdkOther plugins' skills for the same job