TransactionWatcher

public class TransactionWatcher

A class that allows you to watch a transaction for events and block confirmations.

firstly {
  web3.sendTransaction(transaction: transaction)
}.done { transactionHash in
  let watcher = TransactionWatcher(hash: transactionHash, web3: web3)
  watcher.expectedConfirmations = 3
  watcher.delegate = self
  self.transactionWatcher = watcher
}
  • Called when the transaction’s status changes

    Declaration

    Swift

    public static let StatusDidChangeNotification: Notification.Name
  • Called when the TransactionWatcher receives an event

    Declaration

    Swift

    public static let DidReceiveEvent: Notification.Name
  • The user info key for the received event

    Declaration

    Swift

    public static let MatchedEventKey: String
  • Represents various states of a transaction

    See more

    Declaration

    Swift

    public enum Status : Equatable
  • The transaction hash, received from submitting the transaction

    Declaration

    Swift

    public let transactionHash: EthereumData
  • The receipt object of the transaction

    Declaration

    Swift

    private(set) public var transactionReceipt: EthereumTransactionReceiptObject? {
      get
      }
  • Status of this transaction

    Declaration

    Swift

    private(set) public var status: TransactionWatcher.Status { get set }
  • Block number the transaction was initially confirmed in

    Declaration

    Swift

    private(set) public var blockNumber: EthereumQuantity? {
      get
      }
  • Latest block number we’ve received

    Declaration

    Swift

    private(set) public var currentBlock: EthereumQuantity? {
      get
      }
  • Number of confirmations to require before marking as successful. Generally 3 is enough for low value transactions while 6 should be enough for higher values. The TransactionWatcher will automatically stop once the limit is reached.

    Declaration

    Swift

    public var expectedConfirmations: Int
  • How often to check for new blocks

    Declaration

    Swift

    public var pollInterval: TimeInterval
  • Class to receive updates

    Declaration

    Swift

    public weak var delegate: TransactionWatcherDelegate?
  • Events that we are expecting may be returned

    Declaration

    Swift

    private(set) public var watchedEvents: Set<SolidityEvent> {
      get
      }
  • Initializes a new instance of TransactionWatcher

    Declaration

    Swift

    public init(transactionHash: EthereumData, web3: Web3)

    Parameters

    transactionHash

    the hash of the transaction to watch (returned from sendTransaction())

    web3

    the Web3 instance to use

  • Stops watching the transaction

    Declaration

    Swift

    public func stop()
  • Watches for a provided event from the receipt’s logs

    Declaration

    Swift

    public func startWatching(for event: SolidityEvent)

    Parameters

    event

    ABIEvent to watch for

  • Stops watching for a provided event

    Declaration

    Swift

    public func stopWatching(event: SolidityEvent)

    Parameters

    event

    ABIEvent to stop watching