0

So I am trying to define a type of web3 contract with typescript. We know that a web3 contract is defined in the form that

var myContract = new web3.eth.Contract(contractABI, contractAddress)

My question is that How to define a type of such contract so that the following code is possible

function myFunction(someContract: contract){...}

Any feedback will be appreciated.

3
  • What would be the intended usage? and why do you want to define a contract like that?
    – Ismael
    Jul 17 '21 at 5:30
  • I have figured out. It turns out that I can simply import such type from web3 source code.
    – CoolGas
    Jul 17 '21 at 13:33
  • 1
    I would be nice if you can write what changes were made so the question can be mark as answered.
    – Ismael
    Jul 17 '21 at 16:29
0

Turns out that this can be easily done by import type Contract from the source code of web3.

1
  • 3
    Can you add a little snippet how the code looks like?
    – Ismael
    Jul 17 '21 at 20:32

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.