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.3
  • 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 is used to parse swap amounts from 0x transactions, a task that becomes complex when trades involve Automated Market Makers (AMMs). Given the potential for slippage in these trades, the final swap amounts cannot be anticipated before trade execution. This library addresses this challenge by accepting a transaction hash as input, then parses through the event logs to identify the exact swap amounts.

Installation

npm install @0x/0x-parser

Usage

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

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

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

  console.log(JSON.stringify(data);
}

main();

Live demo

Try a demo app that uses 0x-parser here.

0x parser React demo app

Examples

This repository includes an example you can execute locally using the npm run web:example command. Additionally, there's another repository that showcases how to use this package within a simple React app, which you can find here.

Contributing

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

Keywords

FAQs

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