-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
48 lines (36 loc) · 1.2 KB
/
App.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
/* @unsachdeva */
import React, { Component } from 'react';
import {
Text
} from 'react-native';
import HDWalletProvider from 'truffle-hdwallet-provider';
import Web3 from 'web3';
import truffleConfig from './truffle'
//Add this file with `MY_ADDRESS` and `MY_ADDRESS` as Strings
import { MY_ADDRESS, MNEMONIC } from './constants'
const wethArtifact = require('canonical-weth');
const contract = require('truffle-contract');
type Props = {};
export default class App extends Component<Props> {
async doStuff() {
const network = truffleConfig.networks.rinkeby;
const TESTRPC_ADDRESS = `${network.protocol}://${network.host}/`;
const web3Provider = new HDWalletProvider(MNEMONIC, TESTRPC_ADDRESS);
web3 = new Web3(web3Provider);
let wethContract = contract(wethArtifact);
wethContract.setProvider(web3Provider)
let wethDeployed = wethContract.at('0xc778417e063141139fce010982780140aa0cd5ab')
var txn = await wethDeployed.deposit({ from: MY_ADDRESS, value: 0.001 * 1e18, gas: 2000000 })
console.warn(txn)
}
async componentDidMount() {
await this.doStuff();
}
render() {
return (
<Text>
Welcome to React Native with Blockchain!
</Text>
);
}
}