Nick Wilczynski
Nick Wilczynski

Reputation: 33

Return object array in Solidity

Im trying to return an sample object from a contract but the data is always blank. Im using the BlockApps WebApi to do the work (http://blockapps.net/documentation). It always just returns a comma seperated string thats blank. Any help?

contract TrackingManager {
    Hit[] hits;

    function createHit(string _url, string _referrer) {
        hits.push(new Hit(_url, _referrer));
    }

    function getHits() returns (Hit[]) {
        return hits;
    }
}

contract Hit {
    string public url;
    string public referrer;

    function Hit(string _url, string _referrer) {
        url = _url;
        referrer = _referrer;
    }
}

Upvotes: 1

Views: 4575

Answers (1)

I may be wrong, but I think it's not possible to return struct arrays yet: http://solidity.readthedocs.io/en/develop/frequently-asked-questions.html and https://github.com/ethereum/cpp-ethereum/issues/1788

Upvotes: 3

Related Questions