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,170 points
63 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,550 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,170 points
214 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,170 points
220 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
170 views
0 votes
1 answer
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
• 67,660 points
107 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
163 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,550 points
143 views