RPC

public class RPC<T> where T : Decodable

A generic class representing an RPC call to the Tezos network. A type must be passed in when creating an instance of this object, this will be used by the network layer to parse the response and detect errors.

Public properties

  • The endpoint that will be added onto the TezosNodeConfig.primaryNodeURL to form a full URL for the request

    Declaration

    Swift

    public let endpoint: String
  • An optional payload for sending HTTP POST requests

    Declaration

    Swift

    public let payload: Data?
  • The expected response type from the network

    Declaration

    Swift

    public let responseType: T.Type
  • Computed property to indicate wheter or not this is a POST request

    Declaration

    Swift

    public var isPost: Bool { get }

Init

  • Init an RPC object, to be passed to the network layer to performa request to the node.

    Declaration

    Swift

    public init(endpoint: String, payload: Data?, responseType: T.Type)

    Parameters

    endpoint

    The endpoint to send the request too.

    payload

    An optional payload for POST requests.

    responseType

    The expected response type from the network.

  • Helper function to wrap up JSONEncoder().encode and log any errors.

    Declaration

    Swift

    public static func encodableToData<T>(encodable: T) -> Data? where T : Encodable

Available where T == String

  • Creates an RPC to fetch an XTZ balance for a given Address

    Declaration

    Swift

    public static func xtzBalance(forAddress address: String) -> RPC<String>
  • Creates an RPC to fetch a deelgate for a given Address

    Declaration

    Swift

    public static func getDelegate(forAddress address: String) -> RPC<String>
  • Creates an RPC to fetch the managerKey for a given Address

    Declaration

    Swift

    public static func managerKey(forAddress address: String) -> RPC<String?>
  • Creates an RPC to fetch the current counter for a given Address

    Declaration

    Swift

    public static func counter(forAddress address: String) -> RPC<String>
  • Creates an RPC to remotely forge an operation

    Declaration

    Swift

    public static func forge(operationPayload: OperationPayload) -> RPC<String>?
  • Creates an RPC to inject an operation

    Declaration

    Swift

    public static func inject(signedBytes: String) -> RPC<String>?

Available where T == BlockchainHead

  • Creates an RPC to fetch the HEAD of the blockchain and parse it into an object to extract the pieces we are interested in.

    Declaration

    Swift

    public static func blockchainHead() -> RPC<BlockchainHead>
  • Creates an RPC to fetch the HEAD of 3 blocks previous and parse it into an object to extract the pieces we are interested in.

    Declaration

    Swift

    public static func blockchainHeadMinus3() -> RPC<BlockchainHead>

Available where T == NetworkVersion

  • Creates an RPC to fetch the details about the version of the network running on the given server.

    Declaration

    Swift

    public static func networkVersion() -> RPC<NetworkVersion>

Available where T == NetworkConstants

  • Creates an RPC to fetch the network constants for the given server, such as how much mutez it costs per byte of storage, or the maximum allowed gas amount

    Declaration

    Swift

    public static func networkConstants() -> RPC<NetworkConstants>

Available where T == [OperationPayload]

  • Creates an RPC to remotely parse an operation to verify its contents. Function takes in a hash, as it is returned from the forge call. This function will do all the necessary parsing and formatting

    Declaration

    Swift

    public static func parse(hashToParse: String, metadata: OperationMetadata) -> RPC<[OperationPayload]>?

Available where T == [OperationResponse]

Available where T == OperationResponse

Available where T == Data

  • Creates an RPC to fetch a contracts Michelson storage

    Declaration

    Swift

    public static func contractStorage(contractAddress: String) -> RPC<Data>
  • Creates an RPC to fetch the contents of the given big map

    Declaration

    Swift

    public static func bigMap(id: String) -> RPC<Data>