Catalog npm
PACKAGE EXPLORERView in registry

@0x/0x-parser

npm

🧾 Designed for 0x integrators: This library parses 0x transactions on EVM blockchains into a format that is both user-friendly and easy to understand.

0x0x protocolaggregatordexethereumeventsgaslesslogsparsesettlerswaptokenstransactionserc-20evmexchange proxy
Versions collected57
Direct dependencies9From release 2.15.0
Last observed20 Oct, 22:20 UTC

README

Current package documentation

0x-parser

npm version minified size codecov build and test Medium

Blockchain Support

arbitrum
Arbitrum
avalanche
Avalanche
base
Base
bnb chain
BNB Chain
blast
Blast
ethereum
Ethereum
linea
Linea
mantle
Mantle
mantle
Monad
optimism
Optimism
polygon
Polygon
scroll
Scroll
coming soon
Mode
Worldchain
Worldchain
Unichain
Unichain
coming soon
Berachain
Plasma
Plasma
Abstract
Abstract
Robinhood Chain
Robinhood
coming soon
🔜
coming soon
🔜
coming soon
🔜

Overview

This library is designed for 0x integrators, simplifying the complex task of parsing 0x transactions into a format that is both user-friendly and easy to understand. When swapping tokens, one of the challenges is that the trade can experience slippage through Automated Market Makers (AMMs). This makes the final swap amounts difficult to predict prior to executing the trade. However, this library overcomes that challenge by parsing the transaction receipt and event logs to accurately identify the final swap amounts.

Demo

Try out the parser in a live code environment directly in your browser 🌐. You can also experience it in action through the demo UI app, which is built with 0x-parser.

Screenshot of demo app using 0x-parser

Requirements

0x-parser relies on the debug_traceTransaction Ethereum JSON-RPC method to parse 0x transactions. Ensure that your RPC node supports this method.

Installation

Step 1: Install Peer Dependency

First, make sure you have the required peer dependency viem installed. If you haven't installed it yet, you can do so with the following command:

npm install viem

Step 2: Install the Parsing Library

After installing the peer dependency, proceed to install the @0x/0x-parser package:

npm install @0x/0x-parser

Usage

import { parseSwap } from "@0x/0x-parser";
import { createPublicClient } from "viem";
import { http } from "viem";
import { mainnet } from "viem/chains";

async function main() {
  const RPC_URL = `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`;

  // You can pass any transaction hash that you got after submitted a 0x transaction:
  // https://etherscan.io/tx/0x2fc205711fc933ef6e5bcc0bf6e6a9bfc220b2d8073aea4f41305882f485669d
  const transactionHash = `0x2fc205711fc933ef6e5bcc0bf6e6a9bfc220b2d8073aea4f41305882f485669d`;

  const publicClient = createPublicClient({
    chain: mainnet,
    transport: http(RPC_URL),
  });

  const swap = await parseSwap({ publicClient, transactionHash });

  console.log(swap); // Logs the swap details.
}

main();

Development

This repository contains example code that you can run locally, which is useful for the development process. The code can be found in /examples/web/index.html and you can run the code by running npm run web:example.

Contributing

Contributions are always welcomed! Please read the contributing guidelines before submitting a pull request.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 57

Collected releases
VersionPublishedDirect dependenciesOpen version
2.15.0Registry latest1 Jul 20269
2.14.426 May 20269
2.14.316 Mar 20269
2.14.216 Mar 20269
2.14.027 Jan 20269
2.12.023 Nov 20259
2.11.020 Sept 20259
2.10.312 Jun 20259
2.10.27 Jun 20259
2.10.121 Mar 20259
2.10.025 Feb 20259
2.9.021 Feb 20259
2.8.012 Feb 20259
2.7.121 Jan 20259
2.7.01 Jan 20259
2.6.028 Oct 20249
2.5.027 Oct 20249
2.4.029 Sept 20249
2.3.026 Sept 20249
2.2.024 Sept 20249

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
0xproject/0x-parser

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:20 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:cc96dc6c49cccf2a594576d3580a498b863ecbfc89a60c43eb77fe31aab74fe3