-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
66 lines (56 loc) · 1.95 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { SSVSDK } from "ssv-sdk";
import { createValidatorKeys } from "ssv-sdk/dist/libs/utils/methods/create-validator-keys";
console.log("SSVSDK:", SSVSDK);
const sdk = new SSVSDK({
chain: "holesky",
private_key: "0x_your_private_key_here",
});
// (async () => {
// // api usage
// const operator = await sdk.api.getOperator({ id: "844" });
// // direct contract interaction (read)
// const contractOperator = await sdk.contract.ssv.read.getOperatorById({
// operatorId: 844n,
// });
// // direct contract interaction (write)
// const tx = await sdk.contract.ssv.write.registerOperator({
// args: {
// publicKey: `0x...`,
// fee: 10000000000n,
// setPrivate: true,
// },
// });
// // to wait for the transaction to be mined
// await tx.wait();
// // smart functions that will send the transaction for you
// const { keystores } = await createValidatorKeys({
// count: 1,
// chain: "holesky",
// withdrawal: `0x...`,
// password: "123123123",
// });
// // 1st way to register validators -----------------------
// const extracted = await sdk.utils.generateKeyShares({
// keystore: JSON.stringify(keystores[0]),
// keystore_password: "123123123",
// operator_keys: [],
// operator_ids: [],
// owner_address: `0x...`,
// nonce: 1,
// });
// const receipt = await sdk.clusters
// .registerValidators({
// keyshares: [extracted],
// })
// .then((tx) => tx.wait());
// // ----------------------------------------------------------------
// // 2nd way to register validators -----------------------
// const shares = await sdk.utils.createShares({
// operatorIds: [],
// keyshares: "", // a keyshares file string or an object
// });
// const receipt = await sdk.clusters
// .registerValidators({ keyshares: shares.available })
// .then((tx) => tx.wait());
// // ----------------------------------------------------------------
// })();