Note
This documentation is work in progress and web3.js 1.0 is not yet released! You can find the current documentation for web3 0.x.x at github.com/ethereum/wiki/wiki/JavaScript-API.
web3.eth.Iban¶
The web3.eth.Iban
function lets convert ethereum addresses from and to IBAN and BBAN.
Iban¶
new web3.eth.Iban(ibanAddress)
Generates a iban object with conversion methods and vailidity checks. Also has singleton functions for conversion like Iban.toAddress(), Iban.toIban(), Iban.fromEthereumAddress(), Iban.fromBban(), Iban.createIndirect(), Iban.isValid().
Parameters¶
String
: the IBAN address to instantiate an Iban instance from.
Returns¶
Object
- The Iban instance.
toAddress¶
web3.eth.Iban.toAddress(ibanAddress)
Singleton: Converts a direct IBAN address into an ethereum address.
Note
This method also exists on the IBAN instance.
Parameters¶
String
: the IBAN address to convert.
Returns¶
String
- The ethereum address.
Example¶
web3.eth.Iban.toAddress("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS");
> "0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8"
toIban¶
web3.eth.Iban.toIban(address)
Singleton: Converts an ethereum address to a direct IBAN address.
Parameters¶
String
: the ethereum address to convert.
Returns¶
String
- The IBAN address.
Example¶
web3.eth.Iban.toIban("0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8");
> "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"
fromEthereumAddress¶
web3.eth.Iban.fromEthereumAddress(address)
Singleton: Converts an ethereum address to a direct IBAN instance.
Parameters¶
String
: the ethereum address to convert.
Returns¶
Object
- The IBAN instance.
Example¶
web3.eth.Iban.fromEthereumAddress("0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8");
> Iban {_iban: "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"}
fromBban¶
web3.eth.Iban.fromBban(bbanAddress)
Singleton: Converts an BBAN address to a direct IBAN instance.
Parameters¶
String
: the BBAN address to convert.
Returns¶
Object
- The IBAN instance.
Example¶
web3.eth.Iban.fromBban('ETHXREGGAVOFYORK');
> Iban {_iban: "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"}
createIndirect¶
web3.eth.Iban.createIndirect(options)
Singleton: Creates an indirect IBAN address from a institution and identifier.
Parameters¶
Object
: the options object as follows:institution
-String
: the institution to be assignedidentifier
-String
: the identifier to be assigned
Returns¶
Object
- The IBAN instance.
Example¶
web3.eth.Iban.createIndirect({
institution: "XREG",
identifier: "GAVOFYORK"
});
> Iban {_iban: "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"}
isValid¶
web3.eth.Iban.isValid(address)
Singleton: Checks if an IBAN address is valid.
Note
This method also exists on the IBAN instance.
Parameters¶
String
: the IBAN address to check.
Returns¶
Boolean
Example¶
web3.eth.Iban.isValid("XE81ETHXREGGAVOFYORK");
> true
web3.eth.Iban.isValid("XE82ETHXREGGAVOFYORK");
> false // because the checksum is incorrect
var iban = new web3.eth.Iban("XE81ETHXREGGAVOFYORK");
iban.isValid();
> true
isDirect¶
web3.eth.Iban.isDirect()
Checks if the IBAN instance is direct.
Parameters¶
none
Returns¶
Boolean
Example¶
var iban = new web3.eth.Iban("XE81ETHXREGGAVOFYORK");
iban.isDirect();
> false
isIndirect¶
web3.eth.Iban.isIndirect()
Checks if the IBAN instance is indirect.
Parameters¶
none
Returns¶
Boolean
Example¶
var iban = new web3.eth.Iban("XE81ETHXREGGAVOFYORK");
iban.isIndirect();
> true
checksum¶
web3.eth.Iban.checksum()
Returns the checksum of the IBAN instance.
Parameters¶
none
Returns¶
String
: The checksum of the IBAN
Example¶
var iban = new web3.eth.Iban("XE81ETHXREGGAVOFYORK");
iban.checksum();
> "81"
institution¶
web3.eth.Iban.institution()
Returns the institution of the IBAN instance.
Parameters¶
none
Returns¶
String
: The institution of the IBAN
Example¶
var iban = new web3.eth.Iban("XE81ETHXREGGAVOFYORK");
iban.institution();
> 'XREG'
client¶
web3.eth.Iban.client()
Returns the client of the IBAN instance.
Parameters¶
none
Returns¶
String
: The client of the IBAN
Example¶
var iban = new web3.eth.Iban("XE81ETHXREGGAVOFYORK");
iban.client();
> 'GAVOFYORK'
toAddress¶
web3.eth.Iban.toAddress()
Returns the ethereum address of the IBAN instance.
Parameters¶
none
Returns¶
String
: The ethereum address of the IBAN
Example¶
var iban = new web3.eth.Iban('XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS');
iban.toAddress();
> '0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8'