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
NetworkService
object that will perform all the networking callsDeclaration
Swift
public var networkService: NetworkService
-
The
OperationService
object 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
TezosNodeClient
with aTezosNodeClientConfig
.Declaration
Swift
public init(config: TezosNodeClientConfig = TezosNodeClientConfig(withDefaultsForNetworkType: .mainnet))
Parameters
config
A 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
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.
-
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.
-
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))
-
Send an array of
Operation
‘s to the blockchain. UseOperationFactory
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))
-
Send an already contrsutructed
OperationPayload
with the necessaryOperationMetadata
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.
-
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 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
id
The big map id.
completion
A callback with a
Result
object, with either a[String: Any]
or anError
-
Query the server for the
NetworkVersion
andNetworkConstants
, and store the responses in the tezosNodeClient propertiesnetworkVersion
andnetworkConstants
, 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 optionalError