Send transactions via API

This method is for advanced users only. Your dashboard displays an RPC that accepts transactions into the private pool easily.

To send transactions, you will need:

  • The transactions

  • An API key, create an account on the Developer Dashboard for free to get an API key.

Once a transaction are received, Merkle will run an auction with searchers. If no bid is made on your transaction, it will be released to trusted builders, protecting it from front-running.

Send a new transaction

POST https://mempool.merkle.io/transactions

Headers

NameTypeDescription

X-MBS-Key*

String

Merkle API key. Get one at Merkle Developers

Request Body

NameTypeDescription

transactions*

String array

List of transactions to send to the private pool

privacy

String

Privacy profile of the transaction. By default the value is default, learn more about Privacy.

hints

String array

If custom is passed as a privacy profile, a list of hints is required. Learn more about hints.

bundle_types

String array

Types of bids allowed on auctions. By default, only backruns are allowed.

release_Targets

String array

A list of places where to release the transaction if no bid is received, by default, the transaction is sent directly to block builder privately. Learn more about release.

prevent_reverts

Bool

Prevent this transaction from reverting onchain. This transaction will not be mined if it reverts. Default: false

,Here are examples on how to send transactions for some languages:

Javascript

const signer = {} // the ethers Signer
const tx = {} // the ethers Transation

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), 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 one 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},
    Privacy: "default", // (Optional), The privacy setting
    BundleTypes: []string{"backrun"}, // (Optional)
    ReleaseTargets: []string{"public"}, // (Optional)
    PreventReverts: False, // (Optional)
}

submissionBody, err := json.Marshal(submission)

if err != nil { panic("could not serialize submission") }

// Send to the pool
http.Post("https://mempool.merkle.io/transactions", "application/json", bytes.NewBuffer(submissionBody) )

Last updated