Transaction manager
The transactionManager
service is used to track a transaction's status as it propagates through the blockchain.
Methods in Dai.js that start transactions are asynchronous, so they return promises. These promises can be passed as arguments to the transaction manager to set up callbacks when transactions change their status to pending
, mined
, confirmed
or error
.
Pass the promise to transactionManager.listen
with callbacks, as shown below.
Note that the confirmed
event will not fire unless transactionManager.confirm
is called. This async function waits a number of blocks (default 5) after the transaction has been mined to resolve. To change this globally, set the confirmedBlockCount
attribute in Maker options. To change it for just one call, pass the number of blocks to wait as the second argument:
Transaction Metadata
There are functions such as lockEth()
which are composed of several internal transactions. These can be more accurately tracked by accessing tx.metadata
in the callback which contains both the contract
and the method
the internal transactions were created from.
Transaction Object Methods
A TransactionObject
also has a few methods to provide further details on the transaction:
hash
: transaction hashfees()
: amount of ether spent on gastimeStamp()
: timestamp of when transaction was minedtimeStampSubmitted()
: timestamp of when transaction was submitted to the network
Last updated