# new FabricContractContext(argsopt) → {void}
Provides access to Fabric-specific context elements like stub, identity, and logger to be used by repositories and adapters during contract execution.
Context class for Fabric chaincode operations
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
object
|
<optional> |
Optional initialization arguments passed to the base Context |
void
Example
```typescript
// In a Fabric chaincode contract method
const context = new FabricContractContext();
// Optionally set values via the base Context API
context.set('stub', ctx.stub);
context.set('clientIdentity', ctx.clientIdentity);
context.set('logger', contractLogger);
// Access context properties
const timestamp = context.timestamp;
const creator = context.identity.getID();
```
Classes
- FabricContractContext
Initializes the context with Fabric-specific flags
- FabricContractContext
Initializes the context with Fabric-specific flags
Members
# identity
Returns the ClientIdentity instance for the transaction submitter
Gets the client identity
# timestamp
Overrides the base timestamp getter to use the stub's timestamp
Gets the transaction timestamp
Methods
# getReadCollections() → {Array.<string>}
Returns collection names from segregateRead.
Gets the collections registered for reading
Array of collection names, empty if none registered
Array.<string>
# getWriteCollections() → {Array.<string>}
Returns collection names from segregateWrite, used by sequences to know where to replicate.
Gets the collections registered for writing
Array of collection names, empty if none registered
Array.<string>
# identity() → {ClientIdentity}
Returns the ClientIdentity instance for the transaction submitter
Gets the client identity
The client identity
ClientIdentity
# setSequenceSegregation(seqName, fullySegregated, collections) → {void}
Needed because the Sequence creates its own context (via logCtx), losing flags set by extractSegregatedCollections on the handler context. The adapter persists across operations, making it a reliable store.
Stores segregation metadata per sequence name
Parameters:
| Name | Type | Description |
|---|---|---|
seqName |
string
|
|
fullySegregated |
boolean
|
|
collections |
Array
|
void
# stub() → {ChaincodeStub}
Returns the ChaincodeStub instance for interacting with the ledger
Gets the chaincode stub
The chaincode stub
ChaincodeStub
# timestamp() → {Date}
Overrides the base timestamp getter to use the stub's timestamp
Gets the transaction timestamp
The transaction timestamp
Date