0

Solidity function Using web3 0.20 version and Cant call solidity BETONTEAM function

pragma solidity ^0.4.22;

import "installed_contracts/strings.sol";
import "installed_contracts/oraclize-api/contracts/usingOraclize.sol";

contract OraclizeTest is usingOraclize {

    using strings for *;        //strings import requirement
   // string public matchId; 
    uint public amount; 

//remove url traces
    address public homeBet;  
    address public awayBet;




    event LogInfo(string description);      //getting from update function


    // Constructor
    function OraclizeTest (uint _amount) public {    
        amount = _amount;        

        // Replace the next line with your version:
        OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);

        oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
    //    update();
    }

    //--------------------------------------------------------------------------------------
     //1 indicates home team    //2 indicates away team
    function betOnTeam(uint team) payable public {
      emit LogInfo("INSIDE betOnTeam--------------------");
        if(team == 1)
        {

                if(msg.value == amount)
                {
                    homeBet = msg.sender;
                    if(homeBet != 0 && awayBet != 0)
                    {
                        //oraclize_query("URL", url);


                        oraclize_query("URL", "json(https://api.crowdscores.com/v1/matches/123945?api_key=93c4c515196741beaf5e4528b64ea511).outcome.winner");
                        update();                   
                    }
                }
                else
                {
                    throw;
                }
        }
        else if(team == 2)
        {

                if(msg.value == amount)
                {
                    awayBet = msg.sender;

                    if(homeBet != 0 && awayBet != 0)
                    {
                        //oraclize_query("URL", url);
                        update();
                        oraclize_query("URL", "json(https://api.crowdscores.com/v1/matches/123945?api_key=93c4c515196741beaf5e4528b64ea511).outcome.winner");
                    }
                }
                else
                {
                    throw;
                }
        }
    }
    //--------------------------------------------------------------------------------------
    function __callback(bytes32 id, string result, bytes proof) public {
    require(msg.sender == oraclize_cbAddress());       

    //string lib being used to compare
    emit LogInfo("REACHED-------------CALLBACK");
    if (result.toSlice().equals("home".toSlice()))
    {
        emit LogInfo("REACHED-------------CB-------INSIDE");
        homeBet.transfer(address(this).balance);
    }
    else if(result.toSlice().equals("away".toSlice()))
    {
        awayBet.transfer(address(this).balance);
    }
    else if(result.toSlice().equals("draw".toSlice()))
    {
        homeBet.transfer(address(this).balance / 2);
        awayBet.transfer(address(this).balance / 2);
    }

    }

    function update()
    payable
    public {
        // Check if we have enough remaining funds
        if (oraclize_getPrice("URL") > address(this).balance) {
            emit LogInfo("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
        } else {
            emit LogInfo("Oraclize query was sent, standing by for the answer..");

            // Using XPath to to fetch the right element in the JSON response
            oraclize_query("URL", "json(https://api.crowdscores.com/v1/matches/123945?api_key=93c4c515196741beaf5e4528b64ea511).outcome.winner");

        }
    }

}

Here is the .JS file through which i am trying to call this function App.js


var contract = web3.eth.contract(OraclizeContract.abi).at('0x801063bFD5DdacF816395839D19344E87aCD393D');


 if(team == "Home")
    {
      team = 1;
    }
    else
    {
      team = 2;
    }

console.log(team) ---------------------->> IT SHOWS numeric 1 

    var gettdata = contract.betOnTeam.getData(team);
     console.log(gettdata)


    contract.betOnTeam.call(team, {from: fromAddress1, gas: 444444}, 
          function(err, transactionHash) {
        if (!err)
            console.log(transactionHash); 
          });

```````````````````
Am i doing something wrong i cannot understand how to pass arguement and call the solidity function


  • Comments are not for extended discussion; this conversation has been moved to chat. – eth Jan 18 at 7:42

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.