How to get a contract instance type? #544
-
Hi! Currently migrating over from Ethers, where a I can't seem to get proper typing for the equivalent Old Ethers Setup:let contract: Contract | undefined
contract = new Contract( ... ) Viem Setup:let contract: any
contract = getContract({ ... }) What should I use there instead of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I realise this is quite an old question, but the way I solved for this was to do |
Beta Was this translation helpful? Give feedback.
I realise this is quite an old question, but the way I solved for this was to do
GetContractReturnType<typeof ContractAbi, PublicClient, WalletClient>
. This requires that you create a type definition file for yourContractAbi
.