Skip to main content

Midnight.js API Reference v1.0.0


Midnight.js API Reference / @midnight-ntwrk/midnight-js-contracts / findDeployedContract

Function: findDeployedContract()

Creates an instance of FoundContract given the address of a deployed contract and an optional private state ID at which an existing private state is stored. When given, the current value at the private state ID is used as the initialPrivateState value in the finalizedDeployTxData property of the returned FoundContract.

Param

The providers used to manage transaction lifecycles.

Param

Configuration.

Throws

Error Improper privateStateId and initialPrivateState configuration.

Throws

Error No contract state could be found at contractAddress.

Throws

TypeError Thrown if contractAddress is not correctly formatted as a contract address.

Throws

ContractTypeError One or more circuits defined on contract are undefined on the contract state found at contractAddress, or have mis-matched verifier keys.

Throws

IncompleteFindContractPrivateStateConfig If an initialPrivateState is given but no privateStateId is given to store it under.

Call Signature

findDeployedContract<C>(providers, options): Promise<FoundContract<C>>

Type Parameters

C

C extends Contract<undefined, Witnesses<undefined>>

Parameters

providers

ContractProviders<C, ImpureCircuitId<C>, unknown>

options

FindDeployedContractOptionsBase<C>

Returns

Promise<FoundContract<C>>

Call Signature

findDeployedContract<C>(providers, options): Promise<FoundContract<C>>

Type Parameters

C

C extends Contract<any, Witnesses<any>>

Parameters

providers

ContractProviders<C>

options

FindDeployedContractOptionsExistingPrivateState<C>

Returns

Promise<FoundContract<C>>

Call Signature

findDeployedContract<C>(providers, options): Promise<FoundContract<C>>

Type Parameters

C

C extends Contract<any, Witnesses<any>>

Parameters

providers

ContractProviders<C>

options

FindDeployedContractOptionsStorePrivateState<C>

Returns

Promise<FoundContract<C>>