Skip to content

Commit

Permalink
feat(holesky): EL script for DelegationManager.registerAsOperator
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Oct 23, 2024
1 parent 062bebb commit 8957188
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"registeringOperatorDetails": {
"earningsReceiver": "",
"delegationApprover": "",
"stakerOptOutWindowBlocks": ""
},
"metadataURI": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.25;
import {Script, console} from "forge-std/Script.sol";

import {IAVSDirectory} from "@eigenlayer/src/contracts/interfaces/IAVSDirectory.sol";
import {IDelegationManager} from "@eigenlayer/src/contracts/interfaces/IDelegationManager.sol";
import {ISignatureUtils} from "@eigenlayer/src/contracts/interfaces/ISignatureUtils.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand All @@ -19,9 +20,32 @@ contract RegisterEigenLayerOperator is Script {
uint256 expiry;
}

function run() public {
struct RegisterAsOperatorCalldata {
OperatorDetails registeringOperatorDetails;
string metadataURI;
}

function S01_registerAsOperator() public {
uint256 operatorSk = vm.envUint("OPERATOR_SK");
address operator = vm.addr(operatorSk);

IDelegationManager delegationManager = _readDelegationManager();

string memory json = vm.readFile("config/holesky/operators/eigenlayer/registerAsOperator.json");

bytes memory operatorDetailsRaw = vm.parseJson(json, ".operatorDetails");
OperatorDetails memory registeringOperatorDetails = abi.decode(operatorDetailsRaw, (OperatorDetails));

string memory metadataURI = vm.parseJsonString(json, ".metadataURI");

vm.startBroadcast(operatorSk);
delegationManager.registerAsOperator(registeringOperatorDetails, metadataURI);
console.log("Successfully run DelegationManager.registerAsOperator");
vm.stopBroadcast();
}

function run() public {
uint256 operatorSk = vm.envUint("OPERATOR_SK");
address operator = vm.addr(operatorSk);

BoltEigenLayerMiddlewareV1 middleware = _readMiddleware();
Expand Down Expand Up @@ -69,6 +93,14 @@ contract RegisterEigenLayerOperator is Script {
return IAVSDirectory(vm.parseJsonAddress(json, ".eigenLayer.avsDirectory"));
}

function _readDelegationManager() public view returns (IDelegationManager) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory json = vm.readFile(path);

return IDelegationManager(vm.parseJsonAddress(json, ".eigenLayer.delegationManager"));
}

function _readConfig(
string memory path
) public view returns (OperatorConfig memory) {
Expand Down
24 changes: 22 additions & 2 deletions testnets/holesky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,31 @@ If all goes well, your Symbiotic operator was registered into Bolt.
The Operator will be represented by an Ethereum address that needs to follow the
standard procedure outlined in the [EigenLayer
documentation](https://docs.eigenlayer.xyz/) to opt into EigenLayer. Let's go
through the steps:
documentation](https://docs.eigenlayer.xyz/) to opt into EigenLayer.

We've provided scripts for every step to facilitate the procedures. Please set
the operator private key to an `OPERATOR_SK` environment variable.

Let's go through the steps:

1. As an Operator, you register into EigenLayer using
[`DelegationManager.registerAsOperator`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/testnet-holesky/src/contracts/core/DelegationManager.sol#L107-L119).
To do that, you need to first configure the `OperatorDetails` and the
metadataURI in this JSON file:

```bash
$EDITOR ./config/holesky/operators/eigenlayer/registerAsOperator.json
```

Then you can run the following Forge script:

```bash
forge script script/holesky/operators/RegisterEigenLayerOperator.s.sol \
--sig "S01_registerAsOperator()" \
--rpc-url $HOLESKY_RPC \
-vvvv \
--broadcast
```

2. You can then use the same account to deposit into a supported EigenLayer
strategy using
Expand Down

0 comments on commit 8957188

Please sign in to comment.