Skip to main content

getCollection

A builder function that returns a collection containing a list of transaction IDs by its collection ID.

A collection is a batch of transactions that have been included in a block. Each collection has a unique ID which is the SHA3-256 hash of the collection payload. Collections are used to group related transactions together for more efficient processing by the network.

The collection ID provided must be from the current spork. Collections from past sporks are currently unavailable.

Import

You can import the entire package and access the function:


_10
import * as sdk from '@onflow/sdk';
_10
_10
sdk.getCollection(id);

Or import directly the specific function:


_10
import { getCollection } from '@onflow/sdk';
_10
_10
getCollection(id);

Usage


_22
import * as fcl from '@onflow/fcl';
_22
_22
// Get a collection and see what transactions it contains
_22
const collection = await fcl
_22
.send([
_22
fcl.getCollection(
_22
'cccdb0c67d015dc7f6444e8f62a3244ed650215ed66b90603006c70c5ef1f6e5',
_22
),
_22
])
_22
.then(fcl.decode);
_22
_22
console.log('Collection ID:', collection.id);
_22
console.log('Transaction IDs:', collection.transactionIds);
_22
console.log('Total transactions:', collection.transactionIds.length);
_22
_22
// Process each transaction in the collection
_22
for (const txId of collection.transactionIds) {
_22
const transaction = await fcl
_22
.send([fcl.getTransaction(txId)])
_22
.then(fcl.decode);
_22
console.log('Transaction:', transaction);
_22
}

Parameters

id (optional)

  • Type: string

Returns


_10
export type InteractionBuilderFn = (
_10
ix: Interaction,
_10
) => Interaction | Promise<Interaction>;

A function that processes an interaction object


Rate this page