Load ABI conditionally based on chosen chain

This commit is contained in:
2024-10-27 10:14:15 +00:00
parent 51c59e8dde
commit 7bb8099fef
2 changed files with 4 additions and 2 deletions

View File

@@ -1,2 +1,3 @@
NEXT_PUBLIC_RPC_URL=
NEXT_PUBLIC_CONTRACT_ADDRESS=
NEXT_PUBLIC_CONTRACT_ADDRESS=
CHAIN=

View File

@@ -1,5 +1,6 @@
import { ethers } from 'ethers';
import EventManagerABI from '../contracts/EventManagerABI.json';
import EventManagerBaseABI from '../contracts/EventManagerBaseABI.json';
const FLARE_TESTNET_RPC_URL = process.env.NEXT_PUBLIC_RPC_URL;
const CONTRACT_ADDRESS = process.env.NEXT_PUBLIC_CONTRACT_ADDRESS;
@@ -13,6 +14,6 @@ export function getFlareProvider() {
export function getContract() {
const provider = getFlareProvider();
const contractAddress = CONTRACT_ADDRESS;
const contractABI = EventManagerABI;
const contractABI = (process.env.CHAIN == "flare") ? EventManagerABI : EventManagerBaseABI;
return new ethers.Contract(contractAddress!, contractABI, provider);
}