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


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

Parameters

id (optional)

  • Type: string

Returns

InteractionBuilderFn


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


Rate this page