1
1
import Web3 from "web3" ;
2
2
import 'dotenv/config'
3
- import { BuildervaultWeb3Provider } from "@blockdaemon/buildervault-web3-provider" ;
3
+ import { createEIP1193Provider } from "@blockdaemon/buildervault-web3-provider" ;
4
4
5
5
6
6
type CreateStakeIntentRequest = {
@@ -66,8 +66,17 @@ async function main() {
66
66
throw new Error ( 'ETHEREUM_WITHDRAWAL_ADDRESS environment variable not set' ) ;
67
67
}
68
68
69
- const eip1193Provider = new BuildervaultWeb3Provider ( {
70
- rpcUrl : process . env . BLOCKDAEMON_RPC_URL ,
69
+ if ( ! process . env . BLOCKDAEMON_RPC_URL ) {
70
+ throw new Error ( 'BLOCKDAEMON_RPC_URL environment variable not set' ) ;
71
+ }
72
+
73
+ const chain = {
74
+ chainName : "Ethereum Holesky" ,
75
+ chainId : "0x4268" ,
76
+ rpcUrls : [ process . env . BLOCKDAEMON_RPC_URL ] ,
77
+ } ;
78
+
79
+ const eip1193Provider = await createEIP1193Provider ( {
71
80
playerCount : Number ( process . env . BUILDERVAULT_PLAYER_COUNT ) ,
72
81
73
82
player0Url : process . env . BUILDERVAULT_PLAYER0_URL ,
@@ -91,15 +100,16 @@ async function main() {
91
100
player2ClientKey : process . env . BUILDERVAULT_PLAYER2_CLIENT_KEY ,
92
101
player2mTLSpublicKey : process . env . BUILDERVAULT_PLAYER2_MTLSPUBLICKEY ,
93
102
94
- masterKeyId : process . env . BUILDERVAULT_MASTERKEY_ID ,
103
+ masterKeyId : process . env . BUILDERVAULT_MASTERKEY_ID ! ,
95
104
accountId : Number ( process . env . BUILDERVAULT_ACCOUNT_ID ) ,
96
105
addressIndex : Number ( process . env . BUILDERVAULT_ADDRESS_INDEX ) ,
97
- logRequestsAndResponses : false // Verbose logging
106
+
107
+ chains : [ chain ] ,
98
108
} )
99
109
100
110
const web3 = new Web3 ( eip1193Provider ) ;
101
111
102
- const addresses = await web3 . eth . getAccounts ( ) ;
112
+ const addresses = await web3 . eth . requestAccounts ( ) ;
103
113
const address = addresses [ 0 ] ;
104
114
console . log ( "Ethereum addresses:" , address ) ;
105
115
console . log ( "Initial balance:" , await web3 . eth . getBalance ( address ) ) ;
0 commit comments