smart-lookup/core/web3.ts

50 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2022-06-09 18:10:35 +00:00
import { ethers } from "ethers";
2023-03-06 12:02:27 +00:00
export const networks: Record<string, string> = {
2022-06-09 18:10:35 +00:00
mainnet: "https://rpc.ankr.com/eth",
polygon: "https://rpc.ankr.com/polygon",
avalanche: "https://rpc.ankr.com/avalanche",
fantom: "https://rpc.ankr.com/fantom",
optimism: "https://rpc.ankr.com/optimism",
arbitrum: "https://rpc.ankr.com/arbitrum",
2023-03-06 12:02:27 +00:00
gnosis: "https://rpc.ankr.com/gnosis",
bsc: "https://rpc.ankr.com/bsc",
2022-06-09 18:10:35 +00:00
};
2023-03-06 12:02:27 +00:00
export const networkScanBaseUrl: Record<string, string> = {
2022-06-09 18:10:35 +00:00
mainnet: "https://etherscan.io/",
polygon: "https://polygonscan.com/",
avalanche: "https://snowtrace.io/",
fantom: "https://ftmscan.com/",
optimism: "https://optimistic.etherscan.io/",
arbitrum: "https://arbiscan.io/",
2023-03-06 12:02:27 +00:00
gnosis: "https://gnosisscan.io/",
bsc: "https://bscscan.com/",
2022-06-09 18:10:35 +00:00
};
export type Network = keyof typeof networks;
export const gnosisSafeAbi = [
{
inputs: [],
name: "getOwners",
outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "getThreshold",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
];
export const networkProviderMap = Object.keys(networks).reduce((acc, curr) => {
acc[curr] = new ethers.providers.JsonRpcProvider(networks[curr]);
return acc;
2023-03-06 12:02:27 +00:00
}, {} as Record<string, ethers.providers.JsonRpcProvider>);