Solana.RPC (Solana v0.1.0)

View Source

Functions for dealing with Solana's JSON-RPC API.

Summary

Types

Solana JSON-RPC API client.

Functions

Creates an API client used to interact with Solana's JSON-RPC API.

Sends the provided transactions to the configured RPC endpoint, then confirms them.

Sends the provided requests to the configured Solana RPC endpoint.

Types

client()

@type client() :: Tesla.Client.t()

Solana JSON-RPC API client.

Functions

client(opts)

@spec client(keyword()) :: client()

Creates an API client used to interact with Solana's JSON-RPC API.

Example

iex> key = Solana.keypair() |> Solana.pubkey!()
iex> client = Solana.RPC.client(network: "localhost")
iex> {:ok, signature} = Solana.RPC.send_request(client, Solana.RPC.Request.request_airdrop(key, 1))
iex> is_binary(signature)
true

Options

send_and_confirm(client, tracker, txs, opts \\ [])

@spec send_and_confirm(
  client(),
  pid(),
  [Solana.Transaction.t()] | Solana.Transaction.t(),
  keyword()
) ::
  {:ok, [binary()]} | {:error, :timeout, [binary()]}

Sends the provided transactions to the configured RPC endpoint, then confirms them.

Returns a tuple containing all the transactions in the order they were confirmed, OR an error tuple containing the list of all the transactions that were confirmed before the error occurred.

send_request(client, requests)

@spec send_request(client(), [term()] | term()) :: {:ok, term()} | {:error, term()}

Sends the provided requests to the configured Solana RPC endpoint.