-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (34 loc) · 1.14 KB
/
index.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
const Web3 = require("web3")
const ContractKit = require("@celo/contractkit")
const DEFAULT_TESTNET = "integration"
// 'alfajores', 'baklava' 'integration'
const provider = new Web3.providers.HttpProvider(
`https://${DEFAULT_TESTNET}-forno.celo-testnet.org`
)
const web3 = new Web3(provider)
const contractKit = ContractKit.newKitFromWeb3(web3)
web3.eth
.getTransactionReceipt("0x5b746527b888fb0567fb37d5a73a1894c2c3036deb31adebeb162d6691cf025f")
.then(console.log)
// Wei conversion when necessary
contractKit.contracts.getExchange().then(exchangeContract => {
exchangeContract.getExchangeRate(web3.utils.toWei("1000"), true).then(rate => {
console.log(rate.toString())
})
})
contractKit.contracts.getAccounts().then(accounts => {
accounts.getDataEncryptionKey("0xce10ce10ce10ce10ce10ce10ce10ce10ce10ce10").then(rate => {
console.log(rate)
})
})
contractKit.web3.eth.getBalance("0x9f2abD7DdCf7d4D1d988f92a6C546B89684262fc").then(bal => {
console.log(bal.toString())
})
contractKit._web3Contracts.getReserve().then(reserve => {
reserve.methods
.getOrComputeTobinTax()
.call()
.then(rate => {
console.log(rate)
})
})