What is web3-eth-iban?
The web3-eth-iban npm package is a utility for handling IBAN (International Bank Account Number) addresses in the context of Ethereum. It allows for the conversion between IBAN and Ethereum addresses, validation of IBAN addresses, and other related functionalities.
What are web3-eth-iban's main functionalities?
Convert Ethereum address to IBAN
This feature allows you to convert a standard Ethereum address to an IBAN address. The code sample demonstrates how to use the `toIban` method to achieve this.
const Web3EthIban = require('web3-eth-iban');
const iban = Web3EthIban.toIban('0x1234567890123456789012345678901234567890');
console.log(iban);
Convert IBAN to Ethereum address
This feature allows you to convert an IBAN address back to a standard Ethereum address. The code sample demonstrates how to use the `toAddress` method to achieve this.
const Web3EthIban = require('web3-eth-iban');
const address = Web3EthIban.toAddress('XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS');
console.log(address);
Validate IBAN address
This feature allows you to validate whether a given IBAN address is valid. The code sample demonstrates how to use the `isValid` method to achieve this.
const Web3EthIban = require('web3-eth-iban');
const isValid = Web3EthIban.isValid('XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS');
console.log(isValid);
Other packages similar to web3-eth-iban
ethereumjs-util
The ethereumjs-util package provides a variety of utility functions for Ethereum, including address manipulation and validation. While it does not specifically handle IBAN addresses, it offers a broader range of utilities for Ethereum development.
web3-utils
The web3-utils package is part of the Web3.js library and provides various utility functions for Ethereum, such as address validation, conversion, and formatting. Similar to ethereumjs-util, it does not focus on IBAN addresses but offers a wide array of general-purpose utilities.
web3-eth-iban
This is a sub package of web3.js
This is the IBAN package to be used in the web3-eth
package.
Please read the documentation for more.
Installation
You can install the package either using NPM or using Yarn
Using NPM
npm install web3-eth-iban
Using Yarn
yarn add web3-eth-iban
Usage
const Web3EthIban = require('web3-eth-iban');
const iban = new Web3EthIban('XE75JRZCTTLBSYEQBGAS7GID8DKR7QY0QA3');
iban.toAddress() > '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B';
Types
All the TypeScript typings are placed in the types
folder.