When I run the below solidity function:

function startAuction(string name, uint timeLimit) public returns (uint[]) {
    uint auctionID = totalAuctions++;
    AuctionStruct a = Auctions[auctionID];
    a.recipient = msg.sender; // the person who starts the auction is the recipient
    a.name = name;
    uint array = auctionList.length; 
    Update(a.name, a.highestBid, a.highestBidder, a.recipient, auctionID, array);   
    return auctionList;    

Using the below request from javascript:

contractInstance.startAuction(auctionname, duration, { from: buyerAddress }).then(function(result) {...

I receive a response with an empty logs array.

But when I remove the below line from the above solidity function:


And add the below Solidity function I receive a filled logs array from the first function and an auctionList from the below function including the pushed 12:

function listAuctions() public returns (uint[]) {
    return auctionList;


Which is called using the below request in javacsript (next to the prior script to request the solidity function):

contractInstance.listAuctions.call().then(function(v) {...

I am using truffle-contract to access the contracts, which is activated using the below code:

var Auction = contract(auction_artifacts);

The contract is included using browserify:

global.contract = require('truffle-contract');
global.auction_artifacts = require('../build/contracts/Auction.json');

When I run the above functions from the truffle console all seems to be working fine.

Could anyone explain this?

  • Is Update(a.name, a.highestBid, a.highestBidder, a.recipient, auctionID, array); an Event? Commented Dec 15, 2017 at 19:19
  • Yes that is correct Commented Dec 16, 2017 at 6:06
  • Is the transaction successful when the auctionList.push(13); is included? As in can you check the status field (inside the transaction receipt object returned in the .then()) is equal to 1? If it isn't then the transaction isn't successfully being executed and auctionList.push(13); is causing that function/transaction to fail for some reason.
    – willjgriff
    Commented Dec 20, 2017 at 23:16
  • That startAuction is returning no events means the transaction has failed, and the cause seems to be it is running out of gas.
    – Ismael
    Commented Mar 27, 2018 at 14:27

2 Answers 2


You are confusing "call" and "sendTransaction". When you use "call", you get the return value and you did when executing contractInstance.listAuctions.call().then(function(v) {...

And your code here is not using "call" contractInstance.startAuction(auctionname, duration, { from: buyerAddress }).then(function(result) {...

It is a common question as you see here: What is the difference between a transaction and a call?

call - It is synchronous and the return value of the contract function is returned immediately.

transaction - it is asynchronous, the immediate return value of a transaction is always the transaction's hash

  • It does return values using the "sendTransaction" option when the code ""auctionList.push(13)" is not included so I don't think that is the issue. Also when I use the truffle console I do get the right result using "sendTransaction" even when the "auctionList.push(13)" is included Commented Dec 16, 2017 at 6:09
  • 1
    It doesn´t return a transaction hash when you use sendTransaction? That´s weird. I couldn´t reproduce here. I always get a transaction hash. And when I use Promise I get a complex object after it is mined. Commented Dec 18, 2017 at 11:13

The function you describe modifies state variables, so you can’t call them from outside solidity with call()

When you remove the line that pushes the item into the array, the function does not modify the state anymore.

If the function is intended to modify an state variable you don’t need to use .call(). Just do contract.myfunc(var);

  • Thanks, but the call function is working correctly. The function that uses the contract.myfunc(var) does not work correctly in this case Commented Dec 10, 2017 at 16:27
  • 4
    @pabloruiz55 You can call a function that modifies the contract storage, they will not permanently modify the storage (only within the call). They will not cause any error ethereum.stackexchange.com/questions/28040/…
    – Ismael
    Commented Dec 11, 2017 at 21:48

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.