TzKTClient

public class TzKTClient
extension TzKTClient: HubConnectionDelegate

TzKT is an indexer for Tezos, who’s API allows developers to query details about wallets, transactions, bakers, account status etc

  • Unique Errors that TzKTClient can throw

    See more

    Declaration

    Swift

    public enum TzKTServiceError : Error
  • Constants needed for interacting with the API

    See more

    Declaration

    Swift

    public struct Constants
  • Is currently monitoring an address for update notifications

    Declaration

    Swift

    public var isListening: Bool
  • Notifications of monitored addresses that have changed

    Declaration

    Swift

    @Published
    public var accountDidChange: [String] { get set }

Init

Storage

  • Get the storage of a given contract and parse it to a supplied model type

    Declaration

    Swift

    public func getStorage<T>(forContract contract: String, ofType: T.Type, completion: @escaping ((Result<T, KukaiError>) -> Void)) where T : Decodable, T : Encodable

    Parameters

    forContract

    The KT1 contract address to query

    ofType

    The Codable compliant model to parse the response as

    completion

    A completion block called, returning a Swift Result type

  • Get the keys of a big map, by ID and parse it to a model

    Declaration

    Swift

    public func getBigMap<T>(forId id: String, ofType: T.Type, completion: @escaping ((Result<T, KukaiError>) -> Void)) where T : Decodable, T : Encodable

    Parameters

    forId

    The numeric ID of the big map

    ofType

    The Codable compliant model to parse the response as

    completion

    A completion block called, returning a Swift Result type

  • Get the keys of a big map, but filtered to only one specific key. Parse the response as the supplied model

    Declaration

    Swift

    public func getBigMapKey<T>(forId id: String, key: String, ofType: T.Type, completion: @escaping ((Result<T, KukaiError>) -> Void)) where T : Decodable, T : Encodable

    Parameters

    forId

    The numeric ID of the big map

    key

    The key to filter by

    ofType

    The Codable compliant model to parse the response as

    completion

    A completion block called, returning a Swift Result type

Search

Baking and Rewards

Network

Block checker

  • Query details about the given operation

    Declaration

    Swift

    public func getOperation(byHash hash: String, completion: @escaping (([TzKTOperation]?, KukaiError?) -> Void))

    Parameters

    byHash

    The operation hash to query.

    completion

    A completion colsure called when the request is done.

Account monitoring

Balances

  • Get the count of tokens the given address has balances for (excluding zero balances)

    Declaration

    Swift

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

    Parameters

    forAddress

    The tz address to search for

    completion

    The completion block called with a Result containing the number or an error

  • Tokens balances and metadata need to be fetch from a paginated API. THis function calls a sinlerequest or 1 page of balances / metadata

    Declaration

    Swift

    public func getBalancePage(forAddress: String, offset: Int = 0, completion: @escaping ((Result<[TzKTBalance], KukaiError>) -> Void))

    Parameters

    forAddress

    The tz address to search for

    offset

    The starting position

    completion

    The completion block called with a Result containing an array of balances or an error

  • Get the account object from TzKT caontaining information about the address, its balance and baker

    Declaration

    Swift

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

    Parameters

    forAddress

    The tz address to search for

    completion

    The completion block called with a Result containing an object or an error

  • Get all balances from one function call, by fetching the result from getBalanceCount and using that to decide how many pages should be called

    Declaration

    Swift

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

    Parameters

    forAddress

    The tz address to search for

    completion

    The completion block called with a Result containing an object or an error

  • In order to access the cached images, you need the URL it was downloaded from. This can either be found inside the Token objects returned as part of Account from the fetchAccountInfo func. Or, if you need to use it seperately, given the token address you can use this function

    Declaration

    Swift

    public static func avatarURL(forToken token: String) -> URL?

    Parameters

    forToken

    The token address who’s image you are looking for.

Transaction History