Skip to main content

ContractFactory

An ethers Contract Factory. Given a ContractList, the ContractFactory will initialize ethers Contracts and easily provide Providers or Signers.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ContractFactory(signersOrProviders, contractList)

Create an instance of a ContractFactory by providing Signers or Providers keyed by their chain ids and a list of contract metadata.

Parameters

NameTypeDescription
signersOrProvidersSignersOrProviderssigners or providers keyed by their chain ids
contractListContractLista list of contract metadata

Defined in

src/ContractFactory.ts:25

Properties

contractList

Readonly contractList: ContractList

Defined in

src/ContractFactory.ts:17


signersOrProviders

Readonly signersOrProviders: SignersOrProviders

Defined in

src/ContractFactory.ts:16

Methods

getContract

getContract(chainId, address): Contract

Creates an ethers Contract for the contract identifier provided using the ContractList and Signers or Providers provided on initialization.

Parameters

NameTypeDescription
chainIdnumberthe chain id the contract was deployed on
addressstringthe address of the contract to create

Returns

Contract

an ethers contract for the provided contract identifier

Defined in

src/ContractFactory.ts:40


getContractList

getContractList(): ContractList

Getter for the ContractList provided on initialization.

Returns

ContractList

the contract list the contract factory was initialized with

Defined in

src/ContractFactory.ts:87


getContracts

getContracts(contractIdentifiers): Contract[]

Creates multiple ethers Contracts for the identifiers provided using the ContractList and Signers or Providers provided on initialization.

Parameters

NameTypeDescription
contractIdentifiersContractIdentifier[]a list of unique identifiers for contracts to create

Returns

Contract[]

a list of ethers contracts for the provided conract identifiers

Defined in

src/ContractFactory.ts:58


getSignerOrProvider

getSignerOrProvider(chainId): Signer | Provider

Gets a Signer or Provider for the chain id requested from the Signers or Providers prodiced on initialization.

Parameters

NameTypeDescription
chainIdnumberthe chain id to get a signer or provider for

Returns

Signer | Provider

the signer or provider for the chain id requested

Defined in

src/ContractFactory.ts:71


getSignersOrProviders

getSignersOrProviders(): SignersOrProviders

Getter for the Signers or Providers provided on initialization.

Returns

SignersOrProviders

the signers or providers the contract factory was initialized with

Defined in

src/ContractFactory.ts:79