Skip to content

Latest commit

 

History

History
210 lines (125 loc) · 4.19 KB

Documentation.md

File metadata and controls

210 lines (125 loc) · 4.19 KB

rsk-utils documentation

Addresses

zeroAddress() ⇒ String

Returns the zero address

isAddress(address) ⇒ Boolean

Check if a string is an address

Params

  • address String

toChecksumAddress(address, chainId) ⇒ String

Implements EIP-1191 Address Checksum

Returns: String - checksummed address
Params

  • address String
  • chainId Integer | String

isValidChecksumAddress(address, chainId) ⇒ Boolean

Validates address checksum

Params

  • address String
  • chainId Integer | String

isValidAddress(address, chainId) ⇒ Boolean

Checks if an address is valid.

Params

  • address String
  • chainId Integer | String

searchChecksummedNetworks(address, [networks]) ⇒ Array

Search network info of checksummed address

Params

isZeroAddress(address, chainId) ⇒ Boolean

Checks if is zero address.

Params

  • address String
  • chainId Integer | String

Arrays

arrayIntersection(a, b) ⇒ Array

Returns: Array - a ∩ b
Params

  • a Array
  • b Array

arrayDifference(a, b) ⇒ Array

Returns: Array - a - b
Params

  • a Array
  • b Array

arraySymmetricDifference(a, b) ⇒ Array

Returns: Array - a - b
Params

  • a Array
  • b Array

hasValue(haystack, needle) ⇒ Boolean

Check if an array contains some of the searched items

Params

  • haystack Array
  • needle Array

includesAll(haystack, needle) ⇒ Boolean

Check if an array contains all the searched items

Params

  • haystack Array
  • needle Array

Bytes

toBuffer(value, [encoding]) ⇒ Buffer

Converts strings or numbers to buffer

Params

  • value string | number | buffer
  • [encoding] String = 'hex'

bufferToHex(buffer) ⇒ String

Converts buffer to hex string

Params

  • buffer Buffer

Hashes

keccak256(input, [format]) ⇒ Buffer

Creates Keccak sha256 hash

Params

  • input String | Number | Array | Buffer
  • [format] String = 'hex'

Strings

isHexString(str) ⇒ Boolean

Checks if a string is hex string

Params

  • str String

add0x(str) ⇒ String

Add '0x' at start of hex strings, honoring prefix

Params

  • str String

hasHexPrefix(str) ⇒ Boolean

Checks if string is hex prefixed

Params

  • str String

stripHexPrefix(str) ⇒ String

remove 0x from start of string

Params

  • str String

remove0x(value) ⇒ Any

Remove '0x' from hex strings, honoring prefix

Returns: Any - if value is hex string, {String} without '0x'
Params

  • value Any

isTxOrBlockHash(str) ⇒ Boolean

Checks if a string is a tx or block hash

Returns: Boolean - '
Params

  • str string