1

This is the struct for deals I created

// custom types
struct Deal {
    uint id;
    string name;
    string description;
    uint256 price;
    address seller;
    address buyer;
    string[] sellerDocuments;
    string[] buyerDocuments;
    string[] dealImages;
    uint status; // 0 - inactive, 1 - pending, 2 - active, 3 - paid, 4 - completed
    uint category; // 0 - oil, 1 - gas, etc
    uint256 dateposted;
}

This is my sellDeal() function.

// Sell Deal

function sellDeal(string _name, string _description, uint256 _price, string[] _images, string[] _sellerDocuments, string[] _buyerDocuments, uint _category, uint256 _dateposted) public {
    dealCounter++;
    // storing this deal
    deals[dealCounter] = Deal(
      dealCounter,
      _name,
      _description,
      _price,
      msg.sender,
      0x0,
      _sellerDocuments,
      _buyerDocuments,
      _images,
      0,
      _category,
      _dateposted
      );

    emit LogSellDeal(dealCounter, msg.sender, _name, _price);
}

I call the function using

app.sellDeal("deal 2", "desc for deal 2", 4000, ["img 1", "img 2"], ["sdoc 1", "sdoc 2"], ["bdoc 1", "bdoc 2"], 1, 123456)

It works on remix, but anytime I use truffle locally, I get

Error: Transaction: 0xf62026249e65bc3b10e3aff744e579b5434edca2c6dff47148d6648634b24685 exited with an error (status 0).
Please check that the transaction:
    - satisfies all conditions set by Solidity `require` statements.
    - does not trigger a Solidity `revert` statement.

    at StatusError.ExtendableError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10:1)
    at new StatusError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-contract/statuserror.js:29:1)
    at Object.callback (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:181:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:142:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:89:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:460:23)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

What am I doing wrong?

  • 1
    Did you try increasing transaction gas? You are passing several strings and using strings can be expensive. Try something like app.sellDeal(...., { gas: "4000000" }). – Ismael Jul 4 '18 at 18:59

Your Answer

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

Browse other questions tagged or ask your own question.