2

I have a contract like below:

contract SimpleBidding {

    address contractOwnersAccount;

    // request information
    address public client;
    uint barcode;

    // bidding information
    uint expectedProposals;
    address bestVendor;
    uint bestPrice;

    // events
    event AssetRequested(address client, uint barcode);

    /* Constructor */
    function SimpleBidding(address _account) {
        contractOwnersAccount = _account;
    }

    /* checks if the time limit has been reached and ends the contract */
    function dispose() {
        suicide(contractOwnersAccount);
    }

    /* Used by clients to request assets and start bidding.     */ 
    function requestAsset(uint _barcode) {
        // save the requester
        client = msg.sender;

        // save the asset barcode
        barcode = _barcode;

        // create the event
        AssetRequested(client, barcode);

        // initialize the bidding process
        expectedProposals = 2;
        bestPrice = 999999;
    }
}

I realized that somehow the global variable address public client; does not work (it does not create the event). When I change it to var client = msg.sender;, it works and creates the event. I know it, because I have a watcher printing a log when the event is fired.

By the way, I call the function as below:

simplebidding_sol_simplebidding.requestAsset(5555, {from: eth.accounts[2]})

Any ideas? There is no error message or something like that I found.

8
  • This seems to work for me on Browser Solidity, even if I change the account from which it's sent. (By changing "Transaction origin".) The event is successfully triggered. Mar 22 '17 at 15:54
  • It works for me also on Browser Solidity. I realized that if I add more statement to the function, it does not work properly. It is probably about this gas stuff, but I am a newbie and dont know much how to do. Mar 22 '17 at 16:02
  • If you think it's a gas issue, just do simplebidding_sol_simplebidding.requestAsset(5555, {from: eth.accounts[2], gas:1000000}) Mar 22 '17 at 22:55
  • Also, if you post a tx hash from the mainnet or public testnet, we can tell you for sure if it's a gas issue. Mar 22 '17 at 22:57
  • simplebidding_sol_simplebidding.requestAsset(5555, {from: eth.accounts[2], gas:1000000}) worked for me. So it was about gas. But I remember for some cases, the geth console is giving warning when there is not enough balance for example when you try to execute a function. For this problem, I had no warning at all. I am just curious, when we call the function as simplebidding_sol_simplebidding.requestAsset(5555, {from: eth.accounts[2]}) (without the gas paramater), what is the default gas amount used? Do you know? Mar 23 '17 at 10:11

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.