Socket
Socket
Sign inDemoInstall

web3-eth-contract

Package Overview
Dependencies
66
Maintainers
4
Versions
359
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-eth-contract

Web3 module to interact with Ethereum smart contracts.


Version published
Maintainers
4
Weekly downloads
399,957
decreased by-7.99%

Weekly downloads

Readme

Source

web3.js

web3.js - Eth Contract Package

ES Version Node Version NPM Package Downloads

This is a sub-package of web3.js.

web3-eth-contract contains the contract package used in web3-eth.

Installation

You can install the package either using NPM or using Yarn

Using NPM

npm install web3-eth-contract

Using Yarn

yarn add web3-eth-contract

Getting Started

  • :writing_hand: If you have questions submit an issue or join us on Discord Discord

Prerequisites

Usage

You can initialize the typesafe Contract API instance with the following.

import { Contract } from 'web3-eth-contract';

const abi = [...] as const;

const contract = new Contract(abi);
  • We prefer that you use web3.eth.Contract API in normal usage.
  • The use of as const is necessary to have fully type-safe interface for the contract.
  • As the ABIs are not extensive in size, we suggest declaring them as const in your TS project.
  • This approach is more flexible and seamless compared to other approaches of off-line compiling ABIs to TS interfaces (such as TypeChain.

Compatibility

We have tested the TypeScript interface support for the ABIs compiled with solidity version v0.4.x and above. If you face any issue regarding the contract typing, please create an issue to report to us.

The TypeScript support for fixed length array types are supported up 30 elements. See more details here. This limitation is only to provide more performant developer experience in IDEs. In future we may come up with a workaround to avoid this limitation. If you have any idea feel free to share.

Package.json Scripts

ScriptDescription
cleanUses rimraf to remove dist/
buildUses tsc to build package and dependent packages
lintUses eslint to lint package
lint:fixUses eslint to check and fix any warnings
formatUses prettier to format the code
testUses jest to run unit tests
test:integrationUses jest to run tests under /test/integration
test:unitUses jest to run tests under /test/unit

FAQs

Last updated on 26 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc