I am interacting with a contract on the Rinkeby testnet using web3.js (version 0.20.7) with Metamask and the chrome console.
I setup a contract object called mycontract for a given ABI and address. When I set the web3 provider for this contract using mycontract.setProvider(web3.givenProvider) I get an error saying that mycontract.setProvider is not a function.
See below the js code deployed in the chrome console:
> const mycontract = web3.eth.contract(ABI, Address);
undefined
> mycontract.setProvider(web3.givenProvider);
< VM212:1 Uncaught TypeError: simpleStorage.setProvider is not a function
at <anonymous>:1:15
I suppose this may be due to the fact that the mycontract.setProvider(web3.givenProvider)
command is for web3.js version 1.0 and above.
However, if it is the case, I could not find info about what command I should use with web3.js 0.20.7.
Any help would be great.
Thank you
console.log(web3.version)
inside your code and report back with the result.> console.log(web3.version) > {api: "0.20.7", getNode: ƒ, getNetwork: ƒ, …} VM288:1
So as expected it seems to be the version 0.20.7 of web3.js. Do you know what should I do to execute the code described in my post above? Thanks