-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrinkeby.js
More file actions
25 lines (20 loc) · 979 Bytes
/
rinkeby.js
File metadata and controls
25 lines (20 loc) · 979 Bytes
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
const RequestNetwork = require('@requestnetwork/request-network.js');
const Web3 = require('web3');
var HDWalletProvider = require('truffle-hdwallet-provider');
var mnemonic = 'opinion maple cake sugar pudding cream honey rich smooth crumble sweet treat';
(async () => {
// Initialize web3 with infura provider
const web3 = new Web3(new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io:443'));
// Initialize the Request Network library
const requestNetwork = new RequestNetwork.default({
provider: web3.currentProvider,
ethNetworkId: 4,
useIpfsPublic: true,
});
// Retrieve a random request from the blockchain
const request = await requestNetwork.fromRequestId('0x8fc2e7f2498f1d06461ee2d547002611b801202b000000000000000000000140')
const data = await request.getData();
console.log(web3.utils.fromWei(data.payee.expectedAmount.toString()));
console.log(web3.utils.fromWei(data.payee.balance.toString()));
console.log(data.data);
})();