forked from rhinofi/client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04.getBalance.js
executable file
·48 lines (37 loc) · 1.17 KB
/
04.getBalance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
/*
DO NOT EDIT THIS FILE BY HAND!
Examples are generated using helpers/buildExamples.js script.
Check README.md for more details.
*/
const HDWalletProvider = require('@truffle/hdwallet-provider')
const sw = require('starkware_crypto')
const Web3 = require('web3')
const DVF = require('../src/dvf')
const envVars = require('./helpers/loadFromEnvOrConfig')(
process.env.CONFIG_FILE_NAME
)
const logExampleResult = require('./helpers/logExampleResult')(__filename)
const ethPrivKey = envVars.ETH_PRIVATE_KEY
// NOTE: you can also generate a new key using:`
// const starkPrivKey = dvf.stark.createPrivateKey()
const starkPrivKey = envVars.STARK_PRIVATE_KEY
const rpcUrl = envVars.RPC_URL
const provider = new HDWalletProvider(ethPrivKey, rpcUrl)
const web3 = new Web3(provider)
provider.engine.stop()
const dvfConfig = {
api: envVars.API_URL,
dataApi: envVars.DATA_API_URL,
useAuthHeader: true
// Add more variables to override default values
}
;(async () => {
const dvf = await DVF(web3, dvfConfig)
const getBalanceResponse = await dvf.getBalance()
logExampleResult(getBalanceResponse)
})()
.catch(error => {
console.error(error)
process.exit(1)
})