Making RPC Requests

  • A session that handles communication with the Solana JSON-RPC API.

    See more

    Declaration

    Swift

    public class RPCSession
  • A node on the Solana network, addressable via JSON-RPC calls.

    See more

    Declaration

    Swift

    public struct RPCNode
  • The protocol Solana JSON-RPC requests must confrom to.

    See more

    Declaration

    Swift

    public protocol RPCRequest
  • The structure that wraps each JSON-RPC request made to a Solana node, providing it with necessary information about how the request should be performed and identified in responses.

    You can provide this wrapper manually with your request, allowing you to specify information like the version of the JSON-RPC spec and the Integer ID the node will use in communication about this request, or you can allow your RPCSession to do this for you.

    Letting RPCSession do the work - most common

    let session = RPCSession(...)
    let request = RandomInformationRequest(...)
    
    // You will not have knowledge of the JSON-RPC Spec
    // or the identifier sent to the node, but
    // because of the framework's structure, you usually
    // don't need either of these.
    let publisher = session.publish(request)
    

    Manually building the tagged request

    let session = RPCSession(...)
    let request = RandomInformationRequest(...)
    
    // You can keep track of this ID and throw all your requests
    // and responses around however you want this way.
    let taggedRequest = TaggedRPCRequest(request, id: 123456)
    let publisher = session.publish(wrappedRequest)
    
    See more

    Declaration

    Swift

    public struct TaggedRPCRequest<Request> : Encodable where Request : RPCRequest
  • A protocol that represents the bridging logic betweeen a source of knowledge and a session that handles Solana JSON-RPC requests.

    Conform to this protocol and set up an RPCSession object with your conforming object to create a custom testing or mock system. For normal use, RPCNetworkRequestAdaptor comes pre-configured, and RPCPassthroughRequestAdaptor can handle sending flat files from disk.

    See more

    Declaration

    Swift

    public protocol RPCRequestAdaptor