Socket
Socket
Sign inDemoInstall

@flashbots/matchmaker-ts

Package Overview
Dependencies
22
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @flashbots/matchmaker-ts

Matchmaker client library for Flashbots mev-share.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

Flashbots Matchmaker

Client library for Flashbots MEV-share Matchmaker.

Based on prospective API docs.

quickstart

Install from npm:

yarn add @flashbots/matchmaker-ts
# or
npm i @flashbots/matchmaker-ts

Alternatively, clone the library & build from source:

git clone https://github.com/flashbots/matchmaker-ts
cd matchmaker-ts
yarn install && yarn build

use matchmaker in your project

:warning: Variables denoted in ALL_CAPS are placeholders; the code does not compile. examples/ contains compilable demos.

In your project:

import { Wallet, JsonRpcProvider } from "ethers"
import Matchmaker, { ShareBundleParams, PendingShareTransaction, ShareTransactionOptions } from "@flashbots/matchmaker-ts"

const provider = new JsonRpcProvider(GOERLI_RPC_URL)
const authSigner = new Wallet(FB_REPUTATION_PRIVATE_KEY, provider)
const matchmaker = new Matchmaker(authSigner, {chainId: 5, name: "goerli"})

examples

Source code

:information_source: Examples require a .env file (or that you populate your environment directly with the appropriate variables).

cd src/examples
cp .env.example .env
vim .env
send a tx with hints

This example sends a transaction to mev-share from the account specified by SENDER_PRIVATE_KEY with a hex-encoded string as data.

yarn example.tx
backrun a pending tx

This example watches the mev-share streaming endpoint for pending mev-share transactions and attempts to backrun them. The example runs until a backrun has been included on-chain.

yarn example.backrun

API

onShareTransaction

Starts listening for transactions on mev-share, registers the provided callback to be called when a new transaction is detected.

const callback = (tx: PendingShareTransaction) => {/* handle pending tx */}
const handler = matchmaker.onShareTransaction(callback)
// do some stuff...
handler.close()

sendShareTransaction

Sends a private transaction to Flashbots with specified hint parameters.

const shareTxParams: ShareTransactionOptions = {
    hints: {
        logs: true,
        calldata: false,
        functionSelector: true,
        contractAddress: true
    },
    maxBlockNumber: undefined,
}
await matchmaker.sendShareTransaction(SIGNED_TX, shareTxParams)

sendShareBundle

Sends a bundle; an array of transactions; which tries to backrun a pending mev-share transaction. Currently only one share transaction in shareTxs is supported.

const bundleParams: ShareBundleParams = {
    targetBlock: TARGET_BLOCK,
    shareTxs: [PENDING_TX_HASH],
    backrun: [SIGNED_BACKRUN_TX1, SIGNED_BACKRUN_TX2],
}
await matchmaker.sendShareBundle(bundleParams)

FAQs

Last updated on 13 Apr 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc