How to set eth_sendPrivateTransaction to fast

I try to use

what do I need to change in

const ethers = require(“ethers”);
(async () => {
const provider = new ethers.providers.JsonRpcProvider(“https://docs-demo.quiknode.pro/”);
const estimate = await provider.eth_sendPrivateTransaction(“RAW_SIGNED_TX”);
console.log(estimate);
})();

in order to make fast: true ?

Hey Christopher,

If I’m not mistaken, are you trying to send this transaction faster?

-Nick

In your docs it says its

“fast
boolean
It sends the transaction with fast mode when true”

You are using the flashbots endpoint if Im not mistaken. In the flashbot docs it says that when transaction speed for private transactions is set to default the transaction will only be submitted to flashbots validator. If it set to fast the transaction will be send to a bunch a validators (eth_sendPrivateTransaction | Flashbots Docs)

So what do I need to change in

const ethers = require(“ethers”);
(async () => {
const provider = new ethers.providers.JsonRpcProvider(“https://docs-demo.quiknode.pro/”);
const estimate = await provider.eth_sendPrivateTransaction(“RAW_SIGNED_TX”);
console.log(estimate);
})();

in order to make fast: true so that it sends the private transaction to not only one validator but a set of validators.

Thanks!

Hey Christopher,

You’ll need to do this

const ethers = require("ethers");
(async () => {
  const provider = new ethers.providers.JsonRpcProvider("https://docs-demo.quiknode.pro/");
  
  const preferences = {
    fast: true,
  };

  const estimate = await provider.eth_sendPrivateTransaction("RAW_SIGNED_TX", preferences);

  console.log(estimate);
})();

-Nick

I get

TypeError: provider.eth_sendPrivateTransaction is not a function

Why is that ?

Here is my full script

const { Wallet, Utils } = require(“alchemy-sdk”);
const ethers = require(“ethers”);

const PRIVATE_KEY = process.env.nftastic

let wallet = new Wallet(PRIVATE_KEY);

async function test() {

const exampleTx = {
to: “0x0C7172c8c5C000F39E2A11b04c52805aF29d945b”,
value: 1,
gasLimit: “21000”,
maxFeePerGas: Utils.parseUnits(‘30’, ‘gwei’),
type: 2,
chainId: 1,
};

const rawTransaction = await wallet.signTransaction(exampleTx);
console.log(rawTransaction)

const provider = new ethers.JsonRpcProvider(“https://warmhearted-solitary-brook.quiknode.pro/KEY/”);
const estimate = await provider.eth_sendPrivateTransaction(rawTransaction);
console.log(estimate);

}

test();

{
“dependencies”: {
@quicknode/sdk”: “^1.1.4”,
“alchemy-sdk”: “^2.11.0”,
“ethers”: “^6.8.1”
}
}

Thanks in advance!

Hey Christopher,

Can you try this, as eth_sendPrivateTransaction is not natively supported in Ethers.

const ethers = require("ethers");
(async () => {
  const PRIVATE_KEY = process.env.nftastic
  const wallet = new ethers.Wallet(PRIVATE_KEY);

  const provider = new ethers.providers.JsonRpcProvider("https://docs-demo.quiknode.pro/");
  
  const exampleTx = {
    to: "0x0C7172c8c5C000F39E2A11b04c52805aF29d945b",
    value: ethers.utils.parseUnits('1', 'ether'),
    gasLimit: "21000",
    maxFeePerGas: ethers.utils.parseUnits('30', 'gwei'),
    type: 2,
    chainId: 1,
  };
  const rawTransaction = await wallet.signTransaction(exampleTx);

  const heads = await provider.send("eth_sendPrivateTransaction", [
    {
      "tx": rawTransaction,
      "preferences": {
        "fast": true,
      }
    },
  ]);
  console.log(heads);
})();`Preformatted text`

-Nick

Hey Nick,

thanks for the fast support! Your script worked now. I have a quick follow up question regarding the fast mode. When I check my tx through the flashbots api endpoint

https://protect.flashbots.net/tx/0xfe8eb90cb019c6aa3b8787c75c342a6ff7a37598f8155dc6bba56b882bd9f5c2

the fastMode there still says false. Do you know why that is?

Ive found this here maybe this explain it but not sure. When you check the docs of flashbots sendprivatetransaction (eth_sendPrivateTransaction | Flashbots Docs) you can see that

fast: boolean, // Deprecated; required until this is removed from the API. Value has no effect.

Could this explain it? Also do you maybe know a workaround to make sure my tx is not only getting sent to flashbot builder but to all available builders?

Thanks!

Hi Christopher,

I would say that yes that may explain it however don’t have too much detail on this question, unfortunately.

In regards to the second question, it sounds like you are asking for something similar to Blocknative’s Transaction Boost product → Transaction Boost.

-Nick

That sounds about what Im trying to achieve :smiley: I just read a bit through the docs and didnt found something explaining requirements. Is the transaction boost you provide for free or is this only available in some kind of subscribtion?

Thanks in advance Nick!

Hey Christopher,

It’s a service you should be able to incorporate with QuickNode, but it’s separate from our Blocknative marketplace add-on.

-Nick

Much appreciated Nick thanks for all the help!

1 Like