@vocdoni/skills 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.claude-plugin/marketplace.json +27 -15
  2. package/CHANGELOG.md +22 -0
  3. package/README.md +38 -24
  4. package/bin/install.js +13 -2
  5. package/package.json +1 -1
  6. package/plugins/agentic-dev/.claude-plugin/plugin.json +1 -1
  7. package/plugins/agentic-dev/skills/subagent-driven-development/SKILL.md +6 -4
  8. package/plugins/agentic-dev/skills/subagent-driven-development/references/dispatch.md +6 -1
  9. package/plugins/agentic-dev/skills/subagent-driven-development/references/ledger.md +8 -5
  10. package/plugins/agentic-dev/skills/subagent-driven-development/references/models.md +38 -6
  11. package/plugins/agentic-dev/skills/subagent-driven-development/scripts/init-workspace.sh +1 -0
  12. package/plugins/agentic-dev/skills/subagent-driven-development/scripts/model-inventory.sh +6 -4
  13. package/plugins/claude-pi-subagent/plugins/pi-subagent/package-lock.json +4 -3
  14. package/plugins/vocdoni-contributing/.claude-plugin/plugin.json +2 -2
  15. package/plugins/vocdoni-contributing/hooks/session-start.sh +1 -1
  16. package/plugins/vocdoni-contributing/skills/contributing/SKILL.md +33 -6
  17. package/plugins/vocdoni-go/.claude-plugin/plugin.json +2 -2
  18. package/plugins/vocdoni-go/skills/vocdoni-backend-review/SKILL.md +522 -0
  19. package/plugins/vocdoni-go/skills/vocdoni-backend-review/references/prompts.md +260 -0
  20. package/plugins/vocdoni-go/skills/vocdoni-backend-review/scripts/untracked-list.sh +35 -0
  21. package/plugins/vocdoni-sdk/.claude-plugin/plugin.json +4 -5
  22. package/plugins/vocdoni-sdk/skills/vocdoni-ballot-protocol/SKILL.md +61 -38
  23. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/SKILL.md +35 -21
  24. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/approval-vote.ts +3 -3
  25. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/basic-poll.ts +6 -6
  26. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/csp-vote.ts +12 -7
  27. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/multichoice-vote.ts +3 -3
  28. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/quadratic-vote.ts +3 -3
  29. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/ranked-vote.ts +3 -3
  30. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/weighted-census.ts +3 -3
  31. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/accounts.md +26 -15
  32. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/census.md +9 -10
  33. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/client.md +15 -13
  34. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/csp.md +43 -18
  35. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/elections.md +4 -4
  36. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/errors.md +24 -21
  37. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/removed-features.md +98 -0
  38. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/results.md +0 -1
  39. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/voting.md +30 -34
  40. package/plugins/vocdoni-sequencer/.claude-plugin/plugin.json +21 -0
  41. package/plugins/vocdoni-sequencer/skills/vocdoni-sequencer/SKILL.md +169 -0
  42. package/plugins/vocdoni-sequencer/skills/vocdoni-sequencer/references/removed-routes.md +60 -0
  43. package/plugins/davinci-sdk/.claude-plugin/plugin.json +0 -13
  44. package/plugins/davinci-sdk/skills/davinci-sdk/SKILL.md +0 -120
  45. package/plugins/davinci-sdk/skills/davinci-sdk/recipes/bootstrap.ts +0 -61
  46. package/plugins/davinci-sdk/skills/davinci-sdk/recipes/cast-vote.ts +0 -78
  47. package/plugins/davinci-sdk/skills/davinci-sdk/recipes/create-process.ts +0 -102
  48. package/plugins/davinci-sdk/skills/davinci-sdk/recipes/full-election.ts +0 -128
  49. package/plugins/davinci-sdk/skills/davinci-sdk/recipes/read-results.ts +0 -73
  50. package/plugins/davinci-sdk/skills/davinci-sdk/recipes/token-census.ts +0 -111
  51. package/plugins/davinci-sdk/skills/davinci-sdk/references/ballot-modes.md +0 -125
  52. package/plugins/davinci-sdk/skills/davinci-sdk/references/census.md +0 -168
  53. package/plugins/davinci-sdk/skills/davinci-sdk/references/contracts.md +0 -133
  54. package/plugins/davinci-sdk/skills/davinci-sdk/references/errors.md +0 -83
  55. package/plugins/davinci-sdk/skills/davinci-sdk/references/process.md +0 -225
  56. package/plugins/davinci-sdk/skills/davinci-sdk/references/protocol.md +0 -65
  57. package/plugins/davinci-sdk/skills/davinci-sdk/references/sequencer.md +0 -135
  58. package/plugins/davinci-sdk/skills/davinci-sdk/references/setup.md +0 -123
  59. package/plugins/davinci-sdk/skills/davinci-sdk/references/voting.md +0 -128
  60. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/anonymous-vote.ts +0 -108
  61. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/token-census.ts +0 -121
  62. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/anonymous.md +0 -183
  63. package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/census3.md +0 -308
@@ -1,14 +1,34 @@
1
1
  ---
2
2
  name: vocdoni-sdk
