18 lines
638 B
JavaScript
18 lines
638 B
JavaScript
import contractAddresses from './addresses.json';
|
|
|
|
export const networks = {
|
|
localhost: '0x539',
|
|
sepolia: '0xaa36a7',
|
|
};
|
|
|
|
export const getContractByNetworkName = (networkName, contractName) => {
|
|
const address = contractAddresses[networkName][contractName];
|
|
if (!address) throw new Error(`Contract ${contractName} not recognized`);
|
|
return address;
|
|
};
|
|
|
|
export const getContractByChainId = (chainId, contractName) => {
|
|
const network = Object.entries(networks).find(([_, id]) => id === chainId)[0];
|
|
if (!network) throw new Error(`Chain ID ${chainId} not recognized`);
|
|
return getContractByNetworkName(network, contractName);
|
|
}; |