Socket
Socket
Sign inDemoInstall

@kodex-data/abi-tools

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kodex-data/abi-tools

The `@kodex-data/abi-tools` package provides several functions and types related to the Ethereum ABI (Application Binary Interface) specification.


Version published
Maintainers
3
Created
Source

@kodex-data/abi-tools

The @kodex-data/abi-tools package provides several functions and types related to the Ethereum ABI (Application Binary Interface) specification.

Installation

To use @kodex-data/abi-tools, simply run the following command:

yarn add @kodex-data/abi-tools 

or

npm install @kodex-data/abi-tools 

Usage

You can import the package and use the exported functions and types as follows:

import { isAbi, isAbiItem, validators, toSha256Hex } from '@kodex-data/abi-tools'

The following is a list of exported items:

  • isAbi, isAbiItem, isFragmentItem, and isFragmentArray: These are functions that check if the given input is a valid Ethereum ABI, ABI item, ABI fragment item, or an array of ABI fragment items respectively.
  • validators: An object that contains several validation functions and regular expressions used to validate various types of input, including integers, bytes, and arrays of bytes. These functions are used internally by the other exported functions.
  • toSha256Hex(str: string): string: A function that takes a string input, computes its SHA-256 hash, and returns it as a hexadecimal string.
  • abiToFnName(abi: AbiItem): string: A function that takes an ABI item object and returns the name of the corresponding function, if it exists.
  • typeToString(input: AbiInput): string: A function that takes an ABI input object and returns a string representation of its type.
  • abiToName(abi: AbiItem): string: A function that takes an ABI item object and returns a string representation of its function name, if it exists.
  • abiToSig(abi: AbiItem, with0x?: boolean): string: A function that takes an ABI item object and returns its 4-byte function signature as a hexadecimal string, with an optional with0x parameter indicating whether or not to include the "0x" prefix.
  • toFragment(abi: AbiItem): Fragments: A function that takes an ABI item object and returns a detailed ABI fragment object.
  • fromFragment(fragments: Fragments): AbiItem: A function that takes an ABI fragment object and returns the corresponding ABI item object.
  • toFragmentArray(abis: AbiItem[]): Fragments[]: A function that takes an array of ABI item objects and returns an array of corresponding ABI fragment objects.
  • toFragmentMap(abiItems: AbiItem[]): Map<string, Fragments>: A function that takes an array of ABI item objects and returns a map object where the keys are function names and the values are corresponding ABI fragment objects.
  • ItemIO: A type that represents the input and output types for an ABI item.

Keywords

FAQs

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