0

I'm quite stuck with this issue. It seems like it must work, but it doesn't :D

Have a contract on rinkeby network which is working perfectly through remix(load by address) and truffle console. However method calls through web3 client refuse to work.

init:

import Web3 from 'web3';


// @ts-ignore
const web3 = new Web3(window.web3.currentProvider);

***got address & abi***

export default new web3.eth.Contract(abi, address);

usage example:

console.log(registryContract.options.address);
console.log(registryContract.methods);
const owner = await registryContract.methods.owner().call();

In console.log() i can see the actual contract address and methods. Metamask is active and web3.eth.defaultAccount shows me my correct account at rinkeby network => provider must be working.

calling the owner from remix working. with web3 i'm getting an empty array as response. Same for other methods calls.

What is possible going wrong? "web3": "^1.0.0-beta.37"

1

The problem was with contract abi - don't know what exactly was wrong with it. I simply used abi from different source and it helped. Any tool for abi verification?

0

You have some stray brackets after the method name.

Instead of

registryContract.methods.owner().call();

try

registryContract.methods.owner.call();
  • tried using it without () returns me methods.owner object – user1935987 Dec 31 '18 at 12:06
0

Try this.

registryContract.owner(function (error, result) {
if (!error)
  console.log(result);
else
  console.error(error);
});
  • tried, doesn't throw any error – user1935987 Dec 31 '18 at 12:08

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.