@ssv-labs/ssv-sdk 0.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/LICENSE +674 -0
- package/README.html +102 -0
- package/README.md +136 -0
- package/README.pdf +0 -0
- package/dist/abi/holesky/v4/getter.d.ts +824 -0
- package/dist/abi/holesky/v4/setter.d.ts +1662 -0
- package/dist/abi/mainnet/v4/getter.d.ts +824 -0
- package/dist/abi/mainnet/v4/setter.d.ts +1677 -0
- package/dist/abi/token.d.ts +292 -0
- package/dist/api/ssv-api/index.d.ts +16 -0
- package/dist/api/subgraph/index.d.ts +101 -0
- package/dist/config/chains.d.ts +94 -0
- package/dist/config/create.d.ts +45 -0
- package/dist/config/globals.d.ts +33 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config-DPI30L0i.js +5159 -0
- package/dist/config-DlwfpwZd.mjs +5161 -0
- package/dist/contract-interactions/create.d.ts +3 -0
- package/dist/contract-interactions/index.d.ts +1 -0
- package/dist/contract-interactions/types.d.ts +93 -0
- package/dist/graphql/graphql.d.ts +3249 -0
- package/dist/libs/api/index.d.ts +81 -0
- package/dist/libs/cluster/index.d.ts +5636 -0
- package/dist/libs/cluster/methods/deposit.d.ts +286 -0
- package/dist/libs/cluster/methods/exit-validators.d.ts +283 -0
- package/dist/libs/cluster/methods/index.d.ts +8 -0
- package/dist/libs/cluster/methods/liquidate-cluster.d.ts +281 -0
- package/dist/libs/cluster/methods/reactivate-cluster.d.ts +282 -0
- package/dist/libs/cluster/methods/register-validators.d.ts +3652 -0
- package/dist/libs/cluster/methods/remove-validators.d.ts +283 -0
- package/dist/libs/cluster/methods/set-fee-recipient.d.ts +282 -0
- package/dist/libs/cluster/methods/withdraw.d.ts +282 -0
- package/dist/libs/operator/index.d.ts +4005 -0
- package/dist/libs/operator/methods.d.ts +844 -0
- package/dist/libs/utils/index.d.ts +32 -0
- package/dist/libs/utils/methods/get-cluster-balance.d.ts +9 -0
- package/dist/libs/utils/methods/index.d.ts +4 -0
- package/dist/libs/utils/methods/keyshares.d.ts +21 -0
- package/dist/libs/utils/methods/keystores.d.ts +13 -0
- package/dist/libs/utils/methods/methods.d.ts +2 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.js +36437 -0
- package/dist/main.mjs +36437 -0
- package/dist/mock/api.d.ts +3 -0
- package/dist/mock/config.d.ts +6 -0
- package/dist/mock/index.d.ts +8 -0
- package/dist/sdk.d.ts +14 -0
- package/dist/types/contract-interactions.d.ts +21 -0
- package/dist/types/methods.d.ts +3 -0
- package/dist/types/operator.d.ts +9 -0
- package/dist/types/utils.d.ts +3 -0
- package/dist/utils/bigint.d.ts +29 -0
- package/dist/utils/cluster.d.ts +8 -0
- package/dist/utils/contract.d.ts +3 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/keyshares.d.ts +21 -0
- package/dist/utils/number.d.ts +21 -0
- package/dist/utils/operator.d.ts +5 -0
- package/dist/utils/try-catch.d.ts +1 -0
- package/dist/utils/url-join.d.ts +1 -0
- package/dist/utils/zod/config.d.ts +9 -0
- package/dist/utils.js +43 -0
- package/dist/utils.mjs +43 -0
- package/package.json +136 -0
package/README.html
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<!DOCTYPE html><html><head>
|
|
2
|
+
<title>README</title>
|
|
3
|
+
<meta charset="utf-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5
|
+
|
|
6
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css">
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
<style>
|
|
13
|
+
code[class*=language-],pre[class*=language-]{color:#333;background:0 0;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.4;-moz-tab-size:8;-o-tab-size:8;tab-size:8;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:.8em;overflow:auto;border-radius:3px;background:#f5f5f5}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal;background:#f5f5f5}.token.blockquote,.token.comment{color:#969896}.token.cdata{color:#183691}.token.doctype,.token.macro.property,.token.punctuation,.token.variable{color:#333}.token.builtin,.token.important,.token.keyword,.token.operator,.token.rule{color:#a71d5d}.token.attr-value,.token.regex,.token.string,.token.url{color:#183691}.token.atrule,.token.boolean,.token.code,.token.command,.token.constant,.token.entity,.token.number,.token.property,.token.symbol{color:#0086b3}.token.prolog,.token.selector,.token.tag{color:#63a35c}.token.attr-name,.token.class,.token.class-name,.token.function,.token.id,.token.namespace,.token.pseudo-class,.token.pseudo-element,.token.url-reference .token.variable{color:#795da3}.token.entity{cursor:help}.token.title,.token.title .token.punctuation{font-weight:700;color:#1d3e81}.token.list{color:#ed6a43}.token.inserted{background-color:#eaffea;color:#55a532}.token.deleted{background-color:#ffecec;color:#bd2c00}.token.bold{font-weight:700}.token.italic{font-style:italic}.language-json .token.property{color:#183691}.language-markup .token.tag .token.punctuation{color:#333}.language-css .token.function,code.language-css{color:#0086b3}.language-yaml .token.atrule{color:#63a35c}code.language-yaml{color:#183691}.language-ruby .token.function{color:#333}.language-markdown .token.url{color:#795da3}.language-makefile .token.symbol{color:#795da3}.language-makefile .token.variable{color:#183691}.language-makefile .token.builtin{color:#0086b3}.language-bash .token.keyword{color:#0086b3}pre[data-line]{position:relative;padding:1em 0 1em 3em}pre[data-line] .line-highlight-wrapper{position:absolute;top:0;left:0;background-color:transparent;display:block;width:100%}pre[data-line] .line-highlight{position:absolute;left:0;right:0;padding:inherit 0;margin-top:1em;background:hsla(24,20%,50%,.08);background:linear-gradient(to right,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));pointer-events:none;line-height:inherit;white-space:pre}pre[data-line] .line-highlight:before,pre[data-line] .line-highlight[data-end]:after{content:attr(data-start);position:absolute;top:.4em;left:.6em;min-width:1em;padding:0 .5em;background-color:hsla(24,20%,50%,.4);color:#f4f1ef;font:bold 65%/1.5 sans-serif;text-align:center;vertical-align:.3em;border-radius:999px;text-shadow:none;box-shadow:0 1px #fff}pre[data-line] .line-highlight[data-end]:after{content:attr(data-end);top:auto;bottom:.4em}html body{font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ol,html body>ul{margin-bottom:16px}html body ol,html body ul{padding-left:2em}html body ol.no-list,html body ul.no-list{padding:0;list-style-type:none}html body ol ol,html body ol ul,html body ul ol,html body ul ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:700;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:700}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::after,html body code::before{letter-spacing:-.2em;content:'\00a0'}html body pre>code{padding:0;margin:0;word-break:normal;white-space:pre;background:0 0;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:after,html body pre code:before,html body pre tt:after,html body pre tt:before{content:normal}html body blockquote,html body dl,html body ol,html body p,html body pre,html body ul{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body code,html body pre{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview ul{list-style:disc}.markdown-preview ul ul{list-style:circle}.markdown-preview ul ul ul{list-style:square}.markdown-preview ol{list-style:decimal}.markdown-preview ol ol,.markdown-preview ul ol{list-style-type:lower-roman}.markdown-preview ol ol ol,.markdown-preview ol ul ol,.markdown-preview ul ol ol,.markdown-preview ul ul ol{list-style-type:lower-alpha}.markdown-preview .newpage,.markdown-preview .pagebreak{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center!important}.markdown-preview:not([data-for=preview]) .code-chunk .code-chunk-btn-group{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .status{display:none}.markdown-preview:not([data-for=preview]) .code-chunk .output-div{margin-bottom:16px}.markdown-preview .md-toc{padding:0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link div,.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}.markdown-preview .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0;min-height:100vh}@media screen and (min-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode]) .markdown-preview{font-size:14px!important;padding:1em}}@media print{html body[for=html-export]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for=html-export]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,.66);border:4px solid rgba(150,150,150,.66);background-clip:content-box}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc{padding:0 16px}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div,html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p{display:inline}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% - 300px);padding:2em calc(50% - 457px - 300px / 2);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for=html-export]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for=html-export]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
|
|
14
|
+
/* Please visit the URL below for more information: */
|
|
15
|
+
/* https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */
|
|
16
|
+
|
|
17
|
+
</style>
|
|
18
|
+
<!-- The content below will be included at the end of the <head> element. --><script type="text/javascript">
|
|
19
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
20
|
+
// your code here
|
|
21
|
+
});
|
|
22
|
+
</script></head><body for="html-export">
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<div class="crossnote markdown-preview ">
|
|
26
|
+
|
|
27
|
+
<h1 id="ssv-sdk">SSV SDK </h1>
|
|
28
|
+
<p>A TypeScript SDK for interacting with the SSV (Secret Shared Validator) network, enabling distributed validator operations on Ethereum.</p>
|
|
29
|
+
<h2 id="installation">Installation </h2>
|
|
30
|
+
<pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token function">pnpm</span> <span class="token function">install</span> ssv-sdk ssv-keys viem
|
|
31
|
+
<span class="token comment"># or</span>
|
|
32
|
+
<span class="token function">npm</span> <span class="token function">install</span> ssv-sdk ssv-keys viem
|
|
33
|
+
<span class="token comment"># or</span>
|
|
34
|
+
<span class="token function">yarn</span> <span class="token function">add</span> ssv-sdk ssv-keys viem
|
|
35
|
+
</code></pre><h2 id="usage">Usage </h2>
|
|
36
|
+
<h3 id="initialize-the-sdk">Initialize the SDK </h3>
|
|
37
|
+
<pre data-role="codeBlock" data-info="typescript" class="language-typescript typescript"><code><span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> <span class="token constant">SSVSDK</span> <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'ssv-sdk'</span>
|
|
38
|
+
|
|
39
|
+
<span class="token comment">// Initialize with basic configuration</span>
|
|
40
|
+
<span class="token keyword keyword-const">const</span> sdk <span class="token operator">=</span> <span class="token keyword keyword-new">new</span> <span class="token class-name"><span class="token constant">SSVSDK</span></span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
41
|
+
chain<span class="token operator">:</span> <span class="token string">'mainnet'</span><span class="token punctuation">,</span> <span class="token comment">// or holesky</span>
|
|
42
|
+
private_key<span class="token operator">:</span> <span class="token string">'0x.......'</span><span class="token punctuation">,</span>
|
|
43
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
44
|
+
</code></pre><h3 id="api-interactions">API Interactions </h3>
|
|
45
|
+
<pre data-role="codeBlock" data-info="typescript" class="language-typescript typescript"><code><span class="token keyword keyword-const">const</span> operators <span class="token operator">=</span> <span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>api<span class="token punctuation">.</span><span class="token function">getOperators</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
46
|
+
operatorIds<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">'220'</span><span class="token punctuation">,</span> <span class="token string">'221'</span><span class="token punctuation">,</span> <span class="token string">'223'</span><span class="token punctuation">,</span> <span class="token string">'224'</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
|
47
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
48
|
+
|
|
49
|
+
<span class="token keyword keyword-const">const</span> nonce <span class="token operator">=</span> <span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>api<span class="token punctuation">.</span><span class="token function">getOwnerNonce</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
50
|
+
owner<span class="token operator">:</span> <span class="token string">'0x'</span><span class="token punctuation">,</span>
|
|
51
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
52
|
+
</code></pre><h3 id="cluster-management">Cluster management </h3>
|
|
53
|
+
<pre data-role="codeBlock" data-info="typescript" class="language-typescript typescript"><code><span class="token comment">// Get cluster balance</span>
|
|
54
|
+
<span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> getClusterSnapshot <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'@/utils/cluster'</span>
|
|
55
|
+
<span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> <span class="token constant">SSVSDK</span> <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'ssv-sdk'</span>
|
|
56
|
+
|
|
57
|
+
<span class="token comment">// Initialize with basic configuration</span>
|
|
58
|
+
<span class="token keyword keyword-const">const</span> sdk <span class="token operator">=</span> <span class="token keyword keyword-new">new</span> <span class="token class-name"><span class="token constant">SSVSDK</span></span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
59
|
+
chain<span class="token operator">:</span> <span class="token string">'mainnet'</span><span class="token punctuation">,</span> <span class="token comment">// or holesky</span>
|
|
60
|
+
private_key<span class="token operator">:</span> <span class="token string">'0x.......'</span><span class="token punctuation">,</span>
|
|
61
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
62
|
+
|
|
63
|
+
<span class="token comment">// Get Cluster</span>
|
|
64
|
+
<span class="token keyword keyword-const">const</span> cluster <span class="token operator">=</span> <span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>api<span class="token punctuation">.</span><span class="token function">getCluster</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
65
|
+
id<span class="token operator">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
|
|
66
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
67
|
+
|
|
68
|
+
<span class="token keyword keyword-const">const</span> balance <span class="token operator">=</span> <span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>contract<span class="token punctuation">.</span>write<span class="token punctuation">.</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
69
|
+
cluster<span class="token operator">:</span> <span class="token function">getClusterSnapshot</span><span class="token punctuation">(</span>cluster<span class="token punctuation">)</span><span class="token punctuation">,</span>
|
|
70
|
+
clusterOwner<span class="token operator">:</span> <span class="token string">'0x'</span><span class="token punctuation">,</span>
|
|
71
|
+
operatorIds<span class="token operator">:</span> operators<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>o<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token function">BigInt</span><span class="token punctuation">(</span>o<span class="token punctuation">.</span>id<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
|
72
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
73
|
+
</code></pre><h3 id="cluster-management-1">Cluster Management </h3>
|
|
74
|
+
<pre data-role="codeBlock" data-info="typescript" class="language-typescript typescript"><code><span class="token keyword keyword-import">import</span> <span class="token punctuation">{</span> parseEther <span class="token punctuation">}</span> <span class="token keyword keyword-from">from</span> <span class="token string">'viem'</span>
|
|
75
|
+
|
|
76
|
+
<span class="token keyword keyword-await">await</span> sdk<span class="token punctuation">.</span>clusters<span class="token punctuation">.</span><span class="token function">deposit</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
|
77
|
+
id<span class="token operator">:</span> <span class="token string">'...'</span><span class="token punctuation">,</span>
|
|
78
|
+
amount<span class="token operator">:</span> <span class="token function">parseEther</span><span class="token punctuation">(</span><span class="token string">'1.5'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
|
79
|
+
options<span class="token operator">:</span> <span class="token punctuation">{</span>
|
|
80
|
+
approve<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token comment">// Automatically triggers token approval transaction if the allowance is lower than the deposit amount</span>
|
|
81
|
+
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
|
82
|
+
<span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
83
|
+
</code></pre><h3 id="environment-setup-for-testing">Environment Setup for Testing </h3>
|
|
84
|
+
<p>To run tests, you'll need to set up your environment variables. Create a <code>.env</code> file in the root directory of your project using the provided <code>.env.example</code> as a template:</p>
|
|
85
|
+
<pre data-role="codeBlock" data-info="bash" class="language-bash bash"><code><span class="token comment"># Copy the example env file</span>
|
|
86
|
+
<span class="token function">cp</span> .env.example .env
|
|
87
|
+
</code></pre><p>The <code>.env</code> file should contain the following variables:</p>
|
|
88
|
+
<pre data-role="codeBlock" data-info="typescript" class="language-typescript typescript"><code><span class="token constant">PRIVATE_KEY</span><span class="token operator">=</span>your_private_key_here
|
|
89
|
+
<span class="token constant">OWNER_ADDRESS</span><span class="token operator">=</span>your_owner_address_here
|
|
90
|
+
</code></pre><p>Make sure to never commit your actual <code>.env</code> file to version control. The <code>.env.example</code> file serves as a template showing which variables are required.</p>
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
</body></html>
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://ssv.network/wp-content/uploads/2024/06/full_logo_white.svg" alt="SSV Network" width="300"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">SSV SDK</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://codecov.io/gh/ssvlabs/ssv-sdk">
|
|
9
|
+
<img src="https://codecov.io/gh/ssvlabs/ssv-sdk/graph/badge.svg?token=2j2HCF1fSb" alt="codecov"/>
|
|
10
|
+
</a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
> **⚠️ Development Notice**: This SDK is currently under active development and testing. It is not recommended for production use at this time. For updates and documentation, please refer to our [official documentation](https://docs.ssv.network).
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
The SSV SDK is a TypeScript library for interacting with the SSV (Secret Shared Validator) network, enabling distributed validator operations on Ethereum.
|
|
18
|
+
|
|
19
|
+
## Core Modules
|
|
20
|
+
|
|
21
|
+
The SDK consists of four main modules:
|
|
22
|
+
|
|
23
|
+
- **Clusters**: Manage validator clusters, handle deposits, and register validators
|
|
24
|
+
- **Operators**: Interact with network operators and manage operator relationships
|
|
25
|
+
- **API**: Access network data, query states, and retrieve operational information
|
|
26
|
+
- **Utils**: Helper functions for keyshare validation, share generation, and other utilities
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Using npm
|
|
32
|
+
npm install ssv-sdk ssv-keys viem
|
|
33
|
+
|
|
34
|
+
# Using yarn
|
|
35
|
+
yarn add ssv-sdk ssv-keys viem
|
|
36
|
+
|
|
37
|
+
# Using pnpm
|
|
38
|
+
pnpm install ssv-sdk ssv-keys viem
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
### Initialize the SDK
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { SSVSDK, chains } from 'ssv-sdk'
|
|
47
|
+
import { createPublicClient, createWalletClient, http } from 'viem'
|
|
48
|
+
import { privateKeyToAccount } from 'viem/accounts'
|
|
49
|
+
|
|
50
|
+
const chain = chains.mainnet // or chains.holesky
|
|
51
|
+
const transport = http()
|
|
52
|
+
|
|
53
|
+
const publicClient = createPublicClient({
|
|
54
|
+
chain,
|
|
55
|
+
transport,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const account = privateKeyToAccount('0x...')
|
|
59
|
+
const walletClient = createWalletClient({
|
|
60
|
+
account,
|
|
61
|
+
chain,
|
|
62
|
+
transport,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const sdk = new SSVSDK({
|
|
66
|
+
publicClient,
|
|
67
|
+
walletClient,
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### API Examples
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// Query operators
|
|
75
|
+
const operators = await sdk.api.getOperators({
|
|
76
|
+
operatorIds: ['220', '221', '223', '224'],
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// Get owner nonce
|
|
80
|
+
const nonce = await sdk.api.getOwnerNonce({
|
|
81
|
+
owner: 'your_wallet_address',
|
|
82
|
+
})
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Cluster Management
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { parseEther } from 'viem'
|
|
89
|
+
|
|
90
|
+
// Deposit to cluster
|
|
91
|
+
await sdk.clusters.deposit(
|
|
92
|
+
{
|
|
93
|
+
id: 'your_cluster_id',
|
|
94
|
+
amount: parseEther('30'),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
approve: true, // Auto-approve token if needed
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Register Validators
|
|
103
|
+
To register validators, you'll need to:
|
|
104
|
+
|
|
105
|
+
1. Create shares from your keyshares JSON file
|
|
106
|
+
2. Register the validator using the created shares
|
|
107
|
+
```typescript
|
|
108
|
+
import { parseEther } from 'viem'
|
|
109
|
+
|
|
110
|
+
// Your keyshares JSON file containing the validator's data
|
|
111
|
+
import keyshares from 'path/to/keyshares.json'
|
|
112
|
+
|
|
113
|
+
// First, validate and create shares from your keyshares
|
|
114
|
+
try {
|
|
115
|
+
const result = await sdk.utils.validateSharesPreRegistration({
|
|
116
|
+
operatorIds: ['220', '221', '223', '224'],
|
|
117
|
+
keyshares,
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
// Register validators using the clusters API
|
|
121
|
+
const receipt = await sdk.clusters
|
|
122
|
+
.registerValidators({
|
|
123
|
+
args: {
|
|
124
|
+
keyshares: result.available,
|
|
125
|
+
depositAmount: parseEther('2'),
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
.then((tx) => tx.wait())
|
|
129
|
+
} catch (e) {
|
|
130
|
+
// something went wrong
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Documentation
|
|
135
|
+
|
|
136
|
+
For detailed documentation and examples, visit our [official documentation](https://docs.ssv.network).
|
package/README.pdf
ADDED
|
Binary file
|