Class: Transaction

fabric-network~ Transaction

Represents a specific invocation of a transaction function, and provides felxibility over how that transaction is invoked. Applications should obtain instances of this class by calling Contract#createTransaction().

Instances of this class are stateful. A new instance must be created for each transaction invocation.

new Transaction()

Methods


<async> addCommitListener(callback [, options] [, eventHub])

Create a commit event listener for this transaction.
Parameters:
Name Type Argument Description
callback function This callback will be triggered when a transaction commit event is emitted. It takes parameters of error, transactionId, transaction status and block number
options module:fabric-network.Network~ListenerOptions <optional>
Optional. Options on registrations allowing start and end block numbers.
eventHub ChannelEventHub <optional>
Optional. Used to override the event hub selection
Returns:
Type
module:fabric-network~CommitEventListener

<async> evaluate( [args])

Evaluate a transaction function and return its results. The transaction function will be evaluated on the endorsing peers but the responses will not be sent to the ordering service and hence will not be committed to the ledger. This is used for querying the world state.
Parameters:
Name Type Argument Description
args String <optional>
<repeatable>
Transaction function arguments.
Returns:
Payload response from the transaction function.
Type
Buffer

getName()

Get the fully qualified name of the transaction function.
Returns:
Transaction name.
Type
String

getNetwork()

Returns the network from the contract
Returns:
Type
module:fabric-network.Network

getTransactionID()

Get the ID that will be used for this transaction invocation.
Returns:
Transaction ID.
Type
module:fabric-client.TransactionID

setEndorsingPeers(peers)

Set the peers that should be used for endorsement when this transaction is submitted to the ledger.
Parameters:
Name Type Description
peers Array.<ChannelPeer> Endorsing peers.
Returns:
This object, to allow function chaining.
Type
module:fabric-network.Transaction

setTransient(transientMap)

Set transient data that will be passed to the transaction function but will not be stored on the ledger. This can be used to pass private data to a transaction function.
Parameters:
Name Type Description
transientMap Object Object with String property names and Buffer property values.
Returns:
This object, to allow function chaining.
Type
module:fabric-network.Transaction

<async> submit( [args])

Submit a transaction to the ledger. The transaction function name will be evaluated on the endorsing peers and then submitted to the ordering service for committing to the ledger.
Parameters:
Name Type Argument Description
args String <optional>
<repeatable>
Transaction function arguments.
Throws:
If the transaction was successfully submitted to the orderer but timed out before a commit event was received from peers.
Type
module:fabric-network.TimeoutError
Returns:
Payload response from the transaction function.
Type
Buffer