Skip to content

Commit de9c0a8

Browse files
committed
chore(SOLNENG-27): update golang for BV sandbox
1 parent c10a9e5 commit de9c0a8

File tree

5 files changed

+306
-116
lines changed

5 files changed

+306
-116
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Blockdaemon Stake
2+
BLOCKDAEMON_API_KEY=
3+
BLOCKDAEMON_STAKE_API_KEY=
4+
ETHEREUM_NETWORK=holesky # mainnet | holesky
5+
ETHEREUM_WITHDRAWAL_ADDRESS=
6+
PLAN_ID= # Optional. If provided, will use a specific validator plan.
Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
## Sample go staking app demo
2+
# Golang Ethereum staking with Builder Vault wallet
33

44

55
```mermaid
@@ -24,35 +24,34 @@ sequenceDiagram
2424
StakeClient ->> Blockchain: broadcast signed tx<br>(signed tx, deposit contract)
2525
```
2626

27-
<!--
28-
29-
# Get Plans
30-
http -b GET https://svc.blockdaemon.com/boss/v1/plans \
31-
X-API-KEY:$STAKE_API_KEY
32-
33-
# Post Intent
34-
http -b POST https://svc.blockdaemon.com/boss/v1/ethereum/holesky/stake-intents \
35-
X-API-KEY:$STAKE_API_KEY \
36-
accept:application/json \
37-
content-type:application/json \
38-
stakes:='[{"amount":"32000000000","withdrawal_address":"0x00000000219ab540356cBB839Cbe05303d7705Fa","fee_recipient":"0x93247f2209abcacf57b75a51dafae777f9dd38bc"}]'
27+
### Prerequisites
28+
- [Golang](https://go.dev/doc/install) or launch in [code-spaces](https://codespaces.new/Blockdaemon/demo-buildervault-stakingAPI?quickstart=1)
29+
- Register for a demo Builder Vault tenant: https://www.blockdaemon.com/get-started/builder-vault-sandbox-registration
30+
- Download SDK bundle provided in registration email (extract authentication certificates)
31+
- Place Builder Vault authentication certificate key-pair `client.crt` & `client.key` in this nodejs folder
32+
- Register for free Blockdaemon [RPC API key](https://docs.blockdaemon.com/reference/get-started-rpc#step-1-sign-up-for-an-api-key) and set in .env as BLOCKDAEMON_API_KEY
33+
- Register for free Blockdaemon [Staking API key](https://docs.blockdaemon.com/reference/get-started-staking-api#step-1-sign-up-for-an-api-key) and set in .env as BLOCKDAEMON_STAKE_API_KEY
34+
35+
### Step 1. Set environment variables in .env
36+
```shell
37+
cd ethereum-staking/buildervault/golang/
38+
cp .env.example .env
39+
```
40+
- update .env with API keys
3941

40-
# Get Intents
41-
http -b GET https://svc.blockdaemon.com/boss/v1/stake-intents?protocols=ethereum&networks=holesky \
42-
X-API-KEY:$STAKE_API_KEY
42+
### Step 2. Launch main.go to auto-create the Builder Vault wallet address on first run
43+
```shell
44+
go run main.go
4345
```
46+
- note, on first run this step will fail as the wallet address has no funds
47+
- copy the new Ethereum wallet address and fund the account
4448

45-
sequenceDiagram
46-
autonumber
47-
participant StakeClient as Sample stake<br> client application
48-
participant StakeAPI as Stake Intent API
49-
participant Blockchain as Blockchain
50-
participant TSM as Sender Wallet Vault<br>(private key)
49+
### Step 3. Fund the new Ethereum wallet address with 33 ETH using faucets below
50+
- https://holesky-faucet.pk910.de/#/
5151

52-
StakeClient ->> StakeAPI: get StakeIntent unsigned tx data <br>(amount, withdrawal & recipient address)
53-
StakeClient ->> Blockchain: get blockchain inputs for new tx<br>(gas fee, chainID, sender wallet nonce)
54-
StakeClient ->> StakeClient: construct unsigned tx
55-
StakeClient ->> TSM: request signature of unsigned tx
56-
TSM ->> StakeClient: return tx signature
57-
StakeClient ->> Blockchain: broadcast signed tx<br>(signed tx, deposit contract)
58-
--!>
52+
### Step 4. Launch main.go to generate the Stake Intent request, sign the request with BuilderVault and broadcast the transaction
53+
```shell
54+
go run main.go
55+
```
56+
- (optional) decode the raw unsigned transaction to inspect the Blockdaemon provided attributes (https://rawtxdecode.in)
57+
- observe the confirmed transaction through the generated blockexplorer link

ethereum-staking/buildervault/golang/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/go-ole/go-ole v1.3.0 // indirect
2525
github.com/gorilla/websocket v1.4.2 // indirect
2626
github.com/holiman/uint256 v1.2.4 // indirect
27+
github.com/joho/godotenv v1.5.1 // indirect
2728
github.com/mmcloughlin/addchain v0.4.0 // indirect
2829
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
2930
github.com/supranational/blst v0.3.11 // indirect

ethereum-staking/buildervault/golang/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
9292
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
9393
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
9494
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
95+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
96+
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
9597
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
9698
github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
9799
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=

0 commit comments

Comments
 (0)