Elrondex.Account (Elrondex v0.1.1) View Source
Link to this section Summary
Functions
Generates an account based on a specific address.
Returns an account from the mnemonic.
Generates an account based on a specific private key.
Generates an account based on a specific public key.
Generates a random account.
Converts an account's private key to hex format.
Converts an account's public key to hex format.
Returns an account's address from the public key.
Signs the data.
Verifies the signature of the data.
Link to this section Functions
Generates an account based on a specific address.
Arguments
address
- a wallet's address
Examples
iex> Elrondex.Test.Bob.address()
...> |> Elrondex.Account.from_address()
...> |> Map.get(:public_key)
<<203, 118, 219, 103, 28, 45, 57, 174, 200, 185, 187, 95, 244, 197, 165, 240,
28, 122, 88, 250, 13, 128, 6, 242, 143, 81, 69, 130, 54, 31, 71, 129>>
Returns an account from the mnemonic.
Arguments
mnemonic
- a wallet's mnemonic
Examples
iex> Elrondex.Test.Bob.mnemonic()
...> |> Elrondex.Account.from_mnemonic()
...> |> Map.get(:address)
...> "erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
Generates an account based on a specific private key.
Arguments
private_key
- a private key (in binary or in hex format)
Examples
iex> Elrondex.Test.Bob.private_key()
...> |> Elrondex.Account.from_private_key()
...> |> Map.get(:address)
"erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
iex> Elrondex.Test.Bob.hex_private_key()
...> |> Elrondex.Account.from_private_key()
...> |> Map.get(:address)
"erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
Generates an account based on a specific public key.
Arguments
public_key
- a public key (in binary or in hex format)
Examples
iex> Elrondex.Test.Bob.public_key()
...> |>Elrondex.Account.from_public_key()
...> |>Map.get(:address)
"erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
Generates a random account.
Examples
iex> Elrondex.Account.generate_random().address
...> |> String.slice(0, 3)
"erd"
Converts an account's private key to hex format.
Arguments
account
- the account that uses the key
Examples
iex> Elrondex.Test.Bob.private_key()
...> |> Elrondex.Account.from_private_key()
...> |> Elrondex.Account.hex_private_key()
"5d251c79a032263f4af11acd06d6d5d92646b408a256a282155b8363e2f168bf"
Converts an account's public key to hex format.
Arguments
account
- the account that uses the key
Examples
iex> Elrondex.Test.Bob.public_key()
...> |> Elrondex.Account.from_public_key()
...> |> Elrondex.Account.hex_public_key()
"cb76db671c2d39aec8b9bb5ff4c5a5f01c7a58fa0d8006f28f514582361f4781"
Returns an account's address from the public key.
Arguments
public_key
- a public key (in binary or in hex format)Examples
iex> Elrondex.Test.Bob.account().public_key() ...> |> Elrondex.Account.public_key_to_address "erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
iex> Elrondex.Test.Bob.hex_public_key() ...> |> Elrondex.Account.public_key_to_address() "erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
Signs the data.
Arguments
data_to_sign
- data to signaccount
- the account that signs
Verifies the signature of the data.
Arguments
data_to_sign
- data to signsignature
- the signatureaccount
- the account that signed