3
- description: Use this skill whenever the user is building, debugging, or asking questions about code that uses the Vocdoni SDK (`@vocdoni/sdk`) — the TypeScript/JavaScript library for the Vocdoni voting protocol. Triggers on imports from `@vocdoni/sdk`, mentions of VocdoniSDKClient, VocdoniCensus3Client, creating elections, voting on Vocdoni, Vochain, census creation (PlainCensus/WeightedCensus/CspCensus/TokenCensus/StrategyCensus), election variants (approval / ranked / multichoice / budget / quadratic), anonymous (ZK) voting, CSP-based voting, token-gated censuses via Census3, faucet/account bootstrap, EnvOptions.DEV/STG/PROD, or any prompt like "how do I create a poll", "vote on this election", "get election results", "token holder census" in a context where Vocdoni is in play. Even when the user names only a high-level intent ("I want quadratic voting", "anonymous voting"), load this skill — the SDK has specific class/method shapes the agent must use and is unlikely to recall accurately without consulting it.
3
+ description: Legacy. Use this skill when maintaining existing code that uses the legacy Vocdoni SDK (`@vocdoni/sdk`), the TypeScript client of the Vochain `/v2` API, now served by vocdoni-sequencer. Triggers on imports from `@vocdoni/sdk`, VocdoniSDKClient, EnvOptions.DEV/STG/PROD, Vochain accounts and the faucet, census classes (PlainCensus/WeightedCensus/CspCensus), election variants (approval / ranked / multichoice / budget / quadratic), CSP voting (cspStep, cspSign, CspVote, weighted CSP votes), vote memos, reading results, and upgrading to @vocdoni/sdk 0.10.0. Also use when old code calls something the chain dropped (AnonymousVote, SIKs, VocdoniCensus3Client, TokenCensus, RemoteSigner) and needs a replacement. New integrations do not use this SDK: they build on the Vocdoni Integrator SDK (`@vocdoni/api-client`, `@vocdoni/api-voting`) against the SaaS API, covered by the vocdoni-integrator-sdk skill.
4
4
  ---
5
5
 
6
6
  # Vocdoni SDK
7
7
 
