Iota

public class Iota: IotaDebuggable

Iota Class Instance.

  • Spam address used for promote.

    Declaration

    Swift

    public static let spamTransfer = IotaTransfer(address: "".rightPadded(count: 81, character: "9"))
  • Spam Seed used for promote.

    Declaration

    Swift

    public static let spamSeed = "".rightPadded(count: 81, character: "9")
  • Address of the host.

    Declaration

    Swift

    public fileprivate(set) var address: String = ""
  • Debug variable, setting it to true, will enable the debug logging. Default false.

    Declaration

    Swift

    public var debug = false
  • Local PoW instance, setting it to nil will delegate the PoW to the node.

    Declaration

    Swift

    public var localPoW: IotaLocalPoW? = CPearlDiver()
  • Initializer for Iota class with automatic node selection.

    Declaration

    Swift

    public init(prefersHTTPS: Bool = false, _ onReady: @escaping (Iota?) -> Void)

    Parameters

    prefersHTTPS

    Setting it to true, HTTPS nodes will be preferred.

    onReady

    On ready block.

  • Initializer for Iota class.

    Declaration

    Swift

    public init(node: String, port: UInt)

    Parameters

    node

    Node address without port.

    port

    Port for the specified node address

  • Initializer for Iota class

    Declaration

    Swift

    public init(node: String)

    Parameters

    node

    Full node address Ex:http://localhost:14700

  • Returns information about the connected node.

    Declaration

    Swift

    public func nodeInfo(_ success: @escaping ([String: Any]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    success

    Success block.

    error

    Error block.

  • Returns the confirmed balance of the requested addresses.

    Declaration

    Swift

    public func balances(addresses: [String], _ success: @escaping (_ balances: [String: Int64]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    addresses

    List of addresses.

    success

    Success block.

    error

    Error block.

  • Find the transactions which match the specified addresses.

    Declaration

    Swift

    public func findTransactions(addresses: [String], _ success: @escaping (_ hashes: [String]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    addresses

    List of addresses.

    success

    Success block.

    error

    Error block.

  • Find the transactions which match the specified bundles.

    Declaration

    Swift

    public func findTransactions(bundles: [String], _ success: @escaping (_ hashes: [String]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    bundles

    List of bundles.

    success

    Success block.

    error

    Error block.

  • Returns the raw transaction data (trytes) of a specific transaction. These trytes can then be easily converted into the actual transaction object. See IotaTransaction.

    Declaration

    Swift

    public func trytes(hashes: [String], _ success: @escaping (_ trytes: [IotaTransaction]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    hashes

    List of transaction hashes.

    success

    Success block.

    error

    Error block.

  • returns the addresses, transfers, inputs and balance that are associated and have been used with your account (seed). This function is useful in getting all the relevant information of your account.

    Declaration

    Swift

    public func accountData(seed: String, minimumNumberOfAddresses: Int = 0, security: Int = 2, requestTransactions: Bool = false, _ success: @escaping (_ account: IotaAccount) -> Void, error: @escaping (Error) -> Void, log: ((_ log: IotaLog) -> Void)? = nil)

    Parameters

    seed

    The Seed.

    minimumNumberOfAddresses

    The minimum number of addresses associated to the seed, setting it to true will be useful in order to speed up the process, by requesting all the addresses balance and transactions in batch.

    security

    The security level (1-3).

    requestTransactions

    Setting it to true, all the transactions associated to the addresses will be requested and returned. If you don’t need it, set it to false.

    success

    Success block.

    error

    Error block.

    log

    Log block.

  • Attaches the specified address to the Tangle by doing Proof of Work.

    Declaration

    Swift

    public func attachToTangle(seed: String, index: Int, security: Int = 2, _ success: @escaping (_ transfer: IotaTransaction) -> Void, error: @escaping (Error) -> Void)

    Parameters

    seed

    The Seed.

    index

    The index of the address.

    security

    The security level.

    success

    Success block.

    error

    Error block.

  • Wrapper function that basically does prepareTransfers, as well as attachToTangle and finally, it broadcasts and stores the transactions locally.

    Declaration

    Swift

    public func sendTransfers(seed: String, security: Int = 2, depth: Int = 10, minWeightMagnitude: Int = IotaConstants.mwm, transfers: [IotaTransfer], inputs: [IotaInput]?, remainderAddress: String?, reference: String? = nil, _ success: @escaping (_ transactions: [IotaTransaction]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    seed

    The Seed.

    security

    The security level.

    depth

    Number of bundles to go back to determine the transactions for approval, leave it as default.

    minWeightMagnitude

    Minimum weight magnitude, leave it as default.

    transfers

    List of IotaTransfers.

    inputs

    List of IotaInputs, by setting it to null, the proper inputs will be taken automatically.

    remainderAddress

    The remainder address, by setting it to null, a new address will be generated and used as remainder.

    reference

    Hash of transaction to start random-walk from, used to make sure the tips returned reference a given transaction in their past, leave it as default.

    success

    Success block.

    error

    Error block.

  • Takes a tail transaction hash as input, gets the bundle associated with the transaction and then replays the bundle by attaching it to the tangle.

    Declaration

    Swift

    public func replayBundle(tx: String, depth: Int = 10, minWeightMagnitude: Int = IotaConstants.mwm, _ success: @escaping (_ transactions: [IotaTransaction]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    tx

    Transaction hash, has to be tail.

    depth

    Number of bundles to go back to determine the transactions for approval, leave it as default.

    minWeightMagnitude

    Minimum weight magnitude, leave it as default.

    success

    Success block.

    error

    Error block.

  • Returns the bundle with the specified where the specified tx hash belongs to.

    Declaration

    Swift

    public func bundle(tx: String, _ success: @escaping (_ transactions: [IotaTransaction]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    tx

    The transaction hash, has to be the tail.

    success

    Success block.

    error

    Error block.

  • Returns all the transactions associated to the specified address.

    Declaration

    Swift

    public func transactionsFromAddress(address: String, _ success: @escaping (_ transactions: [IotaTransaction]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    address

    The address hash.

    success

    Success block.

    error

    Error block.

  • Returns the tail transaction from a transaction.

    Declaration

    Swift

    public func tailFromTransaction(tx: IotaTransaction, _ success: @escaping (_ tail: IotaTransaction) -> Void, error: @escaping (Error) -> Void)

    Parameters

    tx

    The requested tail transaction.

    success

    Success block.

    error

    Error block.

  • Returns an IotaAddress instance, filled with all the transactions.

    Declaration

    Swift

    public func addressFromHash(address: String, _ success: @escaping (_ transactions: IotaAddress) -> Void, error: @escaping (Error) -> Void)

    Parameters

    address

    The address hash.

    success

    Success block.

    error

    Error block.

  • Get the inclusion states of a set of transactions. This is for determining if a transaction was accepted and confirmed by the network or not.

    Declaration

    Swift

    public func latestInclusionStates(hashes: [String], _ success: @escaping (([Bool]) -> Void), _ error: @escaping (Error) -> Void)

    Parameters

    hashes

    List of transactions hashes you want to get the inclusion state for.

    success

    Success block.

    error

    Error block.

  • Check if a list of addresses was ever spent from, in the current epoch, or in previous epochs.

    Declaration

    Swift

    public func wereAddressesSpentFrom(addresses: [String], _ success: @escaping (([Bool]) -> Void), _ error: @escaping (Error) -> Void)

    Parameters

    addresses

    List of addresses to check if they were ever spent from.

    success

    Success block.

    error

    Error block.

  • Checks if a bundle is promotable by checking the tx tail of the bundle.

    Declaration

    Swift

    public func isPromotable(tail: String, _ success: @escaping ((Bool) -> Void), _ error: @escaping (Error) -> Void)

    Parameters

    tail

    The tail transaction hash.

    success

    Success block.

    error

    Error block.

  • Promotes a transaction by spamming the network (convenience method).

    Declaration

    Swift

    public func promoteTransaction(hash: String, transactions: [IotaTransfer] = [Iota.spamTransfer], depth: Int = 10, minWeightMagnitude: Int = IotaConstants.mwm, delayInSeconds: UInt = 0, numberOfPromotes: Int = 4, _ success: @escaping (_ tail: String) -> Void, error: @escaping (Error) -> Void)

    Parameters

    hash

    Transaction hash, has to be tail.

    transactions

    List of transfers.

    depth

    Number of bundles to go back to determine the transactions for approval, leave it as default.

    minWeightMagnitude

    Minimum weight magnitude, leave it as default.

    delayInSeconds

    Delay in seconds between spams.

    numberOfPromotes

    Number of spams to add on top of the transaction (default 4).

    success

    Success block.

    error

    Error block.

  • Promotes a transaction by spamming the network.

    Declaration

    Swift

    public func promoteTransaction(_ tx: IotaTransaction, transactions: [IotaTransfer] = [Iota.spamTransfer], depth: Int = 10, minWeightMagnitude: Int = IotaConstants.mwm, delayInSeconds: UInt = 0, numberOfPromotes: Int = 4, _ success: @escaping (_ tail: String) -> Void, error: @escaping (Error) -> Void)

    Parameters

    tx

    The transaction.

    transactions

    List of transfers.

    depth

    Number of bundles to go back to determine the transactions for approval, leave it as default.

    minWeightMagnitude

    Minimum weight magnitude, leave it as default.

    delayInSeconds

    Delay in seconds between spams.

    numberOfPromotes

    Number of spams to add on top of the transaction (default 4).

    success

    Success block.

    error

    Error block.

  • Promotes a transaction by spamming the network (convenience method).

    Declaration

    Swift

    public func promote(tail: String, transactions: [IotaTransfer] = [Iota.spamTransfer], depth: Int = 10, minWeightMagnitude: Int = IotaConstants.mwm, delayInSeconds: UInt = 0, numberOfPromotes: Int = 4, _ success: @escaping (_ tail: String) -> Void, error: @escaping (Error) -> Void)

    Parameters

    tail

    The tail transaction hash.

    transactions

    List of transfers.

    depth

    Number of bundles to go back to determine. the transactions for approval, leave it as default.

    minWeightMagnitude

    Minimum weight magnitude, leave it as default.

    delayInSeconds

    Delay in seconds between spams.

    numberOfPromotes

    Number of spams to add on top of the transaction (default 4).

    success

    Success block.

    error

    Error block.

  • Wrapper function that does attachToTangle and finally, it broadcasts and stores the transactions.

    Declaration

    Swift

    public func sendTrytes(trytes: [String], depth: Int = 10, minWeightMagnitude: Int = IotaConstants.mwm, reference: String? = nil, _ success: @escaping (_ transactions: [IotaTransaction]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    trytes

    List of trytes.

    depth

    Number of bundles to go back to determine the transactions for approval, leave it as default.

    minWeightMagnitude

    Minimum weight magnitude, leave it as default.

    reference

    Hash of transaction to start random-walk from, used to make sure the tips returned reference a given transaction in their past, leave it as default.

    success

    Success block.

    error

    Error block.

  • Attaches the specified address to the Tangle by doing Proof of Work.

    Declaration

    Swift

    public func attachToTangle(trunkTx: String, branchTx: String, minWeightMagnitude: Int, trytes: [String], _ success: @escaping (_ trytes: [String]) -> Void, error: @escaping (Error) -> Void)

    Parameters

    trunkTx

    The trunk transaction.

    branchTx

    The branch transaction.

    minWeightMagnitude

    The Minimum Weight Magnitude.

    trytes

    An Array of Trytes.

    success

    The success block.

    error

    The error block.