@voidifydao/sdk 2.0.0 → 2.0.1
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.
- package/README.md +0 -105
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Voidify SDK
|
|
2
|
-
|
|
3
|
-
[English](README.md) | [中文](docs/README.zh-CN.md) | [Русский](docs/README.ru.md) | [日本語](docs/README.ja.md)
|
|
4
|
-
|
|
5
|
-
`@voidifydao/sdk` is the Voidify SDK and CLI for deposits, private notes, relayer withdrawals, relayer services, and indexed protocol activity on Solana.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
As a library:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install @voidifydao/sdk
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
As a command-line tool:
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
npm install -g @voidifydao/sdk
|
|
19
|
-
voidify --help
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## CLI Setup
|
|
23
|
-
|
|
24
|
-
Generate a JSON configuration file, then fill in that same file:
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
voidify config init --type default --path ./voidify.json
|
|
28
|
-
voidify -c ./voidify.json config set programId YOUR_VOIDIFY_PROGRAM_ID
|
|
29
|
-
voidify -c ./voidify.json config set keypair.path /absolute/path/to/solana-keypair.json
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
For withdrawal proof generation, download the proof artifacts from the
|
|
33
|
-
[Voidify ceremony record v1.0.0 release](https://github.com/VoidifyCommunity/voidify-ceremony-record/releases/tag/v1.0.0).
|
|
34
|
-
Extract `withdraw.wasm` and `withdraw.zkey`, then place them at the
|
|
35
|
-
`proof.wasmPath` and `proof.zkeyPath` paths in the generated config.
|
|
36
|
-
|
|
37
|
-
All following commands use the generated `./voidify.json` file through `-c`.
|
|
38
|
-
|
|
39
|
-
## CLI Commands
|
|
40
|
-
|
|
41
|
-
Generate a private note:
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
voidify -c ./voidify.json note gen 1
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Deposit `1 SOL`. If `--commitment` is omitted, a new note is generated and printed:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
voidify -c ./voidify.json deposit 1
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
List deposits in a pool:
|
|
54
|
-
|
|
55
|
-
```sh
|
|
56
|
-
voidify -c ./voidify.json deposit list 1
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Withdraw through an automatically selected healthy relayer:
|
|
60
|
-
|
|
61
|
-
```sh
|
|
62
|
-
voidify -c ./voidify.json withdraw "YOUR_PRIVATE_NOTE" --recipient RECIPIENT_SOLANA_ADDRESS
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Choose a relayer by name:
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
voidify -c ./voidify.json withdraw "YOUR_PRIVATE_NOTE" --recipient RECIPIENT_SOLANA_ADDRESS --relayer RELAYER_NAME
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
> Keep your private note secure. Anyone with the note can withdraw the deposit, and a lost note cannot be recovered.
|
|
72
|
-
|
|
73
|
-
## Run a Relayer
|
|
74
|
-
|
|
75
|
-
Generate a relayer JSON configuration, fill in that file, then use it for relayer commands:
|
|
76
|
-
|
|
77
|
-
```sh
|
|
78
|
-
voidify config init --type relayer --path ./relayer.json
|
|
79
|
-
voidify -c ./relayer.json relayer start
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## SDK Usage
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
import { Context, Note, voidify } from "@voidifydao/sdk";
|
|
86
|
-
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
87
|
-
|
|
88
|
-
const wallet = Keypair.generate();
|
|
89
|
-
const ctx = new Context({
|
|
90
|
-
rpcUrl: "https://api.mainnet-beta.solana.com",
|
|
91
|
-
programId: new PublicKey("YOUR_VOIDIFY_PROGRAM_ID"),
|
|
92
|
-
wallet,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const note = await Note.generate("1");
|
|
96
|
-
const signature = await voidify.deposit(
|
|
97
|
-
ctx,
|
|
98
|
-
note.commitment,
|
|
99
|
-
1_000_000_000n,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
console.log(note.serialize(), signature);
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
The package also exports withdrawal helpers, relayer types, `VoidifyProgram`, substream clients and stores, and amount/note utilities.
|
package/package.json
CHANGED