8
- The `@vocdoni/sdk` TypeScript/JavaScript library is the official client for the [Vocdoni voting protocol](https://docs.vocdoni.io). It lets an application:
8
+ > **Legacy.** Use this skill to maintain existing `@vocdoni/sdk` code; do not start new work on it.
9
+ > New integrations build on [[vocdoni-integrator-sdk]], which talks to the Vocdoni SaaS API
10
+ > (saas-backend) rather than to the chain. The chain this SDK talks to is now served by
11
+ > [[vocdoni-sequencer]], which replaced the archived vocdoni-node. It keeps the `/v2` API, with
12
+ > these breaks:
13
+ >
14
+ > - **`@vocdoni/sdk` 0.8.3 and older break on paginated and count calls.** They call
15
+ > `/accounts/page/`, `/accounts/count`, `/elections/page/{page}`, `/elections/{id}/votes/count`,
16
+ > `/chain/transactions/page/` and similar, which now answer 410 (code 4067). 0.9.0 and newer use
17
+ > `?page=` queries: upgrade. The full list is in the [[vocdoni-sequencer]] skill's
18
+ > `references/removed-routes.md`.
19
+ > - **Anonymous (ZK) voting** is rejected at election creation; the SIK and circuit routes return 410.
20
+ > - **Census3** is shut down, so `VocdoniCensus3Client`, `TokenCensus` and `StrategyCensus` fail.
21
+ > - **RemoteSigner** against the SaaS can log in but cannot sign: its `/transactions` routes are gone.
22
+ > - **CSP elections need the V2 salt.** 0.10.0 publishes them as `OFF_CHAIN_CA_V2`, so the CSP must be `vocdoni/blind-csp` v0.2.0 or later (see `references/removed-features.md`).
23
+ > - **Test on `EnvOptions.DEV`.** Its faucet funds accounts automatically. If the STG faucet fails, see `references/removed-features.md`.
24
+ >
25
+ > What breaks and what to use instead: `references/removed-features.md`.
26
+ > This skill tracks `@vocdoni/sdk` 0.10.0.
27
+
28
+ The `@vocdoni/sdk` TypeScript/JavaScript library is the official client for the [Vocdoni voting protocol](https://vocdoni.io/developers). It lets an application:
9
29
 
10
30
  - Bootstrap a signing account on the Vocdoni chain (vochain).
11
- - Build a census of eligible voters (plain list, weighted, CSP-gated, or token-holder via Census3).
31
+ - Build a census of eligible voters (plain list, weighted, or CSP-gated).
12
32
  - Create a voting process ("election") with a wide range of variants and configurations.
13
33
  - Cast votes and read results.
14
34
 
@@ -35,10 +55,10 @@ This skill is the entry point. Read the section that matches the task; load the
35
55
  | Ranked / linear-weighted-choice voting | `references/election-types.md` + `references/voting.md` | `recipes/ranked-vote.ts` |
36
56
  | Multi-choice voting (min/max, can-abstain) | `references/election-types.md` + `references/voting.md` | `recipes/multichoice-vote.ts` |
37
57
  | Budget-based voting (allocate credits) | `references/election-types.md` + `references/voting.md` | — |
38
- | Anonymous voting (ZK proofs hide voter identity) | `references/anonymous.md` + `references/voting.md` | `recipes/anonymous-vote.ts` |
39
58
  | CSP-gated voting (blind-signature census) | `references/csp.md` + `references/census.md` | `recipes/csp-vote.ts` |
40
- | Token-holder census from an ERC20/721 | `references/census3.md` | `recipes/token-census.ts` |
41
- | Multi-token strategy census ("(A OR B) AND C") | `references/census3.md` | `recipes/token-census.ts` |
59
+ | Weighted CSP vote / vote memo (SDK 0.10.0) | `references/csp.md` + `references/voting.md` | `recipes/csp-vote.ts` |
60
+ | Code uses anonymous voting, SIKs, Census3 or RemoteSigner | `references/removed-features.md` | — |
61
+ | Upgrade an old SDK | `references/removed-features.md` | — |
42
62
  | Read election results / status | `references/results.md` | — |
43
63
  | Pause / cancel / end / continue an election | `references/elections.md` | — |
44
64
  | Debug a runtime error | `references/errors.md` | — |
@@ -56,12 +76,12 @@ import {
56
76
  Vote,
57
77
  } from '@vocdoni/sdk';
58
78
 
59
- // 1. Client. EnvOptions.STG is the recommended testing environment; DEV resets often; PROD is mainnet.
79
+ // 1. Client. EnvOptions.DEV is the testing environment; PROD is mainnet.
60
80
  const creator = Wallet.createRandom();
61
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
81
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
62
82
 
63
- // 2. Bootstrap the creator's account on the Vocdoni chain (faucet runs automatically on STG/DEV).
64
- await client.createAccount();
83
+ // 2. Bootstrap the creator's account on the Vocdoni chain (faucet runs automatically when no faucetPackage is passed).
84
+ await client.createAccount({ sik: false });
65
85
 
66
86
  // 3. Build a census of eligible voters.
67
87
  const census = new PlainCensus();
@@ -92,21 +112,16 @@ const result = await client.fetchElection();
92
112
  console.log(result.results); // [[ "1", "0" ]] → 1 vote for choice 0 ("Yes")
93
113
  ```
94
114
 
95
- This is the spine of every Vocdoni flow. Every variant — anonymous, CSP, token-gated, quadratic, ranked — is the same shape with a different census, a different election variant class, and/or different `voteType` parameters.
115
+ This is the spine of every Vocdoni flow. Every variant (CSP, weighted, quadratic, ranked) is the same shape with a different census, a different election variant class, and/or different `voteType` parameters.
96
116
 
97
117
  ## Mental model
98
118
 
99
- - **Vocdoni runs its own blockchain (the *vochain*).** Account creation, election creation, and votes are all signed transactions against this chain.
100
- - **Three blockchain environments:** `EnvOptions.DEV` (resets often, faucet on), `EnvOptions.STG` (stable testnet, recommended), `EnvOptions.PROD` (real elections). The same code works on all three; only the constant changes.
101
- - **Two clients:** `VocdoniSDKClient` (everything on the vochain) and `VocdoniCensus3Client` (a separate API that produces censuses from on-chain ERC20/721 holdings). They cooperate: Census3 hands a `TokenCensus`/`StrategyCensus` to the main client.
119
+ - **The Vochain is Vocdoni's own chain, now a single node (vocdoni-sequencer / voconed) behind the SaaS; `/v2` is its API.** Account creation, election creation, and votes are all signed transactions against it.
120
+ - **Three environments:** `EnvOptions.DEV` (testing; the faucet works; it may be reset), STG (stable API, but its faucet can fail the TLS handshake, so use DEV for testing; see `references/removed-features.md`), `EnvOptions.PROD` (real elections; the faucet hands out only a small package, so real budgets come from a faucet package signed by a funded account). The same code works on all three; only the constant changes.
102
121
  - **The signer matters who you're acting as.** Creating an election uses the creator's wallet; submitting a vote uses the voter's wallet. The client's `wallet` is mutable (`client.wallet = voter`) and a new client can be cheaply instantiated per actor.
103
122
  - **`client.setElectionId(id)` is sticky.** Many methods (`submitVote`, `isInCensus`, `hasAlreadyVoted`, `fetchElection`) default to this stored ID. Forgetting to set it is a frequent bug.
104
123
  - **Election creation is asynchronous on-chain.** After `createElection()` returns, wait until `client.fetchElection(id).then(e => e.status)` reaches `ElectionStatus.ONGOING` before voting. Block time is ~10–13s; recipes show the polling pattern.
105
- - **Census types are bound to election types.** Anonymous elections need an anonymous-type census; CSP elections need a `CspCensus`; weighted/quadratic typically want a `WeightedCensus`. `references/census.md` and `references/election-types.md` cross-link these constraints.
106
-
107
- ## A note on Census3 vs the main SDK
108
-
109
- If the user wants a census **from token holders or LP positions on a real chain (Ethereum, Polygon, …)**, that comes from [Census3](https://github.com/vocdoni/census3), exposed via `VocdoniCensus3Client` in the same npm package. It returns a `TokenCensus` or `StrategyCensus` that plugs directly into `Election.from({ census, … })` on the main `VocdoniSDKClient`. Treat Census3 as a sibling service — separate API, different methods, same package import.
124
+ - **Census types are bound to election types.** CSP elections need a `CspCensus`; weighted/quadratic typically want a `WeightedCensus`. `references/census.md` and `references/election-types.md` cross-link these constraints.
110
125
 
111
126
  ## Trustworthy reading order when the task is open-ended
112
127
 
@@ -118,9 +133,8 @@ If the user hasn't pinned the shape of the task, this is the safest order to loa
118
133
  4. `references/voting.md` — submit-vote shape, the `Vote` constructor, the check methods (`isInCensus`, `hasAlreadyVoted`).
119
134
  5. Then a `recipes/*.ts` file for the closest scenario.
120
135
 
121
- Anonymous, CSP, Census3, and election-type variants are specializations of this baseline — go to their reference when you know that's the shape.
136
+ CSP and election-type variants are specializations of this baseline — go to their reference when you know that's the shape.
122
137
 
123
138
  ## Sibling skill: the ballot protocol
124
139
 
125
140
  For protocol-level questions ("what shape is the vote array", "what does my result matrix mean", "what is `costExponent` *really*", "discrete vs index-weighted aggregation"), load the [[vocdoni-ballot-protocol]] skill in the same plugin. It encodes the on-chain data model the SDK serialises into — useful for debugging vote-shape errors and understanding why a given election variant constrains things the way it does.
126
-
@@ -29,8 +29,8 @@ async function waitForElectionReady(c: VocdoniSDKClient, id: string) {
29
29
 
30
30
  async function main() {
31
31
  const creator = Wallet.createRandom();
32
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
33
- await client.createAccount();
32
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
33
+ await client.createAccount({ sik: false });
34
34
 
35
35
  const voters: Wallet[] = Array.from({ length: VOTERS_NUM }, () => Wallet.createRandom());
36
36
  const census = new PlainCensus();
@@ -58,7 +58,7 @@ async function main() {
58
58
  // All voters submit the same approval ballot for clarity
59
59
  await Promise.all(
60
60
  voters.map(async (voter) => {
61
- const c = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: voter, electionId });
61
+ const c = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: voter, electionId });
62
62
  await c.submitVote(new Vote(APPROVAL_BALLOT));
63
63
  }),
64
64
  );
@@ -9,11 +9,11 @@
9
9
  * - cast every voter's vote
10
10
  * - read results
11
11
  *
12
- * Runs against EnvOptions.STG (recommended testing env). Replace STG with PROD
13
- * for real elections (and supply a faucet package to createAccount).
12
+ * Runs against EnvOptions.DEV, whose faucet funds the creator account. For PROD,
13
+ * pass createAccount({ faucetPackage, sik: false }) signed by a funded account.
14
14
  *
15
15
  * Usage:
16
- * yarn add @vocdoni/sdk @ethersproject/wallet
16
+ * yarn add @vocdoni/sdk@0.10.0 @ethersproject/wallet
17
17
  * ts-node basic-poll.ts
18
18
  */
19
19
 
@@ -39,8 +39,8 @@ async function waitForElectionReady(client: VocdoniSDKClient, id: string): Promi
39
39
  async function main() {
40
40
  // 1. Creator client + account
41
41
  const creator = Wallet.createRandom();
42
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
43
- await client.createAccount(); // faucet runs automatically on STG/DEV
42
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
43
+ await client.createAccount({ sik: false }); // faucet runs automatically when no faucetPackage is passed
44
44
 
45
45
  // 2. Build a census of 5 random voters (all weight = 1)
46
46
  const voters: Wallet[] = [];
@@ -74,7 +74,7 @@ async function main() {
74
74
  // 5. Cast each voter's vote in parallel — one client per voter
75
75
  await Promise.all(
76
76
  voters.map(async (voter, i) => {
77
- const c = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: voter, electionId });
77
+ const c = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: voter, electionId });
78
78
  // Alternate Yes/No so we see both columns
79
79
  const voteId = await c.submitVote(new Vote([i % 2]));
80
80
  console.log(`voter ${i} voted: ${voteId}`);
@@ -9,7 +9,9 @@
9
9
  * your CSP requires.
10
10
  *
11
11
  * Requires a running CSP server reachable at CSP_URL with public key CSP_PUBKEY.
12
- * For a real reference implementation see https://github.com/vocdoni/blind-csp.
12
+ * vocdoni/blind-csp (https://github.com/vocdoni/blind-csp) is the reference CSP.
13
+ * Use v0.2.0 or later: older releases sign with the legacy salt and fail on the
14
+ * OFF_CHAIN_CA_V2 elections SDK 0.10.0 creates. It signs weight 1 only.
13
15
  */
14
16
 
15
17
  import { Wallet } from '@ethersproject/wallet';
@@ -36,8 +38,8 @@ async function waitForElectionReady(c: VocdoniSDKClient, id: string) {
36
38
  async function main() {
37
39
  // 1. Creator side: build an election with a CspCensus
38
40
  const creator = Wallet.createRandom();
39
- const adminClient = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
40
- await adminClient.createAccount();
41
+ const adminClient = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
42
+ await adminClient.createAccount({ sik: false });
41
43
 
42
44
  const census = new CspCensus(CSP_PUBKEY, CSP_URL);
43
45
 
@@ -59,7 +61,7 @@ async function main() {
59
61
  // 2. Voter side: run the CSP auth protocol, then submit a CspVote.
60
62
  const voter = Wallet.createRandom();
61
63
  const voterClient = new VocdoniSDKClient({
62
- env: EnvOptions.STG,
64
+ env: EnvOptions.DEV,
63
65
  wallet: voter,
64
66
  electionId,
65
67
  });
@@ -72,11 +74,14 @@ async function main() {
72
74
  const sum = step0.response.reduce((acc, v) => +acc + +v, 0).toString();
73
75
  const step1 = (await voterClient.cspStep(1, [sum], step0.authToken)) as ICspFinalStepResponse;
74
76
 
75
- // Get the blind signature on the voter's address for this election.
76
- const signature = await voterClient.cspSign(voter.address, step1.token);
77
+ // Blind signature on the voter's address: { signature, weight }. For a weighted
78
+ // vote pass the weight the CSP authorized, e.g. cspSign(voter.address, step1.token, 5n);
79
+ // cspVote reuses it.
80
+ const cspSignature = await voterClient.cspSign(voter.address, step1.token);
77
81
 
78
82
  // Build and submit the CSP vote.
79
- const cspVote = voterClient.cspVote(new Vote([0]), signature);
83
+ // Optional public memo (max 256 bytes, stored in the clear): new Vote([0], 'memo')
84
+ const cspVote = voterClient.cspVote(new Vote([0]), cspSignature);
80
85
  const voteId = await voterClient.submitVote(cspVote);
81
86
 
82
87
  console.log(`Voted (id: ${voteId}). Verify: ${voterClient.explorerUrl}/verify/#/${voteId}`);
@@ -27,8 +27,8 @@ async function waitForElectionReady(c: VocdoniSDKClient, id: string) {
27
27
 
28
28
  async function main() {
29
29
  const creator = Wallet.createRandom();
30
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
31
- await client.createAccount();
30
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
31
+ await client.createAccount({ sik: false });
32
32
 
33
33
  const voters = Array.from({ length: VOTERS_NUM }, () => Wallet.createRandom());
34
34
  const census = new PlainCensus();
@@ -59,7 +59,7 @@ async function main() {
59
59
 
60
60
  await Promise.all(
61
61
  voters.map(async (voter) => {
62
- const c = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: voter, electionId });
62
+ const c = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: voter, electionId });
63
63
  await c.submitVote(new Vote(BALLOT));
64
64
  }),
65
65
  );
@@ -34,8 +34,8 @@ async function waitForElectionReady(c: VocdoniSDKClient, id: string) {
34
34
 
35
35
  async function main() {
36
36
  const creator = Wallet.createRandom();
37
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
38
- await client.createAccount();
37
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
38
+ await client.createAccount({ sik: false });
39
39
 
40
40
  const voters = Array.from({ length: VOTERS_NUM }, () => Wallet.createRandom());
41
41
  const census = new WeightedCensus();
@@ -65,7 +65,7 @@ async function main() {
65
65
 
66
66
  await Promise.all(
67
67
  voters.map(async (voter) => {
68
- const c = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: voter, electionId });
68
+ const c = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: voter, electionId });
69
69
  await c.submitVote(new Vote(BALLOT));
70
70
  }),
71
71
  );
@@ -46,8 +46,8 @@ async function waitForElectionReady(c: VocdoniSDKClient, id: string) {
46
46
 
47
47
  async function main() {
48
48
  const creator = Wallet.createRandom();
49
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
50
- await client.createAccount();
49
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
50
+ await client.createAccount({ sik: false });
51
51
 
52
52
  const voters = Array.from({ length: VOTERS_NUM }, () => Wallet.createRandom());
53
53
  const census = new PlainCensus();
@@ -76,7 +76,7 @@ async function main() {
76
76
 
77
77
  await Promise.all(
78
78
  voters.map(async (voter) => {
79
- const c = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: voter, electionId });
79
+ const c = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: voter, electionId });
80
80
  await c.submitVote(new Vote(RANKED_BALLOT));
81
81
  }),
82
82
  );
@@ -25,8 +25,8 @@ async function waitForElectionReady(c: VocdoniSDKClient, id: string) {
25
25
 
26
26
  async function main() {
27
27
  const creator = Wallet.createRandom();
28
- const client = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: creator });
29
- await client.createAccount();
28
+ const client = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: creator });
29
+ await client.createAccount({ sik: false });
30
30
 
31
31
  // Voters with explicit weights (1, 2, 4, 8, 16 — geometric for visibility)
32
32
  const voters: Wallet[] = [];
@@ -60,7 +60,7 @@ async function main() {
60
60
  // Cast votes: voters 0,2,4 say Yes; 1,3 say No
61
61
  await Promise.all(
62
62
  voters.map(async (voter, i) => {
63
- const c = new VocdoniSDKClient({ env: EnvOptions.STG, wallet: voter, electionId });
63
+ const c = new VocdoniSDKClient({ env: EnvOptions.DEV, wallet: voter, electionId });
64
64
  await c.submitVote(new Vote([i % 2]));
65
65
  }),
66
66
  );
@@ -4,27 +4,29 @@ Companion to the [[vocdoni-sdk]] skill. Use this when registering an account on
4
4
 
5
5
  ## The mental model
6
6
 
7
- Every signer that wants to **create elections** must first register an account on the vochain. Voters don't need an account — they just need to be in the census. The fee for registration and for creating elections is paid in Vocdoni tokens; on DEV/STG these come from the faucet automatically, on PROD you get them out-of-band.
7
+ Every signer that wants to **create elections** must first register an account on the vochain. Voters don't need an account — they just need to be in the census. The fee for registration and for creating elections is paid in Vocdoni tokens. The env's faucet funds the account automatically (test on DEV; if the STG faucet fails, see `removed-features.md`), but on PROD it hands out only a small package, so real budgets come out-of-band.
8
8
 
9
9
  ## Bootstrap a new account
10
10
 
11
11
  ```ts
12
- await client.createAccount();
12
+ await client.createAccount({ sik: false });
13
13
  ```
14
14
 
15
- `createAccount` is idempotent: it fetches the account if it already exists, otherwise it registers it (and on DEV/STG, calls the faucet automatically). Safe to call on every app start.
15
+ `createAccount` is idempotent: it fetches the account if it already exists, otherwise it registers it. It calls the faucet automatically whenever no `faucetPackage` is passed. Safe to call on every app start.
16
16
 
17
17
  Full signature and options:
18
18
 
19
19
  ```ts
20
20
  client.createAccount(options?: {
21
21
  account?: Account; // metadata; see below
22
- faucetPackage?: string; // base64 string from a faucet; required on PROD
23
- sik?: boolean; // generate Secret Identity Key (for anonymous voting). Default: true
24
- password?: string; // password used in SIK derivation. Default: '0'
22
+ faucetPackage?: string; // base64 string; skips the automatic faucet call. Use it for real budgets on PROD
23
+ sik?: boolean; // ignored by the chain (no anonymous voting); default true costs one extra wallet signature, pass false
24
+ password?: string; // only fed the SIK derivation; ignored
25
25
  }): Promise<AccountData>
26
26
  ```
27
27
 
28
+ The next `@vocdoni/sdk` release drops the `sik` option; remove the argument when you upgrade past 0.10.0.
29
+
28
30
  Return value:
29
31
 
30
32
  ```ts
@@ -35,7 +37,7 @@ type AccountData = {
35
37
  nonce: number; // next-tx nonce
36
38
  electionIndex: number; // how many elections this account has created
37
39
  infoURL: string | null; // IPFS URI of the metadata blob
38
- sik: string; // Secret Identity Key
40
+ sik?: string; // undefined: the chain no longer returns it
39
41
  transfersCount: number;
40
42
  feesCount: number;
41
43
  };
@@ -61,6 +63,7 @@ await client.createAccount({
61
63
  // value can be any JSON: string, number, array, object
62
64
  ],
63
65
  }),
66
+ sik: false,
64
67
  });
65
68
  ```
66
69
 
@@ -100,30 +103,38 @@ const info = await client.fetchAccountInfo('0x123…abc'); // any add
100
103
 
101
104
  Use `fetchAccount(address?)` when you want to **assert** the account exists and is active — it throws on archived accounts.
102
105
 
103
- ## Faucet — funding accounts on DEV/STG
106
+ ## Faucet
104
107
 
105
- On DEV and STG, `createAccount()` auto-collects tokens. After creation you can also top up:
108
+ `createAccount()` auto-collects tokens from the env faucet whenever no `faucetPackage` is passed. Use DEV for testing. If the STG faucet fails its TLS handshake, see `removed-features.md`; passing a `faucetPackage` skips the faucet call on any env. PROD's faucet (`https://api-faucet.vocdoni.io/v2`) answers with a small package. After creation you can also top up:
106
109
 
107
110
  ```ts
108
- const info = await client.createAccount();
111
+ const info = await client.createAccount({ sik: false });
109
112
  if (info.balance === 0) {
110
- await client.collectFaucetTokens(); // dev/stg only; throws on prod
113
+ await client.collectFaucetTokens(); // uses the env faucet
111
114
  }
112
115
  ```
113
116
 
114
117
  If you want the raw payload (e.g. to inspect it):
115
118
 
116
119
  ```ts
117
- const b64 = await client.fetchFaucetPayload(); // dev/stg only
120
+ const b64 = await client.fetchFaucetPayload(); // uses the env faucet
118
121
  const parsed = client.parseFaucetPackage(b64); // decode the base64
119
122
  ```
120
123
 
121
- On PROD, the faucet endpoint is disabled. Pass a faucet package obtained out-of-band:
124
+ For real budgets on PROD, pass a faucet package signed by a funded account:
122
125
 
123
126
  ```ts
124
- await client.createAccount({ faucetPackage: '<base64 string from Vocdoni>' });
127
+ await client.createAccount({ faucetPackage: '<base64 string from a funded account>', sik: false });
125
128
  ```
126
129
 
130
+ The SDK's `faucetPackage` is the base64 of a JSON object, not of the protobuf. `parseFaucetPackage` runs `JSON.parse(base64decode(pkg))` and reads two fields:
131
+
132
+ ```json
133
+ { "faucetPayload": "<base64 of the FaucetPayload protobuf bytes>", "signature": "<base64 of the signature bytes>" }
134
+ ```
135
+
136
+ Both fields are standard base64 of raw bytes, which is how Go's `encoding/json` writes a `[]byte`. Take `Payload` and `Signature` from `vochain.GenerateFaucetPackage` (vocdoni-node), marshal them as that JSON object (the faucet service in `api/faucet` does the same), then base64 the whole string. Encoding the protobuf directly (base64 of the bytes, with no JSON wrapper) throws `Invalid faucet package`.
137
+
127
138
  If you bootstrap and the same wallet calls `collectFaucetTokens()` twice (already funded), the call rejects.
128
139
 
129
140
  ## Transfer tokens between accounts
@@ -171,7 +182,7 @@ This wallet can be used for both census membership and voting. Combine it with a
171
182
  - `createAccount` — register + optional faucet (idempotent).
172
183
  - `updateAccountInfo(account)` — change metadata.
173
184
  - `fetchAccountInfo([address])` / `fetchAccount([address])` — read state.
174
- - `collectFaucetTokens([package])` — top up on DEV/STG.
185
+ - `collectFaucetTokens([package])` — top up from the faucet.
175
186
  - `sendTokens({ to, amount, wallet? })` — transfer.
176
187
 
177
188
  That's the full account API. The next thing you need is a census of voters — see `census.md`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Companion to the [[vocdoni-sdk]] skill. Use this when deciding which census class to use for a given election, how to add voters, how publishing works, or how `CspCensus` (blind-signature gate) and `PublishedCensus` (re-use of an existing census) fit in.
4
4
 
5
- For token-holder censuses (ERC20/ERC721 from real chains), see `census3.md` — those produce `TokenCensus`/`StrategyCensus`, which extend `PublishedCensus` and plug into elections the same way.
5
+ Token-holder censuses (Census3) are gone, see `removed-features.md`; snapshot the holders into a `WeightedCensus` instead.
6
6
 
7
7
  ## Census types and when to use each
8
8
 
@@ -12,8 +12,6 @@ For token-holder censuses (ERC20/ERC721 from real chains), see `census3.md` —
12
12
  | `WeightedCensus` | Built locally, custom weights | Voters have different stakes (token balances, shares, credits for quadratic/budget elections). |
13
13
  | `CspCensus` | Reference to a CSP service | Identity is gated by an external authority via blind signatures (KYC, allowlist, anti-Sybil API). |
14
14
  | `PublishedCensus` | Reference to an already-published census | Re-using a census you previously published, or one published by another tool. |
15
- | `TokenCensus` | Census3 (from `census3.md`) | Holders of a single ERC20/ERC721 on a real chain. |
16
- | `StrategyCensus` | Census3 (from `census3.md`) | Multi-token predicate (`(A OR B) AND C`), with optional `minBalance` per token. |
17
15
 
18
16
  The first three are common; pick by election shape.
19
17
 
@@ -23,9 +21,9 @@ Internally the SDK distinguishes by `CensusType`:
23
21
 
24
22
  ```ts
25
23
  enum CensusType {
26
- WEIGHTED = 'weighted', // off-chain merkle (PlainCensus, WeightedCensus, TokenCensus non-anon, StrategyCensus non-anon)
27
- ANONYMOUS = 'zkweighted', // off-chain merkle + ZK proofs (anonymous voting)
28
- CSP = 'csp', // CspCensus
24
+ WEIGHTED = 'weighted', // PlainCensus, WeightedCensus
25
+ ANONYMOUS = 'zkweighted', // rejected: POST /censuses/zkweighted answers 410
26
+ CSP = 'csp', // CspCensus; published as census origin OFF_CHAIN_CA_V2 since SDK 0.10.0
29
27
  UNKNOWN = 'unknown',
30
28
  }
31
29
  ```
@@ -86,6 +84,8 @@ const census = new CspCensus(
86
84
 
87
85
  There's no `.add()` — there's no participant list locally. The CSP authority decides who can vote at vote time. See `csp.md` for the full voting flow (it has multi-step auth with the CSP server).
88
86
 
87
+ Since SDK 0.10.0 this election is published as census origin `OFF_CHAIN_CA_V2`, so the CSP must sign with the V2 salt (see `csp.md`).
88
+
89
89
  ## `PublishedCensus` — reference an existing census
90
90
 
91
91
  If a census was already created (by you in a previous run, or by another tool), reference it without rebuilding:
@@ -96,7 +96,7 @@ import { CensusType, PublishedCensus } from '@vocdoni/sdk';
96
96
  const census = new PublishedCensus(
97
97
  '<merkle root, hex>', // censusId
98
98
  '<ipfs:// uri>', // censusURI
99
- CensusType.WEIGHTED, // or ANONYMOUS, CSP
99
+ CensusType.WEIGHTED, // or CSP
100
100
  /* size? */ 1234,
101
101
  /* weight? */ BigInt('1000000'),
102
102
  );
@@ -144,7 +144,7 @@ const proof = await client.censusService.fetchProof(censusId, voterAddress);
144
144
  - **Addresses must be valid Ethereum addresses.** The SDK calls `isAddress()`. Comparison is case-insensitive internally; both `0xAbCd…` and `0xabcd…` work.
145
145
  - **Weights are `bigint`.** Don't pass `Number`. Use `BigInt(123)` or `123n`.
146
146
  - **Census must be published before the election is created.** `client.createElection()` handles this automatically for local `PlainCensus` / `WeightedCensus`. If you instantiate a `PublishedCensus` with a wrong root/URI, election creation will succeed but voting will fail (no proof generatable).
147
- - **Census class ↔ election type pairing.** Anonymous elections (`electionType.anonymous = true`) need an anonymous-type census (built the same way but published as `ANONYMOUS`; see `anonymous.md`). CSP elections need `CspCensus`. Mixing them produces opaque errors at vote time.
147
+ - **Census class ↔ election type pairing.** CSP elections need `CspCensus`. Mixing census and election types produces opaque errors at vote time.
148
148
  - **Dynamic census.** If you set `electionType.dynamicCensus = true` you can add voters after election creation via `client.changeElectionCensus(electionId, censusId, censusURI, maxCensusSize?)`. Otherwise the census is locked at creation.
149
149
  - **`maxCensusSize`.** On the election you may set `maxCensusSize` to cap eligible voters; it must be ≥ actual census size at creation. Setting it lets you later add voters up to that cap with `client.changeElectionMaxCensusSize(...)`.
150
150
 
@@ -152,6 +152,5 @@ const proof = await client.censusService.fetchProof(censusId, voterAddress);
152
152
 
153
153
  - `elections.md` — how a census is passed into `Election.from({ census })`.
154
154
  - `voting.md` — `client.isInCensus()`, vote submission proof generation.
155
- - `anonymous.md` — how anonymous censuses differ.
156
155
  - `csp.md` — full CSP flow.
157
- - `census3.md` — token-holder censuses producing `TokenCensus`/`StrategyCensus`.
156
+ - `removed-features.md` — the dropped census types (Census3 tokens, anonymous).
@@ -5,7 +5,7 @@ Companion to the [[vocdoni-sdk]] skill. Use this when setting up the main client
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- npm i @vocdoni/sdk
8
+ npm i @vocdoni/sdk@0.10.0
9
9
  # or yarn add / pnpm add
10
10
  ```
11
11
 
@@ -39,7 +39,7 @@ new VocdoniSDKClient(opts: ClientOptions)
39
39
  | `wallet` | `Wallet \| Signer \| RemoteSigner` | `undefined` | The signer used for every transaction. Can be set/replaced later via `client.wallet = …`. |
40
40
  | `electionId` | `string` | `undefined` | Pre-binds an election ID so vote/check methods don't need it on every call. Also settable via `client.setElectionId(id)`. |
41
41
  | `api_url` | `string` | env default | Override the API base URL. Most users never need this. |
42
- | `faucet` | `Partial<FaucetOptions>` | env default | Override faucet token limit on dev/stg. |
42
+ | `faucet` | `Partial<FaucetOptions>` | env default | Override faucet `url` / `token_limit`. |
43
43
  | `tx_wait` | `{ retry_time?: number; attempts?: number }` | `{ retry_time: 5000, attempts: 6 }` | Transaction-confirmation polling. Total wall-clock cap ≈ `retry_time * attempts`. |
44
44
  | `census` | `{ async?: boolean; wait_time?: number; chunk?: number }` | `{ async: true, wait_time: 5000, chunk: 8192 }` | Tuning for census creation/publish — chunk size, async polling cadence. |
45
45
 
@@ -47,9 +47,9 @@ new VocdoniSDKClient(opts: ClientOptions)
47
47
 
48
48
  ```ts
49
49
  enum EnvOptions {
50
- DEV = 'dev', // api: api-dev.vocdoni.net | resets often, faucet auto-funds, fastest iteration
51
- STG = 'stg', // api: api-stg.vocdoni.net | stable testnet, RECOMMENDED for development
52
- PROD = 'prod', // api: api.vocdoni.io | mainnet; faucet disabled; needs real tokens
50
+ DEV = 'dev', // testing; faucet auto-funds; recommended for development
51
+ STG = 'stg', // stable API; its faucet can fail (see removed-features.md); DEV for testing
52
+ PROD = 'prod', // mainnet; faucet hands out only a small package, real budgets need a faucet package from a funded account
53
53
  }
54
54
  ```
55
55
 
@@ -61,6 +61,8 @@ Default URLs per env:
61
61
  | STG | `https://api-stg.vocdoni.net/v2` | `https://api-stg.faucet.vocdoni.net/v2` | `https://stg.explorer.vote` |
62
62
  | PROD | `https://api.vocdoni.io/v2` | `https://api-faucet.vocdoni.io/v2` | `https://explorer.vote` |
63
63
 
64
+ Use DEV for testing; if the STG faucet fails, see `removed-features.md`. On PROD the faucet hands out only a small package; see `accounts.md`.
65
+
64
66
  `client.explorerUrl` returns the explorer URL for the active env — useful for links in logs (`{explorerUrl}/processes/show/#/{electionId}` and `{explorerUrl}/verify/#/{voteId}`).
65
67
 
66
68
  ## Signer choices
@@ -72,7 +74,7 @@ Default URLs per env:
72
74
  | Browser provider via `Web3Provider` | Frontend apps: MetaMask, WalletConnect, etc. Pass `provider.getSigner()`. |
73
75
  | `VocdoniSDKClient.generateWalletFromData([user, hashedPassword])` | Deterministic wallet derived from arbitrary data (e.g., login + password hash). Useful when voters don't own a wallet — covered in `accounts.md`. |
74
76
  | `client.generateRandomWallet()` | Mutates `client.wallet` to a fresh random wallet and returns the private key. |
75
- | `RemoteSigner` | When signing happens behind an HTTP API (Vocdoni's SaaS or your own). See "Remote signer" below. |
77
+ | `RemoteSigner` | When signing happens behind your own HTTP signer service. See "Remote signer" below. |
76
78
 
77
79
  You can also swap the active signer at any time:
78
80
 
@@ -89,10 +91,10 @@ client.accountService // AccountService
89
91
  client.electionService // ElectionService
90
92
  client.voteService // VoteService
91
93
  client.censusService // CensusService
92
- client.anonymousService // AnonymousService (ZK voting)
94
+ client.anonymousService // AnonymousService (anonymous voting, which the chain no longer supports)
93
95
  client.cspService // CspService (blind-signature voting)
94
96
  client.chainService // ChainService (chain data, txInfo, dateToBlock, etc.)
95
- client.faucetService // FaucetService (dev/stg only)
97
+ client.faucetService // FaucetService (faucet HTTP client; no env gating)
96
98
  client.fileService // FileService (calculateCID for IPFS)
97
99
  ```
98
100
 
@@ -113,13 +115,13 @@ client.electionId // currently-bound election ID (or null)
113
115
 
114
116
  ## Remote signer
115
117
 
116
- For Vocdoni's SaaS (or any HTTP-based signer):
118
+ `RemoteSigner` talks to an HTTP service that implements five routes: `/auth/login`, `/auth/refresh`, `/auth/addresses`, `/transactions` and `/transactions/message`. Vocdoni's SaaS can still log in but no longer signs (its `/transactions*` routes were removed in October 2026), so this only works against a service you run yourself. See `removed-features.md`.
117
119
 
118
120
  ```ts
119
121
  import { RemoteSigner } from '@vocdoni/sdk';
120
122
 
121
123
  const signer = new RemoteSigner({
122
- url: 'https://saas.vocdoni.io',
124
+ url: SIGNER_URL, // your service that implements the routes above
123
125
  credentials: { email: 'me@example.com', password: '…' },
124
126
  });
125
127
  await signer.login(); // returns auth token; also refreshes internally
@@ -137,12 +139,12 @@ import { EnvOptions, VocdoniSDKClient } from '@vocdoni/sdk';
137
139
 
138
140
  const wallet = Wallet.createRandom();
139
141
  const client = new VocdoniSDKClient({
140
- env: EnvOptions.STG, // start here unless you have a reason to use DEV or PROD
142
+ env: EnvOptions.DEV, // start here; PROD is mainnet
141
143
  wallet,
142
144
  });
143
145
 
144
- console.log(client.url); // https://api-stg.vocdoni.net/v2
145
- console.log(client.explorerUrl); // https://stg.explorer.vote
146
+ console.log(client.url); // https://api-dev.vocdoni.net/v2
147
+ console.log(client.explorerUrl); // https://dev.explorer.vote
146
148
  ```
147
149
 
148
150
  That's the only client setup most apps ever need. From here, go to: