Here's how I can do that in ethers@4.0.47:

import { Contract, ethers } from "ethers";

const contractInstance: Contract = new ethers.Contract(address, abi);

But in web3.js@1.2.8 none of the following works:

import Web3 from "web3";
import { Contract } from "web3"; // option 1
import { Contract } from "web3/types"; // option 2

I figured it out:

import { Contract } from "web3-eth-contract";

It's recommended that you also list web3-eth-contract as a direct dependency so you avoid getting a warning from eslint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.