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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.getCollection(id)
Or import directly the specific function:
_10import { getCollection } from "@onflow/sdk"_10_10getCollection(id)
Usage
_18import * as fcl from "@onflow/fcl";_18_18// Get a collection and see what transactions it contains_18const collection = await fcl.send([_18 fcl.getCollection("cccdb0c67d015dc7f6444e8f62a3244ed650215ed66b90603006c70c5ef1f6e5")_18]).then(fcl.decode);_18_18console.log("Collection ID:", collection.id);_18console.log("Transaction IDs:", collection.transactionIds);_18console.log("Total transactions:", collection.transactionIds.length);_18_18// Process each transaction in the collection_18for (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
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>