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

@0x/0x-parser

Package Overview
Dependencies
Maintainers
13
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0x/0x-parser

🧾 Designed for 0x integrators: This parser library decodes swap details from 0x transactions on Ethereum.

  • 0.3.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213
decreased by-42.74%
Maintainers
13
Weekly downloads
 
Created
Source

0x-parser

npm version build and test codecov

Designed for 0x integrators, this library tackles the complex task of parsing swap amounts from 0x transactions, particularly when trades involve Automated Market Makers (AMMs). Given these trades can experience slippage, the final swap amounts cannot be anticipated before executing the trade. This library takes a transaction hash as input and parses the event logs to identify the exact swap amounts. Try the demo here.

React demo app for 0x-parser

Installation

npm install @0x/0x-parser

Usage

import { parseSwap } from '@0x/0x-parser';

async function main() {
  const response = await fetch(
    "https://raw.githubusercontent.com/0xProject/protocol/development/packages/contract-artifacts/artifacts/IZeroEx.json"
  );

  const IZeroEx = await response.json();

  const data = await parseSwap({
    rpcUrl: "https://eth.llamarpc.com",
    exchangeProxyAbi: IZeroEx.compilerOutput.abi,
    transactionHash: "0xd8637124d650268ae7680781809800e103a3a2bee9fec56083028fea6d98140b",
  });

  console.log(data);
}

main();

This package directly integrates the latest version of Ethers.js, a decision driven by the rapid and often inconsistent upgrade patterns observed in some web3 codebases. This decision simplifies the source code by eliminating the need to support multiple versions of Ethers.js. However, it may lead to redundancy if you're already using the provider and contract modules in the latest Ethers.js version. This redundancy, though, might not affect your application.

The impact this library may have on your app's bundle size varies depending on the context. It's not a concern for server-side scripts, but could influence the initial bundle size of client-side browser applications. Given this library tree-shakes Ethers.js dependencies, it's beneficial to use lazy loading to prevent an increase in your client application's initial bundle size. For a demonstration of this, refer to the example available here.

Examples

This repository includes examples you can execute locally. Navigate to the /examples directory for additional README information on how to run the demos locally. You can also explore a live demo of 0x-parser here.

Contributing

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

Keywords

FAQs

Package last updated on 20 Jun 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