@skalenetwork/privacy-sdk 0.1.0-develop.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.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @skalenetwork/privacy-sdk
2
+
3
+ TypeScript SDK for SKALE Programmable Privacy — encrypted ERC-20 transfers with on-chain confidential computation.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @skalenetwork/privacy-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
15
+ import { deriveViewerKeypair } from "@skalenetwork/privacy-sdk/utils";
16
+ import { createWalletClient, http } from "viem";
17
+ import { privateKeyToAccount } from "viem/accounts";
18
+
19
+ const account = privateKeyToAccount("0x...");
20
+ const walletClient = createWalletClient({ account, transport: http(RPC_URL) });
21
+
22
+ const token = new ConfidentialWrapper({
23
+ rpcUrl: RPC_URL,
24
+ address: WRAPPER_ADDRESS,
25
+ signer: {
26
+ address: account.address,
27
+ sendTransaction: (tx) => walletClient.sendTransaction({ ...tx, chain: null }),
28
+ },
29
+ });
30
+
31
+ // Derive viewer keypair from a signed message (do this once per account)
32
+ const sig = await walletClient.signMessage({ message: "SKALE Privacy Viewer Key", account });
33
+ const { privateKey, publicKey } = deriveViewerKeypair(sig);
34
+ token.setViewerPrivateKey(privateKey);
35
+ await token.registerViewerPublicKey(publicKey);
36
+
37
+ // Wrap underlying ERC-20 → confidential token (approve underlying first)
38
+ const { ctxHash } = await token.wrap(account.address, 1000n).waitForCtx();
39
+
40
+ // Confidential transfer — await for origin hash, .waitForCtx() for the full CTX result
41
+ const hash = await token.transfer(recipient, 500n);
42
+ const { originHash, ctxHash } = await token.transfer(recipient, 500n).waitForCtx();
43
+
44
+ // Decrypt balance
45
+ const balance = await token.decryptBalance();
46
+
47
+ // Unwrap back to ERC-20
48
+ await token.unwrap(account.address, 500n).waitForCtx();
49
+ ```
50
+
51
+ ## Docs
52
+
53
+ - [Concepts](https://github.com/skalenetwork/private-pay/blob/main/packages/privacy-sdk/docs/concepts.md) — CTX lifecycle, viewer keys, CtxPromise pattern
54
+ - [Architecture](https://github.com/skalenetwork/private-pay/blob/main/packages/privacy-sdk/docs/architecture.md) — three-layer design (facades / actions / utils)
55
+ - [API Reference](https://github.com/skalenetwork/private-pay/blob/main/packages/privacy-sdk/docs/api.md) — full method tables for all exports
56
+