UNPKG

web3-plugin-eas

Version:

Web3.js plugin for Ethereum Attestation Service(EAS)

57 lines (56 loc) 2.26 kB
import { Web3PluginBase, Contract } from "web3"; import { ContractAddresses } from "./utils"; import SchemaRegistryABI from "./abis/schemaRegistry"; import EASCoreABI from "./abis/eas"; export type SchemaRegistry = Contract<typeof SchemaRegistryABI>; export type EASCore = Contract<typeof EASCoreABI>; export declare class EASPlugin extends Web3PluginBase { pluginNamespace: string; /** * This method creates EAS's SchemaRegistry Contract instance of connected chain * @param address - SchemaRegistry Contract Address of connected chain * @returns SchemaRegistry Contract instance * @throws Error if address is not a valid address * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new EASPlugin()); * const SchemaRegistry = web3.eas.SchemaRegistry(SchemaRegistryAddress); * ``` */ schemaRegistry(address: string): SchemaRegistry; /** * This method creates EAS's EAS Contract instance of connected chain * @param address - EAS Contract Address of connected chain * @returns EASCore Contract instance * @throws Error if address is not a valid address * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new EASPlugin()); * const easCore = web3.eas.easCore(EASAddress); * ``` */ easCore(address: string): EASCore; /** * This method returns EAS's Contract Addresses of the given chain * * If no chainId is provided, it will use the connected chainId. * @param chainId ChainId of the network to get contract addresses of * @returns Contract Addresses object of the chain * @throws Error if chainId is not supported * @example * ```ts * const web3 = new Web3("http://127.0.0.1:8545"); * web3.registerPlugin(new EASPlugin()); * const addresses = web3.eas.getContractAddresses(1); //ChainId of Ethereum Mainnet * // or * const addresses = await web3.eas.getContractAddresses(); //returns addresses of connected chain * ``` */ getContractAddresses(chainId?: number): Promise<ContractAddresses>; } declare module "web3" { interface Web3Context { eas: EASPlugin; } }