Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 11:26
Show Gist options
  • Save percybolmer/e3f28afc77b70c9430548b206a3826c9 to your computer and use it in GitHub Desktop.
Save percybolmer/e3f28afc77b70c9430548b206a3826c9 to your computer and use it in GitHub Desktop.
async function connectToSelectedNetwork() {
// This will connect to the selected network inside MetaMask
const web3 = new Web3(Web3.givenProvider);
// Set the ABI of the Built contract so we can interact with it
const abi = await getABI();
const address = getContractAddress();
// Make a new instance of the contract by giving the address and abi
const devtoken = new web3.Contract(abi, address);
// Set the state of the app by passing the contract so we can reach it from other places
setDevToken(devtoken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment