Class: Transaction

fabric-network. Transaction

Represents a specific invocation of a transaction function, and provides flexibility 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()

Transaction instances should be obtained only by calling Contract.createTransaction(). This constructor should not be used directly.

Methods


<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
Promise.<Buffer>

getName()

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

getTransactionId()

Get the ID that will be used for this transaction invocation.
Returns:
A transaction ID.
Type
string

serialize()

Extract the state of this transaction in a form that can be reconstructed using Contract#deserializeTransaction(). This allows a transaction to persisted, and then reconstructed and resubmitted following a client application restart. There is no guarantee of compatibility for the serialized data between different versions of this package.
Returns:
A serialized transaction.
Type
Buffer

setEndorsingOrganizations(orgs)

Set the organizations that should be used for endorsement when this transaction is submitted to the ledger. Peers that are in the organizations will be used for the endorsement. This will override the setEndorsingPeers if previously called. Setting the endorsing organizations will not override discovery, however it will filter the peers provided by discovery to be those in these organizatons.
Parameters:
Name Type Argument Description
orgs Array.<string> <repeatable>
Endorsing organizations.
Returns:
This object, to allow function chaining.
Type
module:fabric-network.Transaction

setEndorsingPeers(peers)

Set the peers that should be used for endorsement when this transaction is submitted to the ledger. Setting the peers will override the use of discovery and the submit will send the proposal to these peers. This will override the setEndorsingOrganizations if previously called.
Parameters:
Name Type Description
peers Array.<Endorser> Endorsing peers.
Returns:
This object, to allow function chaining.
Type
module:fabric-network.Transaction

setEventHandler(strategy)

Set an event handling strategy to use for this transaction instead of the default configured on the gateway.
Parameters:
Name Type Description
strategy An event handling strategy.
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:
Returns:
Payload response from the transaction function.
Type
Buffer