Skip to content

Contract.connect() returns a BaseContract #4183

Open
@TomiOhl

Description

@TomiOhl

Ethers Version

6.6.2

Search Terms

connect, contract, migration, BaseContract

Describe the Problem

Since a Contract's connect method returns a BaseContract, it apparently doesn't have the methods from the abi - at least according to typescript (vs code?).
The error message is: Property 'setFee' does not exist on type 'BaseContract'.ts(2339) (where setFee is the name of the function I'm calling).
Note that the code still runs fine.

Code Snippet

// this gives error
await contract.connect(randomWallet).setFee(ethers.ZeroAddress, 12);

// this is fine
await (contract.connect(randomWallet) as Contract).setFee(ethers.ZeroAddress, 12)

Contract ABI

["function setFee(address token, uint256 newFee)"]

Errors

Property 'setFee' does not exist on type 'BaseContract'.ts(2339)

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli), node.js (v12 or newer), Hardhat

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvement.minor-bumpPlanned for the next minor version bump.next-patchIssues scheduled for the next arch release.on-deckThis Enhancement or Bug is currently being worked on.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions