New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mev-boost-aa/account-sdk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mev-boost-aa/account-sdk

MEV Boost ERC-4337 Account SDK

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

mev-boost-aa-account-sdk

The account sdk of MEVBoostAA is built upon userOp.js of stackup.

Dependecies

ethers: "5.7.2"

userop: "^0.3.0"

Install

npm i @mev-boost-aa/account-sdk

Demo

import { MEVBoostAccount } from "@mev-boost-aa/account-sdk";
import { BigNumberish, BytesLike, ethers } from "ethers";
import { Client } from "userop";

async function demo(
  signer: ethers.Signer,
  rpcUrl: string,
  mevBoostPaymaster: string,
  mevBoostAccountFactory: string,
  op: { to: string; value: BigNumberish; data: BytesLike },
  boostOp: {
    minAmount: BigNumberish;
    selfSponsoredAfter: BigNumberish;
    to: string;
    value: BigNumberish;
    data: BytesLike;
  },
  entryPoint?: string,
  overrideBundlerRpc?: string
) {
  const client = await Client.init(rpcUrl, {
    entryPoint,
    overrideBundlerRpc,
  });
  const mevBoostAccount = await MEVBoostAccount.init(signer, rpcUrl, {
    factory: mevBoostAccountFactory,
    mevBoostPaymaster,
    // `overrideBundlerRpc` is required if rpcUrl cannot provide apis of bundler
    overrideBundlerRpc,
    entryPoint,
  });

  // Case1: Normal UserOp
  // execute / executeBatch
  mevBoostAccount.executeBatch([op.to], [op.value], [op.data]);

  let res = await client.sendUserOperation(mevBoostAccount, {
    onBuild: (op) => console.log("Signed UserOperation:", op),
  });
  console.log(`UserOpHash: ${res.userOpHash}`);

  console.log("Waiting for transaction...");
  let ev = await res.wait();
  console.log(`Transaction hash: ${ev?.transactionHash ?? null}`);

  // Case2: Boost UserOp
  // boostExecute / boostExecuteBatch
  // boostOp can be executed before `selfSponsoredAfter` when searcher provides mev (>= `minAmount` wei) and userOp fee
  // boostOp can be also executed after `selfSponsoredAfter` by default
  mevBoostAccount.boostExecuteBatch(
    {
      minAmount: boostOp.minAmount,
      selfSponsoredAfter: boostOp.selfSponsoredAfter,
    },
    [boostOp.to],
    [boostOp.value],
    [boostOp.data]
  );
  res = await client.sendUserOperation(mevBoostAccount, {
    onBuild: (op) => console.log("Signed UserOperation:", op),
  });
  console.log(`UserOpHash: ${res.userOpHash}`);

  // check whether boostOp is filled
  console.log("Waiting for filled boostOp...");
  const boostOpHash = mevBoostAccount.boostOpHash(mevBoostAccount.getOp());
  const bev = await mevBoostAccount.boostWait(
    boostOpHash,
    boostOp.selfSponsoredAfter
  );
  console.log(`Transaction hash: ${bev?.transactionHash ?? null}`);

  // boostOp has not been filled
  console.log("Waiting for transaction...");
  ev = await res.wait();
  console.log(`Transaction hash: ${ev?.transactionHash ?? null}`);
}

Tests

npm test

Keywords

FAQs

Package last updated on 03 Jul 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc