Solidity mocha address is not a contract error

0 votes

I am trying to run below code in mocha. I am using rinkeby network. As you can see in the etherscan address 0xe950a05cc194a83a11533bf18218355b21e315ba is a contract but when I call getRequestsCount method i am getting the error as address is not a contact. Could someone please help me.

const campaign = new web3.eth.Contract(
    JSON.parse(compiledCampaign.interface),
    '0xe950a05cc194a83a11533bf18218355b21e315ba'
);
const summary = campaign.methods.getRequestsCount().call();
console.log(summary);

The error I am getting is as follows:

Error: Attempting to run transaction which calls a contract function, but recipient address 0xe950a05cc194a83a11533bf18218355b21e315ba is not a contract address
Oct 1, 2018 in Blockchain by slayer
• 29,370 points
1,065 views

1 answer to this question.

0 votes

Try the following:

// Initialize contract variable with contract ABI
const campaign = new web3.eth.Contract(
    JSON.parse(compiledCampaign.interface)
);

// Get contract at the contract address
campaignContract = campaign.at('0xe950a05cc194a83a11533bf18218355b21e315ba');

const summary = campaignContract.getRequestsCount().call();
answered Oct 1, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

Truffle tutorials "Error:recipient address is not a contract address"

It appears like you have already migrated ...READ MORE

answered Aug 8, 2018 in Blockchain by slayer
• 29,370 points
1,132 views
0 votes
1 answer

Invalid opcode error in a simple Solidity contract and script

You don't need to call .at() if you're using .new(). ...READ MORE

answered Sep 14, 2018 in Blockchain by slayer
• 29,370 points
4,819 views
0 votes
2 answers
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,220 points
1,464 views
+1 vote
3 answers

What is the pattern for handling throw on a Solidity contract in tests

In my opinion the cleanest way is: it("should ...READ MORE

answered Sep 25, 2018 in Blockchain by Lupin
1,806 views
0 votes
1 answer

Error using EtherJS: this.provider.getTransactionCount is not a function

With this line it should work fine: wallet.provider ...READ MORE

answered Sep 26, 2018 in Blockchain by digger
• 26,740 points
2,555 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP