This question already has an answer here:

I am trying to create a factory contract that dynamically creates new instances of another contract. And I want the factory to return the newly created contract's address; however, when I test it in the Remix IDE, the function does not return anything. Here is my current code:

contract CreateTournament {
    Tournament public newTournament;
    address[] newTournaments;
    uint index = 0;

    function createNewTournament(string _title, uint32 
_maxParticipants, uint _entryFee, uint _surcharge) public 
returns(address) {
        newTournament = new Tournament(_title, _maxParticipants, 
_entryFee, _surcharge);
        return newTournament;

    function checkAddress(address tournament) public view returns(bool) 
        bool exists = false;

        for (uint i = 0; i < newTournaments.length; i++) {
            if (tournament == newTournaments[i]) {
                exists = true;

        return exists;

Any help would be appreciated!

marked as duplicate by Ismael, Richard Horrocks, Roman Frolov, eth Jan 11 '18 at 21:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Functions that write data to the blockchain don't return any values. They return the transaction hash, so you won't be able to get the value from outside Solidity.

You can have the function fire an Event and then capture the log from web3 once the transaction has been mined to get the address of the newly created contract.

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