Solana.RPC (Solana v0.1.0)
View SourceFunctions for dealing with Solana's JSON-RPC API.
Summary
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
@type client() :: Tesla.Client.t()
Solana JSON-RPC API client.
Functions
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
:adapter
(term/0
) - WhichTesla
adapter to use. The default value isTesla.Adapter.Httpc
.:network
- Required. Which Solana cluster to connect to.:retry_options
(keyword/0
) - Options to pass toTesla.Middleware.Retry
. The default value is[]
.:headers
(list of tuple ofString.t/0
,String.t/0
values) - API headers The default value is[]
.
@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.
Sends the provided requests to the configured Solana RPC endpoint.