Ok so I am trying to initialize a new contract. From what I understand, creating this contract will only return a transaction hash. So I'm trying to access the new contract from data structures in the controlling contract. This is working in the solidity online compiler, but it wont seem to work within truffle.

 fundingContract.createProject(amount , deadline, title, description, {from: account}).then(function(projectAddress) {
setStatus("Project created");
}).then(function() { 
fundHub.getProjectAddress.call(0).then(function(_projectAddress) { 
  var newProject = Project.at(_projectAddress);

  newProject.getTitle.call().then(function(projectTitle) { 

Could the function createProject be silently failing?

1 Answer 1


You're working on a common pattern, so I'm hopeful that turning your attention to a working example of this sort of thing will help you out.

Have a look at this: Creating contracts via new doesn't work

The really important thing is to wait for the createProject() transaction to be mined before interrogating the values you expect to find.

It's normal to first get the transaction hash only. It's a hash of something that got submitted, but it's not the result of execution. The result of execution isn't knowable until the transaction is mined. Hence, the need to wait for it and an additional step in the pattern.

The contract and details in the example are slightly different, so adapt the params as needed. The general flow is very similar. You can follow the code inside beforeEach() and continue from return web3.eth.getTransactionReceiptMined(txn) with ... (in your case)

.then(function(_address) { // your createProject() returns a single value
  console.log("the transaction returned", _address);

... continue


  • Ok thats great thanks! I implemented the functions but it seems I am getting null for the contract address, and the function isn't looping. I get a non null object back when I just use web3.eth.getTransactionReceiptMined(txn) without the asynchronous function.
    – ethereal
    Commented Jan 23, 2017 at 0:48
  • I'm getting this error in the console if it's relevant "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience"
    – ethereal
    Commented Jan 23, 2017 at 0:52
  • Don't worry about the synchronous XML... message. Possible to see the whole works? I can probably get it work for you if there's a simple contract and your code so far. Commented Jan 23, 2017 at 1:02

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.