Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

eth-contract-classifier

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-contract-classifier

## Description

latest
npmnpm
Version
1.0.23
Version published
Maintainers
1
Created
Source

eth-contract-classifier

Description

This project includes functions to interact with Ethereum contracts. It provides functionality to get ERC standards by ABI and bytecode. Support ERC20, ERC721, ERC1155, PROXY(DELEGATECALL).

Installation

npm install eth-contract-classifier

Usage

Import the functions from the project and use them in your code: const { getErcByBytecode, getProxyStatus, getErcByAbi, getSigs, isABI,getErcByBytecodePercent,getErcByAbiPercent } = require('eth-contract-classifier');

// Use the functions let ercType = getErcByAbi(abi); let ercTypeByBytecode = getErcByBytecode(bytecode);

Functions

getSigs(abi)

This function retrieves the function and event signatures from the given ABI. It takes an ABI (Application Binary Interface) of the contract as an argument and returns an array containing the function and event signatures.

isABI(abi, bytecode)

This function checks if the given ABI is compatible with the provided bytecode. It takes an ABI (Application Binary Interface) and the bytecode of the contract as arguments. It returns true if the ABI is compatible with the bytecode, otherwise returns false.

getErcByAbi(abi)

This function takes an ABI and an object containing various ABIs for different ERC standards. It calculates the percentage of matches for each ERC standard, sorts them, and returns the ERC standard with the highest percentage of matches.

getErcByBytecode(bytecode)

This function works similarly to getErcByAbi, but it takes bytecode instead of an ABI. It uses the web3.js library to encode the ABI functions into bytecode and checks if the input bytecode includes the function bytecode.

getProxyStatus(bytecode)

This function returns prox status. It takes bytecode of the proxy contract.

getErcByAbiPercent(abi, percent)

The getErcByAbiPercent function takes an ABI and an object containing various ABIs for different ERC standards. It calculates the percentage of matches for each ERC standard, sorts them, and returns an object with each ERC standard and its corresponding match percentage. Default is 100.

getErcByBytecodePercent(bytecode, percent)

The getErcByBytecodePercent function works similarly to getErcByAbiPercent, but it takes bytecode instead of an ABI. It uses the web3.js library to encode the ABI functions into bytecode and checks if the input bytecode includes the function bytecode. It returns an object with each ERC standard and its corresponding match percentage. Default is 100.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

FAQs

Package last updated on 14 Feb 2024

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