forked from rhinofi/client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02.deposit.js
executable file
·54 lines (41 loc) · 1.39 KB
/
02.deposit.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
48
49
50
51
52
53
#!/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 waitForDepositCreditedOnChain = require('./helpers/waitForDepositCreditedOnChain')
const depositResponse = await dvf.deposit('ETH', 0.70, starkPrivKey)
if (process.env.WAIT_FOR_DEPOSIT_READY === 'true') {
await waitForDepositCreditedOnChain(dvf, depositResponse)
}
logExampleResult(depositResponse)
})()
.catch(error => {
console.error(error)
process.exit(1)
})