Skip to content

Instantly share code, notes, and snippets.

@kdelwat
Created December 7, 2017 00:15
Show Gist options
  • Save kdelwat/18475b97a463a43e19a5b5bb87760906 to your computer and use it in GitHub Desktop.
Save kdelwat/18475b97a463a43e19a5b5bb87760906 to your computer and use it in GitHub Desktop.
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");
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