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.
-
The configuration object containing all the necessary settings to connect and communicate with the Tezos node
Declaration
Swift
public let config: TezosNodeClientConfig -
The
NetworkServiceobject that will perform all the networking callsDeclaration
Swift
public var networkService: NetworkService -
The
OperationServiceobject that will perform forging, parsing, signing, preapply and injections of operationsDeclaration
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 populateDeclaration
Swift
public var networkVersion: NetworkVersion? -
Available information about the constants of the network, that the conected server is running. Call
tezosNodeClient.fetchNetworkInformation(...)to populateDeclaration
Swift
public var networkConstants: NetworkConstants? -
Types of errors
See moreDeclaration
Swift
public enum TezosNodeClientError : Error
-
Init a
TezosNodeClientwith aTezosNodeClientConfig.Declaration
Swift
public init(config: TezosNodeClientConfig = TezosNodeClientConfig(withDefaultsForNetworkType: .mainnet))Parameters
configA configuration object containing all the necessary settings to connect and communicate with the Tezos node.
-
Gets the xtz balance for a given Address.
Declaration
Swift
public func getBalance(forAddress address: String, completion: @escaping ((Result<XTZAmount, KukaiError>) -> Void))Parameters
forAddressA Tezos network address, starting with
"tz1","tz2","tz3"or"kt1"completionA callback containing a new
Tokenobject matching the xtz standard, or an error. -
Gets the staked xtz balance for a given Address.
Declaration
Swift
public func getStakedBalance(forAddress address: String, completion: @escaping ((Result<XTZAmount, KukaiError>) -> Void))Parameters
forAddressA Tezos network address, starting with
"tz1","tz2","tz3"or"kt1"completionA callback containing a new
Tokenobject matching the xtz standard, or an error. -
Gets the unstaked xtz balance for a given Address.
Declaration
Swift
public func getUnstakedBalance(forAddress address: String, completion: @escaping ((Result<XTZAmount, KukaiError>) -> Void))Parameters
forAddressA Tezos network address, starting with
"tz1","tz2","tz3"or"kt1"completionA callback containing a new
Tokenobject matching the xtz standard, or an error. -
Gets the finalisable xtz balance for a given Address.
Declaration
Swift
public func getFinalisableBalance(forAddress address: String, completion: @escaping ((Result<XTZAmount, KukaiError>) -> Void))Parameters
forAddressA Tezos network address, starting with
"tz1","tz2","tz3"or"kt1"completionA callback containing a new
Tokenobject matching the xtz standard, or an error. -
Gets the XTZ, staked, unstaked and finalisable balance for a give address.
Declaration
Swift
public func getAllBalances(forAddress address: String, completion: @escaping ((Result<(balance: XTZAmount, staked: XTZAmount, unstaked: XTZAmount, finalisable: XTZAmount), KukaiError>) -> Void))Parameters
forAddressA Tezos network address, starting with
"tz1","tz2","tz3"or"kt1"completionA callback containing
(balance: XTZAmount, staked: XTZAmount, unstaked: XTZAmount, finalisable: XTZAmount)
-
Gets the delegate for the given address.
Declaration
Swift
public func getDelegate(forAddress address: String, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
forAddressA Tezos network address, starting with
"tz1","tz2","tz3"or"kt1"completionA callback containing a String with the delegate/baker’s address, or an error.
-
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, isRemote: Bool, completion: @escaping ((Result<FeeEstimatorService.EstimationResult, KukaiError>) -> Void))
-
Send an array of
Operation‘s to the blockchain. UseOperationFactoryto help create this array for common use cases.Declaration
Swift
public func send(operations: [Operation], withWallet wallet: Wallet, completion: @escaping ((Result<String, KukaiError>) -> Void)) -
Send an already contrsutructed
OperationPayloadwith the necessaryOperationMetadatawithout having to fetch metadata again.Declaration
Swift
public func send(operationPayload: OperationPayload, operationMetadata: OperationMetadata, withWallet wallet: Wallet, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
operationPayloadAn
OperationPayloadthat has already been constructed (e.g. from the estimation call).operationMetadataAn
OperationMetaDataobject containing all the info about the network that the call needs for forge -> inject.withWalletThe
Walletinstance that will sign the transactions.completionA completion closure that will either return the opertionID of an injected operation, or an error.
-
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
forWalletThe
Walletobject that will be sending the operations.completionA 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
contractAddressThe address of the contract to query.
completionA callback with a
Resultobject, with either a[String: Any]or anError -
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
idThe big map id.
completionA callback with a
Resultobject, with either a[String: Any]or anError -
Get the address of the CPMM contract and the 2 tokens (tzBTC and SIRS) that it manages
Declaration
Swift
public func getLiquidityBakingAddresses(completion: @escaping ((Result<(cpmm: String, tzbtc: String, sirs: String), KukaiError>) -> Void))Parameters
completionA callback with a
Resultobject, with either a(cpmm: String, tzbtc: String, sirs: String)or anError -
Query the server for the
NetworkVersionandNetworkConstants, and store the responses in the tezosNodeClient propertiesnetworkVersionandnetworkConstants, 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
completionA callback with a
Boolindicating success and an optionalError
Install in Dash