Created
December 7, 2017 00:15
-
-
Save kdelwat/18475b97a463a43e19a5b5bb87760906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Web3 from "web3"; | |
import { getWeb3 } from "./utils/web3"; | |
const Contract = require("truffle-contract"); | |
import * as SaleABI from "../../build/contracts/YabbySale.json"; | |
import * as CoinABI from "../../build/contracts/YabbyCoin.json"; | |
function showWeb3(divName: string, web3: Web3) { | |
const elt = document.getElementById(divName); | |
if (elt !== null) { | |
elt.innerText = web3.currentProvider.toString(); | |
} | |
} | |
const web3 = getWeb3(); | |
function getContract(ABI: any, web3: Web3) { | |
const contract = Contract(ABI); | |
contract.setProvider(web3); | |
return contract; | |
} | |
showWeb3("greeting", web3); | |
getContract(SaleABI, web3); | |
getContract(CoinABI, web3); | |
console.log("Loaded contracts"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Web3 from "web3"; | |
import { getWeb3 } from "./utils/web3"; | |
const Contract = require("truffle-contract"); | |
import * as SaleABI from "../../build/contracts/YabbySale.json"; | |
import * as CoinABI from "../../build/contracts/YabbyCoin.json"; | |
function showWeb3(divName: string, web3: Web3) { | |
const elt = document.getElementById(divName); | |
if (elt !== null) { | |
elt.innerText = web3.currentProvider.toString(); | |
} | |
} | |
const web3 = getWeb3(); | |
function getContract(ABI: any, web3: Web3) { | |
const contract = Contract(ABI); | |
contract.setProvider(web3); | |
return contract; | |
} | |
showWeb3("greeting", web3); | |
//getContract(SaleABI, web3); | |
//getContract(CoinABI, web3); | |
console.log("Loaded contracts"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment