TezosNodeClient

public class TezosNodeClient

The TezosNodeClient offers methods for interacting with the Tezos node to fetch balances, send transactions etc. The client will abstract away all the compelx tasks of remote forging, parsing, signing, preapply and injecting operations. It will also convert amounts from the network into Token objects to make common tasks easier.

Public Properties

  • The configuration object containing all the necessary settings to connect and communicate with the Tezos node

    Declaration

    Swift

    public let config: TezosNodeClientConfig
  • The NetworkService object that will perform all the networking calls

    Declaration

    Swift

    public var networkService: NetworkService
  • The OperationService object that will perform forging, parsing, signing, preapply and injections of operations

    Declaration

    Swift

    public var operationService: OperationService
  • The service responsible for calculating network fees on behalf of the user

    Declaration

    Swift

    public var feeEstimatorService: FeeEstimatorService
  • Available information about the version of the network, that the conected server is running. Call tezosNodeClient.fetchNetworkInformation(...) to populate

    Declaration

    Swift

    public var networkVersion: NetworkVersion?
  • Available information about the constants of the network, that the conected server is running. Call tezosNodeClient.fetchNetworkInformation(...) to populate

    Declaration

    Swift

    public var networkConstants: NetworkConstants?
  • Types of errors

    See more

    Declaration

    Swift

    public enum TezosNodeClientError : Error

Init

Balance

  • Gets the xtz balance for a given Address.

    Declaration

    Swift

    public func getBalance(forAddress address: String, completion: @escaping ((Result<XTZAmount, KukaiError>) -> Void))

    Parameters

    forAddress

    A Tezos network address, starting with "tz1", "tz2", "tz3" or "kt1"

    completion

    A callback containing a new Token object matching the xtz standard, or an error.

Delegate

  • Gets the delegate for the given address.

    Declaration

    Swift

    public func getDelegate(forAddress address: String, completion: @escaping ((Result<String, KukaiError>) -> Void))

    Parameters

    forAddress

    A Tezos network address, starting with "tz1", "tz2", "tz3" or "kt1"

    completion

    A callback containing a String with the delegate/baker’s address, or an error.

Estimate

  • Take an array of operations and estimate the gas, storage, baker fee and burn fees required to inject it onto the network If the supplied operations contain suggested fees (e.g. from a dApp) this function will estimate the fee and pick which ever is higher

    Declaration

    Swift

    public func estimate(operations: [Operation], walletAddress: String, base58EncodedPublicKey: String, completion: @escaping ((Result<FeeEstimatorService.EstimationResult, KukaiError>) -> Void))

    Parameters

    operations

    An array of Operation‘s to be injected.

    wallet

    The Wallet that will sign the operation

    completion

    A callback containing an updated array of Operation‘s with fees set correctly, or an error.

Send

  • Send an array of Operation‘s to the blockchain. Use OperationFactory to help create this array for common use cases.

    Declaration

    Swift

    public func send(operations: [Operation], withWallet wallet: Wallet, completion: @escaping ((Result<String, KukaiError>) -> Void))

    Parameters

    operations

    An array of Operation subclasses to be sent to the network.

    withWallet

    The Wallet instance that will sign the transactions.

    completion

    A completion closure that will either return the opertionID of an injected operation, or an error.

  • Send an already contrsutructed OperationPayload with the necessary OperationMetadata without having to fetch metadata again.

    Declaration

    Swift

    public func send(operationPayload: OperationPayload, operationMetadata: OperationMetadata, withWallet wallet: Wallet, completion: @escaping ((Result<String, KukaiError>) -> Void))

    Parameters

    operationPayload

    An OperationPayload that has already been constructed (e.g. from the estimation call).

    operationMetadata

    An OperationMetaData object containing all the info about the network that the call needs for forge -> inject.

    withWallet

    The Wallet instance that will sign the transactions.

    completion

    A completion closure that will either return the opertionID of an injected operation, or an error.

Blockchain Operations

  • Get all the metadata necessary from the network to perform operations.

    Declaration

    Swift

    public func getOperationMetadata(forWalletAddress: String, completion: @escaping ((Result<OperationMetadata, KukaiError>) -> Void))

    Parameters

    forWallet

    The Wallet object that will be sending the operations.

    completion

    A callback that will be executed when the network requests finish.

  • Get the Michelson storage of a given contract from the blockchain.

    Declaration

    Swift

    public func getContractStorage(contractAddress: String, completion: @escaping ((Result<[String : Any], KukaiError>) -> Void))

    Parameters

    contractAddress

    The address of the contract to query.

    completion

    A callback with a Result object, with either a [String: Any] or an Error

  • Get the Michelson big map contents, from a given id

    Declaration

    Swift

    public func getBigMap(id: String, completion: @escaping ((Result<[String : Any], KukaiError>) -> Void))

    Parameters

    id

    The big map id.

    completion

    A callback with a Result object, with either a [String: Any] or an Error

  • Query the server for the NetworkVersion and NetworkConstants, and store the responses in the tezosNodeClient properties networkVersion and networkConstants, so they can be referred too by the application without having to constantly query t he server.

    Declaration

    Swift

    public func getNetworkInformation(completion: @escaping ((Bool, KukaiError?) -> Void))

    Parameters

    completion

    A callback with a Bool indicating success and an optional Error