Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abitype

Package Overview
Dependencies
Maintainers
2
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abitype

Strict TypeScript types for Ethereum ABIs

  • 0.0.0-canary.20231011T200514
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
856K
increased by9.46%
Maintainers
2
Weekly downloads
 
Created

What is abitype?

The abitype npm package is designed to provide TypeScript types for Ethereum ABI (Application Binary Interface) definitions. It helps developers to work with Ethereum smart contracts in a type-safe manner, ensuring that the interactions with the contracts are correctly typed and reducing the risk of runtime errors.

What are abitype's main functionalities?

Define ABI Types

This feature allows you to define the ABI of a smart contract in a type-safe manner. The `Abi` type ensures that the structure of the ABI is correct and helps catch errors at compile time.

import { Abi } from 'abitype';

const myAbi: Abi = [
  {
    "constant": true,
    "inputs": [],
    "name": "myFunction",
    "outputs": [
      {
        "name": "",
        "type": "uint256"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  }
];

Type-safe Contract Interactions

This feature allows you to interact with smart contract functions in a type-safe manner. By defining the ABI and using the `AbiFunction` type, you can ensure that the interactions with the contract are correctly typed.

import { Abi, AbiFunction } from 'abitype';

const myAbi: Abi = [
  {
    "constant": true,
    "inputs": [],
    "name": "myFunction",
    "outputs": [
      {
        "name": "",
        "type": "uint256"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  }
];

const myFunction: AbiFunction = myAbi[0];

// Now you can interact with the function in a type-safe way
const result: number = await myContract.methods.myFunction().call();

Other packages similar to abitype

Keywords

FAQs

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