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

ethereumjs-abi

Package Overview
Dependencies
Maintainers
7
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-abi

Decoder and encoder for the Ethereum ABI

latest
Source
npmnpm
Version
0.6.8
Version published
Weekly downloads
385K
34.19%
Maintainers
7
Weekly downloads
 
Created

What is ethereumjs-abi?

The ethereumjs-abi package is a JavaScript library for encoding and decoding data according to the Ethereum ABI (Application Binary Interface) specifications. It is commonly used for interacting with smart contracts on the Ethereum blockchain, allowing developers to encode function calls and decode responses.

What are ethereumjs-abi's main functionalities?

Encoding Function Calls

This feature allows you to encode function calls to be sent to a smart contract. The example encodes a call to the 'transfer' function with an address and a value.

const abi = require('ethereumjs-abi');
const methodSignature = 'transfer(address,uint256)';
const params = ['0xRecipientAddress', 1000];
const encodedData = abi.simpleEncode(methodSignature, ...params);
console.log(encodedData.toString('hex'));

Decoding Function Responses

This feature allows you to decode the response from a smart contract function call. The example decodes the response from a 'balanceOf' function call.

const abi = require('ethereumjs-abi');
const methodSignature = 'balanceOf(address)';
const encodedData = '0xEncodedData';
const decodedData = abi.simpleDecode(methodSignature, Buffer.from(encodedData, 'hex'));
console.log(decodedData);

Encoding Event Logs

This feature allows you to encode event logs for smart contract events. The example encodes a 'Transfer' event log with from and to addresses and a value.

const abi = require('ethereumjs-abi');
const eventSignature = 'Transfer(address,address,uint256)';
const params = ['0xFromAddress', '0xToAddress', 1000];
const encodedLog = abi.simpleEncode(eventSignature, ...params);
console.log(encodedLog.toString('hex'));

Decoding Event Logs

This feature allows you to decode event logs from smart contract events. The example decodes a 'Transfer' event log.

const abi = require('ethereumjs-abi');
const eventSignature = 'Transfer(address,address,uint256)';
const encodedLog = '0xEncodedLog';
const decodedLog = abi.simpleDecode(eventSignature, Buffer.from(encodedLog, 'hex'));
console.log(decodedLog);

Other packages similar to ethereumjs-abi

Keywords

ethereum

FAQs

Package last updated on 13 Aug 2019

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