1

I have a method on a Contract A which I am calling (in my dapp). This method in turn instantiates a second Contract B and emits an event with contract B's address.

I then use this address, along with the ABI (from my source code) to create a representation of this contract to interact with - in web3. However, when I try to interact with Contract B I get the following error:

Error: Returned error: Internal JSON-RPC error.

Unlike for my other transactions - metamask does not event attempt to open.

This is the code

const transactionObject = this.context.drizzle.contracts.FundingApplications.methods.submitApplication(name, description);
const data = await transactionObject.send({from: this.props.accounts[0], value: this.drizzle.web3.utils.toWei(String(0.004), "ether")}); // this succesfully uses metamask to make a request
const applicationAddress = data.events.ApplicationSubmitted.address;
const web3Instance = new Web3(this.context.drizzle.web3.currentProvider);
const application = new web3Instance.eth.Contract(Application.abi, applicationAddress);
const transactionalObject = application.methods.voteForApplication(1);
const gas = await transactionalObject.estimateGas(); // this is where it fails
const transaction = await transactionalObject.send({from: this.props.accounts[0], gas: gas});

When I log out transactionalObject, I see that it is indeed the transactional object required by web3 and metamask. However as soon as I call estimateGas, send or call on it, it fails with the above error. This method of interacting with contracts works for all my other contracts which are deployed and then passed into drizzle options... but this method appears not to work for this contract, the only difference being that I am insantiating this contract at runtime using web3 and passing it the metamask provider. What am I missing?

Your Answer

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

Browse other questions tagged or ask your own question.