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;
auctionList.push(13);
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:
auctionList.push(13);
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[]) {
auctionList.push(12);
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);
console.log(Auction);
Auction.setProvider(web3.currentProvider);
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?
Update(a.name, a.highestBid, a.highestBidder, a.recipient, auctionID, array);an Event? – Luiz Soares Dec 15 '17 at 19:19auctionList.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 andauctionList.push(13);is causing that function/transaction to fail for some reason. – willjgriff Dec 20 '17 at 23:16startAuctionis returning no events means the transaction has failed, and the cause seems to be it is running out of gas. – Ismael Mar 27 '18 at 14:27