Skip to content

Binding a provider to the contract instance

The provider parameter of getContract is optional, it use for estimate you need specified the provider in future used. As the same time, you still can set it or change it later.

For the PinkContractPromise instance, you can set or get the provider by the provider property, or create a new PinkContractPromise instance with specified provider by the withProvider method.

provider

AnyProvider | undefined

The PinkContractPromise instance can check which provider in used or binding a new provider with the provider property.

// Getting current binded provider
const currentProvider = contract.provider
 
// Binding a new provider
contract.provider = provider

withProvider

Create a new PinkContractPromise instance with specified provider.

Usage

const newContract = contract.withProvider(provider)

Parameters

provider

AnyProvider

The provider instance will binding to the new PinkContractPromise instance.

Returns

PinkContractPromise