Skip to content

Instantly share code, notes, and snippets.

@apow2
Created April 30, 2021 02:38
Show Gist options
  • Save apow2/8902dd999b32fd2a6582fd40d9e21cc0 to your computer and use it in GitHub Desktop.
Save apow2/8902dd999b32fd2a6582fd40d9e21cc0 to your computer and use it in GitHub Desktop.
import {web3, selectedAccount, chainId, connected} from "svelte-web3";
import {contractAddress, abi} from "./utils/contract.js";
let myContract;
let init = async () => {
await ethStore.setProvider("https://api.avax-test.network/ext/bc/C/rpc");
await ethStore.setBrowserProvider();
let contract = await new $web3.eth.Contract(abi, contractAddress);
if ($chainId != 43113) {
alert("Warning: You are not connected to Avalanche Fuji test-net!");
}
return contract;
};
setContext("myContract", init());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment