I can't seem to find an answer for my problem, or it's either impossible and I'm missing something, or it's trivial and I'm missing something.

I have this function on client side:

const bet = web3.utils.toWei(bet.toString(), 'ether')
let gasEstimated = 135335 //default

Contract.methods.joinGame(id).estimateGas({ from: account, value: bet }).then(function (gasAmount) {
    gasEstimated = gasAmount

Contract.methods.joinGame(id).send({ from: account, gas: gasEstimated, value: bet }).then((result, error) => {
    if (error) return console.log('ERROR_PAYING', error)

It gives me an eth_sendTrasaction does not exist error. My final objective would be for the client to pay with metamask once the joingame function is called.

Disclaimer: I also tried with web3.eth.sendTransaction

It works with ganache-cli

1 Answer 1


Infura doesn't support underlying JSON-RPC method for eth_sendTransaction. Infura only blocks methods that do not make sense for Infura, such as those that require Infura to store private keys. web3.eth.sendTransaction invokes the eth_sendTransaction method (which requires the server to hold keys), and therefore is unsupported by Infura (but is supported by ganache-cli).

You need to use the web3 method that instead invokes eth_sendRawTransaction, so that the transaction signing happens locally. This, of course, would require you to generate the raw transaction and sign it locally prior to calling eth_sendRawTransaction.

Here is a good example of what it should look like.

  • 1
    So there is no way to use infura and request client payments via metamask? If they want to make a transaction they would need to give me their wallet PK?
    – Clipart
    Mar 26, 2019 at 16:22
  • No, this is possible (and is how MM does it). You need to have them locally create the transaction and then send the raw transaction in two steps (as opposed to simply calling send in a single step). So instead of your send function, you would build the transaction and then send it. Take a look at my edited answer. Mar 26, 2019 at 16:24
  • Having this in mind: var tx = new ethereumjs.Tx({ nonce: nonce, gasPrice: web3.toHex(web3.toWei('20', 'gwei')), gasLimit: 100000, to: address, value: 0, data: data, }); tx.sign(ethereumjs.Buffer.Buffer.from(privateKey, 'hex')); var raw = '0x' + tx.serialize().toString('hex'); web3.eth.sendRawTransaction(raw, function (err, transactionHash) { console.log(transactionHash); }); what should be the PK field on my code in order to sign the raw transaction? Or I should just ignore the tx.sign part?
    – Clipart
    Mar 26, 2019 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.