Socket
Book a DemoInstallSign in
Socket

@metamask/abi-utils

Package Overview
Dependencies
Maintainers
9
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/abi-utils

Lightweight utilities for encoding and decoding Solidity ABI

3.0.0
latest
Source
npmnpm
Version published
Weekly downloads
178K
8.44%
Maintainers
9
Weekly downloads
 
Created

What is @metamask/abi-utils?

@metamask/abi-utils is a utility library for working with Ethereum contract ABIs (Application Binary Interfaces). It provides functions to encode and decode data according to ABI specifications, which is essential for interacting with smart contracts on the Ethereum blockchain.

What are @metamask/abi-utils's main functionalities?

Encoding Function Calls

This feature allows you to encode a function call to a smart contract. The code sample demonstrates encoding a call to a function named 'set' with a single uint256 argument.

const { encodeFunctionCall } = require('@metamask/abi-utils');

const abi = [{
  "constant": false,
  "inputs": [
    {
      "name": "x",
      "type": "uint256"
    }
  ],
  "name": "set",
  "outputs": [],
  "type": "function"
}];

const data = encodeFunctionCall(abi[0], ['123']);
console.log(data);

Decoding Function Calls

This feature allows you to decode a function call from a smart contract. The code sample shows how to decode a call to the 'set' function with a uint256 argument.

const { decodeFunctionCall } = require('@metamask/abi-utils');

const abi = [{
  "constant": false,
  "inputs": [
    {
      "name": "x",
      "type": "uint256"
    }
  ],
  "name": "set",
  "outputs": [],
  "type": "function"
}];

const data = '0x60fe47b1000000000000000000000000000000000000000000000000000000000000007b';
const decoded = decodeFunctionCall(abi[0], data);
console.log(decoded);

Other packages similar to @metamask/abi-utils

Keywords

ethereum

FAQs

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.