Solana.RPC (Solana v0.2.0) View Source

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

Link to this section Summary

Types

Solana JSON-RPC API client.

Functions

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

Sends the provided requests to the configured Solana RPC endpoint.

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

Link to this section Types

Specs

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

Solana JSON-RPC API client.

Link to this section Functions

Specs

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(client, Solana.RPC.Request.request_airdrop(key, 1))
iex> is_binary(signature)
true

Options

Sends the provided requests to the configured Solana RPC endpoint.

Link to this function

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

View Source

Specs

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.