How to Submit a Transaction to Private Mempool
When you submit a transaction to the public mempool, it's visible to everyone. MEV bots can:
- Sandwich your trade: Place orders before and after yours to extract value
- Front-run you: Copy your trade and execute it first
- Back-run you: Profit from the price impact you create
Meanwhile, Private transactions eliminate this exposure by hiding your transactions until they are included.

Private TX vs Public Mempool
| Aspect | Public Mempool | Private TX |
|---|---|---|
| Visibility | Everyone sees it | Only builders see it |
| MEV exposure | Vulnerable | Protected |
| Inclusion speed | Gas price dependent | Builder dependent |
| Best for | Speed-competitive scenarios | Value-sensitive trades |
When to Use Private Transactions
Use private transactions when:
- Executing large swaps that could be sandwiched
- Trading tokens with low liquidity
- Running strategies you don't want copied
- Protecting any transaction from front-running
Request Sample
bashwss://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>bashbsc_private_tx| Parameter | Type | Required | Description |
|---|---|---|---|
transaction | string | Yes | Signed raw transaction hex |
mev_builders | array | No | Builders to send to. Default: ["all"] |
json{
"jsonrpc": "2.0",
"id": 1,
"method": "bsc_private_tx",
"params": {
"transaction": "0xf86c...",
"mev_builders": ["all"]
}
}json{
"jsonrpc": "2.0",
"id": 1,
"result": {
"txHash": "0x..."
}
}How to Submit Transaction to Private Mempool
Set up the project
bash
mkdir transaction-private-mempool cd transaction-private-mempool npm init -y npm install ws ethers dotenvbash
mkdir transaction-private-mempool cd transaction-private-mempool yarn init -y yarn ws ethersSet the ES module
"type": "module"in your package.json.Create a file and name it
index.jsCreate
.envfile and add the following:js
ACCESS_TOKEN=your-accelerated-node-endpoint RPC_URL=your-normal-bsc-node-endppoint //e.g https PRIVATE_KEY=your-wallet-private-keyImport the dependencies
javascript
import WebSocket from 'ws'; import { ethers } from 'ethers'; import 'dotenv/config'; const PRIVATE_KEY = process.env.PRIVATE_KEY; const RPC_URL = process.env.RPC_URLCreate and Sign Your Transaction
javascript
const provider = new ethers.JsonRpcProvider(RPC_URL); const wallet = new ethers.Wallet(PRIVATE_KEY, provider); // Get current nonce const nonce = await provider.getTransactionCount(wallet.address); // Build transaction const tx = { nonce: nonce, to: '0xRECIPIENT_ADDRESS', value: ethers.parseEther('0.1'), gasPrice: ethers.parseUnits('3', 'gwei'), gasLimit: 21000, chainId: 56 }; // Sign transaction const signedTx = await wallet.signTransaction(tx);Submit Privately
javascript
const ws = new WebSocket(`wss://shared.eu-central-1.getblock.io/${process.env.ACCESS_TOKEN}`); ws.on('open', () => { ws.send(JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'bsc_private_tx', params: { transaction: signedTx, mev_builders: ['all'] } })); }); ws.on('message', (data) => { const response = JSON.parse(data); if (response.result) { console.log('✅ Private TX submitted!'); console.log('TX Hash:', response.result.txHash); } else { console.error('❌ Error:', response.error); } ws.close(); });Response
bash
Wallet: 0xD1AF2dAc4e0a.... Recipient: 0xd26ea..... Amount: 0.001 BNB Mode: Private (MEV Protected) Submitting private transaction... ✅ Private transaction submitted! TX Hash: 14223ac9adf33b77e4b52e8612dd351517b1bbc5b771567089994a6183f46df2 BSCScan: https://bscscan.com/tx/14223ac9adf33b77e4b52e8612dd351517b1bbc5b771567089994a6183f46df2
Complete Example: Private BNB Transfer
javascriptimport WebSocket from "ws";
import { ethers } from "ethers";
import "dotenv/config";
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const RPC_URL = process.env.RPC_URL;
async function sendPrivateTransaction(recipient, amountBNB) {
const provider = new ethers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
console.log("Wallet:", wallet.address);
console.log("Recipient:", recipient);
console.log("Amount:", amountBNB, "BNB");
console.log("Mode: Private (MEV Protected)");
// Get nonce
const nonce = await provider.getTransactionCount(wallet.address);
// Build transaction
const signedTx = await wallet.signTransaction({
nonce: nonce,
to: recipient,
value: ethers.parseEther(amountBNB),
gasPrice: ethers.parseUnits("3", "gwei"),
gasLimit: 21000,
chainId: 56,
});
const signedTxNoPrefix = signedTx.startsWith("0x")
? signedTx.slice(2)
: signedTx;
// Submit privately
const ws = new WebSocket(process.env.ACCESS_TOKEN);
return new Promise((resolve, reject) => {
ws.on("open", () => {
console.log("\nSubmitting private transaction...");
ws.send(
JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "bsc_private_tx",
params: {
transaction: signedTxNoPrefix,
mev_builders: ["all"],
},
}),
);
});
ws.on("message", (data) => {
const response = JSON.parse(data);
ws.close();
if (response.result) {
console.log("\n✅ Private transaction submitted!");
console.log("TX Hash:", response.result.txHash);
console.log(
"BSCScan:",
`https://bscscan.com/tx/${response.result.txHash}`,
);
resolve(response.result.txHash);
} else {
console.error("\n❌ Error:", response.error);
reject(response.error);
}
});
ws.on("error", reject);
});
}
// Usage
sendPrivateTransaction(process.env.TO_ADDRESS, "0.001").catch(console.error);
Complete Example: MEV-Protected PancakeSwap Trade
javascriptimport WebSocket from 'ws';
import { ethers } from 'ethers';
import 'dotenv/config';
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const RPC_URL = process.env.RPC_URL;
const PANCAKE_ROUTER = '0x10ED43C718714eb63d5aA57B78B54704E256024E';
const WBNB = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c';
async function privateSwap(tokenAddress, amountBNB, minAmountOut) {
const provider = new ethers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
// Router ABI
const routerABI = [
'function swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) payable'
];
const router = new ethers.Contract(PANCAKE_ROUTER, routerABI, wallet);
// Build swap calldata
const deadline = Math.floor(Date.now() / 1000) + 300;
const swapData = router.interface.encodeFunctionData('swapExactETHForTokens', [
minAmountOut,
[WBNB, tokenAddress],
wallet.address,
deadline
]);
// Get nonce
const nonce = await provider.getTransactionCount(wallet.address);
// Sign transaction
const signedTx = await wallet.signTransaction({
nonce: nonce,
to: PANCAKE_ROUTER,
value: ethers.parseEther(amountBNB),
data: swapData,
gasPrice: ethers.parseUnits('3', 'gwei'),
gasLimit: 300000,
chainId: 56
});
console.log('Swap details:');
console.log(' Amount:', amountBNB, 'BNB');
console.log(' Token:', tokenAddress);
console.log(' Min out:', ethers.formatEther(minAmountOut));
console.log(' Mode: Private (MEV Protected)');
// Submit privately
const ws = new WebSocket(`wss://shared.eu-central-1.getblock.io/${process.env.ACCESS_TOKEN}`);
return new Promise((resolve, reject) => {
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'bsc_private_tx',
params: {
transaction: signedTx,
mev_builders: ['all']
}
}));
});
ws.on('message', (data) => {
const response = JSON.parse(data);
ws.close();
if (response.result) {
console.log('\n✅ Private swap submitted!');
console.log('TX Hash:', response.result.txHash);
console.log('BSCScan:', `https://bscscan.com/tx/${response.result.txHash}`);
resolve(response.result.txHash);
} else {
console.error('\n❌ Error:', response.error);
reject(response.error);
}
});
});
}
// Usage: Swap 1 BNB for BUSD (MEV protected)
privateSwap(
'0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', // BUSD
'1.0', // 1 BNB
ethers.parseEther('200') // Min 200 BUSD
).catch(console.error);Selecting Specific Builders
There are list of builders who should receive the transaction without delay. There are:
bloxroute: bloXroute internal builder(default)all: all builders- Other options:
48club,blockrazor,jetbldr,nodereal
javascriptparams: {
transaction: signedTx,
mev_builders: ['48club', 'bloxroute'] // Specific builders only
}Troubleshooting
| Problem | Solution |
|---|---|
| Transaction not included | Without a priority tip, private transactions compete based on gas fees alone. If your transaction isn't being included: Increase gas price — Higher gas = higher priority for buildersAdd a priority tip — See Private Transactions with TipsTry specific builders — Some builders may be more responsive |
| "Invalid transaction" | Verify your transaction is properly signedCheck the chain ID is 56 (BSC Mainnet)Ensure the nonce is correct |
| Connection issues | Verify your API key is validCheck network connectivityTry reconnecting after a few seconds |
Next Steps
To increase the priority for inclusion in your private transactions, see Private Transactions with Tips.