I am a beginner and was trying to run a truffle project but encountered an error which I am unfamiliar with. I based it off Testing contracts with truffle

To explain this is my folder structure.

enter image description here

In my app folder I have the contract C.sol and migrations.sol

enter image description here

In my test, I have this c.js file

enter image description here

In my truffle.js, this is what I have written

enter image description here

I ran testrpc and then tried to compile truffle and then truffle test but I got this error below saying it can't find the deployed address. What is the issue?

enter image description here

2 Answers 2


You are getting this error because you didn't deploy the contracts.You need to provide file name in truffle.js file and then need to run the command $ truffle build to build the project. Here is the related documentation : http://truffleframework.com/docs/


I find it's better do arrange tests so they don't attempt to work with deployed contracts. That could cause problems in the real world. I'm not 100% sure and don't have time to test, but I think Truffle will not work with the deployed contract as expected.

A lot changed from v2 to v3 so that tutorial may be a little outdated.

You can do something like this:

var c;

beforeEach(function() {
  return C.new() // deploy a new instance of C.sol before each test
  .then(function(newInstance) {
    c = newInstance;

it("should ... 
    c.doFunction(arg1, arg2 ...) ...

You can do

$ truffle migrate

or if testrpc

$ truffle migrate --reset

when you want to deploy and truffle will help keep track of the deployed contracts with c.deployed(). Again, I don't think the migrated contracts mix with unit tests, for safety reasons.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.