Aggregate Transaction

Warning

The configuration presented is NOT intended to be used on the public network. These are the parameters used for the Catapult Testnet version (MIJIN_TEST).

Aggregated Transactions merge multiple transactions into one, allowing trustless swaps, and other advanced logic. NEM does this by generating a one-time disposable smart contract. When all involved accounts have cosigned the aggregate transaction, all the inner transactions are executed at the same time.

Parameters

Aggregate transactions accept the following parameters:

Inner Transaction

Transactions initiated by different accounts. An aggregate transaction can contain up to 1000 inner transactions involving up to 15 different cosignatories. Other aggregate transactions are not allowed as inner transactions.

Cosignatures

An array of transaction cosignatures.

Aggregate complete

An aggregate transaction is complete when all cosigners have signed it.

The different participants can sign without using the blockchain the aggregate transaction. Once it has all the required signatures, one of them can announce it to the network. If the inner transaction setup is valid, and there is no validation error, the transactions will get executed at the same time.

Aggregate complete transactions enable adding more transactions per block by gathering multiple inner transactions between different participants in the same operation.

Example

Dan announces an aggregate transaction that merges two transfer transactions. As he is the only required signed, we say the aggregate transaction it is complete. After announcing it to the network, Alice and Bob will receive the mosaics at the same time.

../_images/guides-transactions-sending-payouts.png

Sending payouts with aggregate complete transactions

Aggregate bonded

An aggregate transaction is bonded when it requires signatures from other participants.

Note

When sending an aggregate bonded transaction, an account must first announce and get confirmed a Lock Funds Transaction for this aggregate with at least 10 XEM.

Once an aggregate bonded is announced, it reaches partial state and notifies its status through WebSockets or HTTP API calls.

Every time a cosignatory signs the transaction and announces an aggregate bonded cosignature, the network checks if all the required cosigners have already signed. In this situation, the transaction changes to unconfirmed state until the network accepts it, and it is included in a block once processed.

../_images/aggregate-bonded-transaction-cycle.png

Aggregate bonded transaction cycle

Examples

  1. In this example, Alice is buying tickets with currency:euro. When the ticket distributor cosigns the aggregate transaction, the swap will happen atomically.
../_images/guides-transactions-escrow.png

Multi-Asset Escrowed Transactions

  1. Alice sends 10 € to Bob using a payment app. But she doesn’t have any XEM to pay the blockchain transaction fee. By creating an aggregate bonded transaction, she can convert USD to XEM to pay the fee. Now Alice and Bob can use NEM blockchain without ever having to buy or hold XEM. Since the app creator can put their own branding on the open source payment app, Alice and Bob may not even know they are using blockchain.
../_images/guides-transactions-paying-for-others-fees.png

Paying for others fees

Cosignature transaction

Cosignature transactions are used to sign announced aggregate bonded transactions with missing cosignatures.

Transaction to cosign

Aggregate bonded transaction to cosign.

Lock funds transaction

Announce a lock funds transaction before sending a signed aggregate bonded transaction. This mechanism is required to prevent network spamming.

Once the related aggregate bonded transaction is confirmed, locked funds become available again in the account that signed the initial lock funds transaction.

If the aggregate bonded transaction duration is reached without being signed by all cosignatories, the locked amount is collected by the block harvester at the height where the lock expires.

Mosaic

Locked mosaic, must be at least 10 nem:xem.

Duration

The funds lock duration.

Hash

Aggregate bonded has to be confirmed before unlocking funds.