EIP-55 v0.1.0 EIP55

Provides EIP-55 encoding and validation functions.

Link to this section Summary

Functions

Encodes an Ethereum address into an EIP-55 checksummed address.

Determines whether the given Ethereum address has a valid EIP-55 checksum.

Link to this section Functions

Link to this function

encode(address)

encode(String.t() | binary()) ::
  {:ok, String.t()} | {:error, :unrecognized_address_format}

Encodes an Ethereum address into an EIP-55 checksummed address.

Examples

iex> EIP55.encode("0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed")
{:ok, "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"}

iex> EIP55.encode(<<90, 174, 182, 5, 63, 62, 148, 201, 185, 160,
...> 159, 51, 102, 148, 53, 231, 239, 27, 234, 237>>)
{:ok, "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"}

iex> EIP55.encode("not an address")
{:error, :unrecognized_address_format}
Link to this function

valid?(address)

Determines whether the given Ethereum address has a valid EIP-55 checksum.

Examples

iex> EIP55.valid?("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")
true

iex> EIP55.valid?("0x5AAEB6053f3e94c9b9a09f33669435e7ef1beaed")
false

iex> EIP55.valid?("not an address")
false