[Ethereum] “this._eth.sendTransaction is not a function” when executing method in Web3

reactsoliditytestrpctruffleweb3js

I'm using react-web3 (which basically gives me a web3 object back) and I'm trying to make my contract work. This is the code I'm using:

const web3 = window.web3;
    const contract = new web3.eth.contract(ABI.abi).at("0xdbb05ed3b5acb77cbd2366d037fe051703958dac");
    contract.buyTicket.sendTransaction(3000, {
        from: '0x5c1a92217e456a7eB4a051B567FC751A534991a3',
        value: web3.toWei(1, 'ether')
    });

The from is my default address in MetaMask.

My contract:

"abi": [
    {
      "constant": false,
      "inputs": [],
      "name": "restartLottery",
      "outputs": [],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [
        {
          "name": "myid",
          "type": "bytes32"
        },
        {
          "name": "result",
          "type": "string"
        }
      ],
      "name": "__callback",
      "outputs": [],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [],
      "name": "toggleActive",
      "outputs": [],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [
        {
          "name": "myid",
          "type": "bytes32"
        },
        {
          "name": "result",
          "type": "string"
        },
        {
          "name": "proof",
          "type": "bytes"
        }
      ],
      "name": "__callback",
      "outputs": [],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [],
      "name": "getTotalPotSize",
      "outputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [
        {
          "name": "_estimate",
          "type": "uint256"
        }
      ],
      "name": "buyTicket",
      "outputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "payable": true,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [],
      "name": "getActiveState",
      "outputs": [
        {
          "name": "",
          "type": "bool"
        }
      ],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [],
      "name": "getKrakenPrice",
      "outputs": [],
      "payable": true,
      "type": "function"
    },
    {
      "constant": true,
      "inputs": [],
      "name": "owner",
      "outputs": [
        {
          "name": "",
          "type": "address"
        }
      ],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [
        {
          "name": "_gameId",
          "type": "uint256"
        }
      ],
      "name": "getEstimationPerGame",
      "outputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "payable": false,
      "type": "function"
    },
    {
      "constant": false,
      "inputs": [
        {
          "name": "_gameId",
          "type": "uint256"
        }
      ],
      "name": "getBuyersPerGame",
      "outputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "payable": false,
      "type": "function"
    },
    {
      "inputs": [],
      "payable": false,
      "type": "constructor"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": false,
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "estimateAndPayout",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": false,
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "priceRetrieved",
      "type": "event"
    }
  ],

I keep getting this error:

Uncaught TypeError: this._eth.sendTransaction is not a function
    at c.sendTransaction (inpage.js:8253)
    at test (Landingpage.jsx:22)
    at Landingpage.componentDidMount (Landingpage.jsx:46)
    at ReactCompositeComponent.js:264
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponent.js:263
    at CallbackQueue.notifyAll (CallbackQueue.js:76)
    at ReactReconcileTransaction.close (ReactReconcileTransaction.js:80)
    at ReactReconcileTransaction.closeAll (Transaction.js:209)
    at ReactReconcileTransaction.perform (Transaction.js:156)
    at batchedMountComponentIntoNode (ReactMount.js:126)
    at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:143)
    at Object.batchedUpdates (ReactDefaultBatchingStrategy.js:62)
    at Object.batchedUpdates (ReactUpdates.js:97)
    at Object._renderNewRootComponent (ReactMount.js:319)
    at Object._renderSubtreeIntoContainer (ReactMount.js:401)
    at Object.render (ReactMount.js:422)
    at Object../src/index.js (index.js:34)
    at __webpack_require__ (bootstrap 2d91de1…:659)
    at fn (bootstrap 2d91de1…:85)
    at Object.0 (web3Reducer.js:21)
    at __webpack_require__ (bootstrap 2d91de1…:659)
    at ./node_modules/ansi-regex/index.js.module.exports (bootstrap 2d91de1…:708)
    at bundle.js:712

Any idea?

Info
I'm using my contract with testrpc and deploy it there with truffle

Best Answer

You don't need to call the sendTransaction function explicitly, just call the function of your smart-contract like this:

contract.buyTicket(3000, {
        from: '0x5c1a92217e456a7eB4a051B567FC751A534991a3',
        gas: 1000000,
        value: web3.toWei(1, 'ether')
    });

also don't forget to define the gas-limit

edit: you don't need to instanciate a new object with new, web3 should give you the instance of your smart-contract:

const contract = web3.eth.contract(ABI.abi).at("0xdbb05ed3b5acb77cbd2366d037fe051703958dac");