eth_sendRawTransaction - ethers

Hi,
I didn’t find any solutions regarding my question neither in the docs.
I am using Ethers.js, and I am trying to deploy a contract from the frontend to the backend.
For security reasons, the deployment will be internal on the server triggered by a button from the frontend.
For the deployment I am getting the userAddress translated to a signer using the provider.
this is the response I am receiving : Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":47,\"error\":{\"code\":-32601,\"message\":\"The method eth_sendTransaction does not exist/is not available\"}}", error={"code":-32601}, requestBody="{\"method\":\"eth_sendTransaction\",\"params\"

and the code

   // Deploy the contract
    const myContract = await contractFactory.deploy(...req.args);

    // Prompt the user to connect their wallet and approve the transaction
    const transaction = myContract.deployTransaction;
     const transactionData = {
      from: transaction.from,
     to: transaction.to,
    value: transaction.value.toHexString(),
      data: transaction.data,
     gasLimit: ethers.utils.hexlify(5000000),
      maxPriorityFeePerGas: ethers.utils.parseUnits("5", "gwei"),
       maxFeePerGas: ethers.utils.parseUnits("20", "gwei"),
      nonce: await provider.getTransactionCount(transaction.from, "latest"),
      type: 2,
       chainId: chainId,
    };

    // // Sign the transaction using a signer
    const signedTransaction = await signer
     .signTransaction(transactionData)
     .then(ethers.utils.serializeTransaction(transaction));

I would like some help to make it work using ethers.js
Thanks

3 Likes

I will be glad to get your help infura.io , team , @Sean_Infura ?

2 Likes

Hey, the eth_sendTransaction JSON-RPC method is not supported because Infura doesn’t store the user’s private key required to sign the transaction. Use eth_sendRawTransaction instead.

1 Like

and instead they are suggesting to use eth_sendRawTransaction.

even for this method, using the signer, this method is not allowed.
with ethers we can use sendTransaction method.
Please kindly provide me a way to achieve it

1 Like