@hinkal/common 0.0.98 → 0.0.100
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 +30 -13
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -1,48 +1,65 @@
|
|
|
1
1
|
# Hinkal SDK
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Hinkal is a middleware and set of smart contracts on EVM chains that uses ZK-proofs and stealth addresses to enable compliant and private transactions on major dApps. Users can privately store assets and transact on major dApps such as Uniswap, Pendle, Lido, Curve, and others.
|
|
4
|
+
|
|
5
|
+
This SDK allows to do arbitrary Smart Contract interactions privately.
|
|
6
|
+
|
|
3
7
|
### Installation
|
|
8
|
+
|
|
4
9
|
Using npm:
|
|
10
|
+
|
|
5
11
|
```sh
|
|
6
12
|
npm install @hinkal/common
|
|
7
13
|
```
|
|
14
|
+
|
|
8
15
|
Or, yarn:
|
|
16
|
+
|
|
9
17
|
```sh
|
|
10
18
|
yarn add @hinkal/common
|
|
11
19
|
```
|
|
20
|
+
|
|
12
21
|
### Usage
|
|
13
22
|
|
|
14
23
|
1. Step: import hinkal from @hinkal/common package and initiate a Hinkal instance:
|
|
15
|
-
```sh
|
|
16
|
-
import {Hinkal} from '@hinkal/common';
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
```sh
|
|
26
|
+
import {Hinkal} from '@hinkal/common';
|
|
27
|
+
|
|
28
|
+
const hinkal = new Hinkal<Connector>();
|
|
19
29
|
```
|
|
20
30
|
|
|
21
31
|
2. Initiate ProviderAdapter object, where connector should be 'wagmi' Connector instance
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const providerAdapter = new ProviderAdapter(connector);
|
|
35
|
+
await hinkal.initProviderAdapter(connector, providerAdapter);
|
|
25
36
|
```
|
|
26
37
|
|
|
27
38
|
3. Ask user to generate his shielded address and fetch state from smart contract
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
await hinkal.initUserKeys();
|
|
42
|
+
await hinkal.resetMerkle();
|
|
31
43
|
```
|
|
32
44
|
|
|
33
|
-
4. Once user generated shielded address, shielded balances are available that can be displayed in front-end:
|
|
45
|
+
4. Once user generated shielded address, shielded balances are available that can be displayed in front-end:
|
|
46
|
+
|
|
34
47
|
```typescript
|
|
35
|
-
|
|
48
|
+
const balances = await hinkal.getBalances();
|
|
36
49
|
```
|
|
37
50
|
|
|
38
51
|
5. A user can deposit to his shielded account using:
|
|
52
|
+
|
|
39
53
|
```typescript
|
|
40
54
|
hinkal.deposit(erc20addresses:string[],amountChanges:bigint[]);
|
|
41
55
|
```
|
|
56
|
+
|
|
42
57
|
where erc20Addresses is array of token addresses and amountChanges - token amounts for the deposit.
|
|
43
58
|
|
|
44
59
|
6. A user, once his balance is updated, can do any smart contract interaction:
|
|
60
|
+
|
|
45
61
|
```typescript
|
|
46
62
|
hinkal.actionPrivateWallet( erc20Addresses:string[], amountChanges:bigint[], onChainCreation:boolean[], ops:string[]);
|
|
47
63
|
```
|
|
48
|
-
|
|
64
|
+
|
|
65
|
+
where onChainCreation indicates amounts of tokens which are uncertain before the transaction is executed onchain. And, ops array is encoded array of user ops.
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hinkal/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.100",
|
|
4
4
|
"homepage": "hinkal.pro",
|
|
5
|
-
"author":
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Hinkal Protocol"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"blockchain",
|
|
10
|
+
"privacy",
|
|
11
|
+
"zero-knowledge",
|
|
12
|
+
"stealth addresses"
|
|
13
|
+
],
|
|
6
14
|
"type": "module",
|
|
7
15
|
"main": "index.mjs",
|
|
8
16
|
"module": "index.mjs",
|