Solana.Key (Solana v0.1.0)
View SourceFunctions for creating and validating Solana keys and keypairs.
Summary
Functions
Checks to see if a Solana.Key.t/0
is valid.
decodes a base58-encoded key and returns it in a tuple.
decodes a base58-encoded key and returns it.
Derives a program address from seeds and a program ID.
Finds a valid program address.
Generates a public/private key pair in the format {private_key, public_key}
Reads a public/private key pair from a file system
wallet in the format
{private_key, public_key}
. Returns {:ok, pair}
if successful, or {:error, reason}
if not.
Derive a public key from another key, a seed, and a program ID.
Types
Functions
Checks to see if a Solana.Key.t/0
is valid.
decodes a base58-encoded key and returns it in a tuple.
If it fails, return an error tuple.
decodes a base58-encoded key and returns it.
Throws an ArgumentError
if it fails.
Derives a program address from seeds and a program ID.
@spec find_address(seeds :: [binary()], program_id :: t()) :: {:ok, t(), nonce :: byte()} | {:error, :no_nonce}
Finds a valid program address.
Valid addresses must fall off the ed25519 curve; generate a series of nonces, then combine each one with the given seeds and program ID until a valid address is found. If a valid address is found, return the address and the nonce in a tuple. Otherwise, return an error tuple.
@spec pair() :: pair()
Generates a public/private key pair in the format {private_key, public_key}
Reads a public/private key pair from a file system
wallet in the format
{private_key, public_key}
. Returns {:ok, pair}
if successful, or {:error, reason}
if not.
@spec with_seed(base :: t(), seed :: binary(), program_id :: t()) :: {:ok, t()} | {:error, binary()}
Derive a public key from another key, a seed, and a program ID.
The program ID will also serve as the owner of the public key, giving it permission to write data to the account.