Having issues with a contract creating another contract using Truffle dev environment. Here are my steps -

truffle console
var node = Node.deployed()
var relay = node.createRelay()

Getting this response after createRelay:

{ tx: 
   { transactionHash: 
     transactionIndex: 0,
     blockNumber: 40,
     gasUsed: 159039,
     cumulativeGasUsed: 159039,
     contractAddress: null,
     logs: [] },
   logs: [] }

As you can see, contractAddress is null.

Here are my contracts:

pragma solidity ^0.4.2;
import "./Relay.sol";

contract Node {

uint public fee;
address public owner;
address[] activeRelays;

  function Node() {
    owner = msg.sender;
    fee = 10;

  function createRelay () returns (address) {
    address relay = new Relay();
    return relay;


pragma solidity ^0.4.2;

contract Relay {
address public owner;

  function Relay() {
    owner = msg.sender;

  function fundRelay() payable returns (bool) {


  function releaseFunds () {


Thank you for any help.


Missing a step. Simple way forward:

First, address[] public publicRelays; // easy access with free getter using "public"

Second, it's normal to get a transaction hash when you submit a transaction. We don't expect a result. Ergo, we won't get the contract address that way.

Instead, wait for the transaction to be mined. At the outset, just watch your node/miner. When you're sure a block has been mined, then it follows that you should then be able to:

> var relay;
> node.publicRelays.call(0).then(function(response) { relay=response; });
> relay

Meaning, 1) interrogate the publicRelay() getter and ask or row 0 (because it's an array). 2) Wait for the response ... 3) see the response.

Hope it helps.

  • 1
    Rob is totally right, just let me add why: Transactions return only transaction IDs. So even though you've set ` createRelay ` to return an address, you will indeed just get the tx ID back. Returning data from a function outside of the EVM works only with calls (reading), whereas functions within contracts can get data returned. – Nikita Fuchs Apr 16 '17 at 11:57

Your Answer

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

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