@skalenetwork/privacy-sdk 0.1.0-develop.1 → 0.1.0-develop.2
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 +60 -8
- package/dist/actions/index.cjs +1678 -1731
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +16 -18
- package/dist/actions/index.d.ts +16 -18
- package/dist/actions/index.js +5 -9
- package/dist/chunk-PMT6KSGL.js +2934 -0
- package/dist/chunk-PMT6KSGL.js.map +1 -0
- package/dist/index.cjs +1692 -1698
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/dist/types-CPLzL9IK.d.ts +13 -0
- package/dist/types-T84pCSPm.d.cts +13 -0
- package/package.json +6 -9
- package/dist/chunk-D3OIZD5L.js +0 -2953
- package/dist/chunk-D3OIZD5L.js.map +0 -1
- package/dist/types-CBDYydn0.d.cts +0 -60
- package/dist/types-Gn0F4pQf.d.ts +0 -60
package/README.md
CHANGED
|
@@ -10,9 +10,12 @@ npm install @skalenetwork/privacy-sdk
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
+
The SDK accepts any signer that implements `{ address, sendTransaction }`. Here's how to initialize with popular web3 libraries:
|
|
14
|
+
|
|
15
|
+
### With viem
|
|
16
|
+
|
|
13
17
|
```typescript
|
|
14
18
|
import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
|
|
15
|
-
import { deriveViewerKeypair } from "@skalenetwork/privacy-sdk/utils";
|
|
16
19
|
import { createWalletClient, http } from "viem";
|
|
17
20
|
import { privateKeyToAccount } from "viem/accounts";
|
|
18
21
|
|
|
@@ -27,6 +30,56 @@ const token = new ConfidentialWrapper({
|
|
|
27
30
|
sendTransaction: (tx) => walletClient.sendTransaction({ ...tx, chain: null }),
|
|
28
31
|
},
|
|
29
32
|
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### With ethers v6
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
|
|
39
|
+
import { Wallet, JsonRpcProvider } from "ethers";
|
|
40
|
+
|
|
41
|
+
const provider = new JsonRpcProvider(RPC_URL);
|
|
42
|
+
const wallet = new Wallet("0x...", provider);
|
|
43
|
+
|
|
44
|
+
const token = new ConfidentialWrapper({
|
|
45
|
+
rpcUrl: RPC_URL,
|
|
46
|
+
address: WRAPPER_ADDRESS,
|
|
47
|
+
signer: {
|
|
48
|
+
address: wallet.address as `0x${string}`,
|
|
49
|
+
sendTransaction: async (tx) => {
|
|
50
|
+
const resp = await wallet.sendTransaction(tx);
|
|
51
|
+
return resp.hash as `0x${string}`;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### With web3.js
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
|
|
61
|
+
import Web3 from "web3";
|
|
62
|
+
|
|
63
|
+
const web3 = new Web3(RPC_URL);
|
|
64
|
+
const account = web3.eth.accounts.privateKeyToAccount("0x...");
|
|
65
|
+
|
|
66
|
+
const token = new ConfidentialWrapper({
|
|
67
|
+
rpcUrl: RPC_URL,
|
|
68
|
+
address: WRAPPER_ADDRESS,
|
|
69
|
+
signer: {
|
|
70
|
+
address: account.address as `0x${string}`,
|
|
71
|
+
sendTransaction: async (tx) => {
|
|
72
|
+
const receipt = await web3.eth.sendTransaction({ from: account.address, ...tx });
|
|
73
|
+
return receipt.transactionHash as `0x${string}`;
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Usage
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { deriveViewerKeypair } from "@skalenetwork/privacy-sdk/utils";
|
|
30
83
|
|
|
31
84
|
// Derive viewer keypair from a signed message (do this once per account)
|
|
32
85
|
const sig = await walletClient.signMessage({ message: "SKALE Privacy Viewer Key", account });
|
|
@@ -35,11 +88,10 @@ token.setViewerPrivateKey(privateKey);
|
|
|
35
88
|
await token.registerViewerPublicKey(publicKey);
|
|
36
89
|
|
|
37
90
|
// Wrap underlying ERC-20 → confidential token (approve underlying first)
|
|
38
|
-
const { ctxHash } = await token.wrap(account.address, 1000n).waitForCtx();
|
|
91
|
+
const { ctxHash: wrapCtxHash } = await token.wrap(account.address, 1000n).waitForCtx();
|
|
39
92
|
|
|
40
|
-
// Confidential transfer
|
|
41
|
-
const
|
|
42
|
-
const { originHash, ctxHash } = await token.transfer(recipient, 500n).waitForCtx();
|
|
93
|
+
// Confidential transfer
|
|
94
|
+
const { ctxHash: transferCtxHash, ctxReceipt } = await token.transfer(recipient, 500n).waitForCtx();
|
|
43
95
|
|
|
44
96
|
// Decrypt balance
|
|
45
97
|
const balance = await token.decryptBalance();
|
|
@@ -50,7 +102,7 @@ await token.unwrap(account.address, 500n).waitForCtx();
|
|
|
50
102
|
|
|
51
103
|
## Docs
|
|
52
104
|
|
|
53
|
-
- [Concepts](https://github.com/skalenetwork/
|
|
54
|
-
- [Architecture](https://github.com/skalenetwork/
|
|
55
|
-
- [API Reference](https://github.com/skalenetwork/
|
|
105
|
+
- [Concepts](https://github.com/skalenetwork/privacy-sdk/blob/develop/docs/concepts.md) — CTX lifecycle, viewer keys, CtxPromise pattern
|
|
106
|
+
- [Architecture](https://github.com/skalenetwork/privacy-sdk/blob/develop/docs/architecture.md) — three-layer design (facades / actions / utils)
|
|
107
|
+
- [API Reference](https://github.com/skalenetwork/privacy-sdk/blob/develop/docs/api.md) — full method tables for all exports
|
|
56
108
|
|