Send transactions via API
This method is for advanced users only. Your dashboard displays an RPC that accepts transactions into the private pool easily. We recommend using the eth_sendRawTransaction RPC method unless you want to customize the lifecycle of the transaction or the auction.
To send transactions, you will need:
The transactions
An API key. Create an account on the Developer Dashboard for free and get your API key.
Once a transaction is received, Merkle will run an auction with searchers. If no bid is made, your transaction will be released to trusted builders, ensuring it remains private and secure until block inclusion.
Send a new transaction
POST
https://mempool.merkle.io/transactions
Headers
X-MBS-Key*
String
Request Body
transactions*
String array
List of transactions to send to the private pool. Each transaction will be processed independently (not as a bundle).
privacy
String
hints
String array
bundle_types
String array
Types of bids allowed on auctions. By default, only backruns are allowed.
prevent_reverts
Bool
Prevent this transaction from reverting onchain. This transaction will not be mined if it reverts. Default: false
max_block_number
Number
The maximum block number this transaction should be broadcasted until. Afterwards the transaction will be dropped and considered "expired".
Here are examples on how to send transactions in several languages:
Javascript
const signer = {} // the ethers Signer
const tx = {} // the ethers Transaction
const signedTx = signer.signTransaction(tx)
await fetch(`https://mempool.merkle.io/transactions`, {
method: 'POST',
body: JSON.stringify({
transactions: [signedTx], // Array[String], List of signed transactions
source: "customer-123", // (Optional) String, A source tag
privacy: "default", // (Optional) String, The privacy profile
hints: [], // (Optional) Array[String], List of hints, overrides the privacy profile
bundle_types: ["backrun"], // (Optional) Array[String], List of allowed bundle types
release_targets: ["public"], // (Optional) Array[String], Either public or private
prevent_reverts: false, // (Optiona) Boolean, Prevent this transaction from reverting
}),
headers: {
'Content-Type': 'application/json',
'X-MBS-Key': '' // Your api key, get it at https://mbs.merkle.io
}
})
Go
tx := new(types.Transaction) // The types. Transaction from go-ethereum
txBytes, err := tx.MarshalBinary()
if err != nil { panic("could not serialize transaction") }
// To hex string
txHex := common.Bytes2Hex(txBytes)
// Send to the pool
type PoolSubmission struct {
// An array of transactions
Transactions []string `json:"transactions"`
// Optional, a source tag
Source string `json:"source"`
// Optional, a privacy profile
Privacy string `json:"privacy"`
// Optional, a list of hints, overrides the privacy profile
Hints []string `json:"hints"`
// Optional, a list of allowed bundles for this transaction
BundleTypes []string `json:"bundle_types"`
// Optional, a list of release targets
ReleaseTargets []string `json:"release_targets"`
// Optional, prevent reverts
PreventReverts bool `json:"prevent_reverts"`
}
submission := &PoolSubmission{
Transactions: []string{txHex}, // Array[String], List of signed transactions
Privacy: "default", // (Optional) String, The privacy setting
BundleTypes: []string{"backrun"}, // (Optional) Array[String], List of allowed bundle types
ReleaseTargets: []string{"public"}, // (Optional) Array[String], Either public or private
PreventReverts: False, // (Optional) Boolean, Prevent this transaction from reverting
}
submissionBody, err := json.Marshal(submission)
if err != nil { panic("could not serialize submission") }
// Send submission to the pool
http.Post("https://mempool.merkle.io/transactions", "application/json", bytes.NewBuffer(submissionBody) )
Last updated
Was this helpful?