Skip to content

Commit 659eb25

Browse files
staking guide updated (#174)
1 parent d06f803 commit 659eb25

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

docs/developer-hub/building-on-0g/contracts-on-0g/staking-interfaces.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,21 @@ galileo/
213213
```
214214

215215
### Step 1: Extract Public Key
216+
217+
`0gchaind-home/config` directory will look like this:
218+
```
219+
0gchaind-home/
220+
├── config/
221+
├── genesis.json
222+
├── priv_validator_key.json
223+
└── ...
224+
```
225+
226+
Make sure to use data path that is used for validator node setup.
227+
216228
```bash
217229
# Set your home directory
218-
HOMEDIR=/.tmp/0gchaind
230+
HOMEDIR={your data path}/0g-home/0gchaind-home
219231
CHAIN_SPEC=devnet
220232

221233
# Generate validator keys
@@ -284,6 +296,10 @@ curl -X POST https://evmrpc-testnet.0g.ai \
284296
```
285297
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000001e776a6b65892ec60537a885c17b820301e054b9"}
286298
```
299+
Remove the zero paddings to get the validator address.
300+
```
301+
0x1e776a6b65892ec60537a885c17b820301e054b9
302+
```
287303

288304
</TabItem>
289305
</Tabs>
@@ -293,9 +309,7 @@ curl -X POST https://evmrpc-testnet.0g.ai \
293309
Use the validator's contract address from Step 2 to generate signature.
294310

295311
```bash
296-
# Set your home directory
297-
HOMEDIR=/.tmp/0gchaind
298-
CHAIN_SPEC=devnet
312+
# set your params
299313
VALIDATOR_CONTRACT_ADDRESS=0x1e776a6b65892ec60537a885c17b820301e054b9
300314
VALIDATOR_INITIAL_DELEGATION_IN_GWEI=32000000000 # 32 ethers
301315

@@ -316,6 +330,44 @@ pubkey: 0xaa0f99735a6436d6b7ed763c2eaa8452d753c5152a4fb1e4dc0bd7e33bcfc8cd4fac0e
316330
signature: 0x123456789000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
317331
```
318332

333+
## Initialize Validator
334+
To initialize the validator, you need to call the `createAndInitializeValidatorIfNecessary` function with the public key and signature from the previous step. The value should be set to minimum 32 OG tokens as the minimum initial delegation.
335+
336+
```solidity
337+
// SPDX-License-Identifier: MIT
338+
pragma solidity ^0.8.0;
339+
340+
interface IStaking {
341+
struct Description {
342+
string moniker;
343+
string identity;
344+
string website;
345+
string securityContact;
346+
string details;
347+
}
348+
349+
function createAndInitializeValidatorIfNecessary(
350+
Description calldata description,
351+
uint32 commissionRate,
352+
uint96 withdrawalFeeInGwei,
353+
bytes calldata pubkey,
354+
bytes calldata signature
355+
) external payable returns (address);
356+
357+
function getValidator(bytes memory pubkey) external view returns (address);
358+
359+
function computeValidatorAddress(bytes calldata pubkey) external view returns (address);
360+
}
361+
362+
```
363+
364+
- `description`: The validator's description struct
365+
- `commissionRate`: The validator's commission rate
366+
- `withdrawalFeeInGwei`: The validator's withdrawal fee
367+
- `pubkey`: The validator's public key
368+
- `signature`: The validator's signature
369+
370+
319371
## Data Structures
320372

321373
<details>

0 commit comments

Comments
 (0)