npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@blocktorch/optimism-batch-decoder

v1.0.1

Published

Decode optimism rollup batcher transactions

Downloads

12

Readme

Optimism batch decoder

Decodes the calldata of a batcher transaction and returns the L2 transactions within it

Background

The transactions of a L2 rollup are batched together and submitted to a L1. The Batcher will submit these batches to a Batch Inbox Address on L1, which is an EOA and will save gas because no code will be executed. 0xFF00000000000000000000000000000000000010 is the Batch Inbox Address of Optimism on Ethereum. The calldata of each transaction to the Batch Inbox contains batches of L2 as an encoded and compressed hex string.

Installation

npm i @blocktorch/optimism-batch-decoder or yarn add @blocktorch/optimism-batch-decoder

Usage

decodeBatcherTransactionCalldata(calldata)

Decodes the L2 transactions from raw calldata

  • calldata - the calldata of the transaction by a Batcher to the Batch Inbox Address on L1. You can get it from the transaction page on Etherscan (Input Data -> View Input As Original). For an example, check example-data/calldata.txt.
import { decodeBatcherTransactionCalldata } from '@blocktorch/optimism-batch-decoder'

const batcherTransaction = await decodeBatcherTransactionCalldata(calldata)

decodeBatcherTransaction(txHash, providerUrl)

Wrapper for decodeBatcherTransactionCalldata. Will fetch the calldata for you based on the transaction hash.

  • txHash - hash of the L1 transaction to the Batch Inbox
  • providerUrl - RPC provider URL that is used to fetch data about the transaction

testWithExampleData(path?)

Test function to decode example calldata. You can provide the path to example call data, but by default it looks for example-data/calldata.txt in the repository.

  • path - path to your own calldata relative to the repository root.

BatcherTransaction

All of the functions will return a BatcherTransaction. It contains a version and its Frames. More about the batcher transaction format

Each Frame contains info about the Frame and its batches.

And each Batch contains a list of transactions and info about the Batch

Known issues

NB! SpanBatch decoding is unimplemented at the moment.


Made with 💛 at Blocktorch