Class

FabricContractContext

FabricContractContext(argsopt) → {void}

Constructor

# 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

sequenceDiagram participant Contract participant Context participant Ledger Contract->>Context: new FabricContractContext() Contract->>Context: set('stub'|'clientIdentity'|'logger', ...) Context-->>Contract: timestamp, identity, logger Contract->>Ledger: Interact via stub
Parameters:
Name Type Attributes Description
args object <optional>

Optional initialization arguments passed to the base Context

View Source contracts/ContractContext.ts, line 3

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

View Source contracts/ContractContext.ts, line 62

# stub

Returns the ChaincodeStub instance for interacting with the ledger

Gets the chaincode stub

View Source contracts/ContractContext.ts, line 46

# timestamp

Overrides the base timestamp getter to use the stub's timestamp

Gets the transaction timestamp

View Source contracts/ContractContext.ts, line 54

Methods

# identity() → {ClientIdentity}

Returns the ClientIdentity instance for the transaction submitter

Gets the client identity

View Source contracts/ContractContext.ts, line 101

The client identity

ClientIdentity

# stub() → {ChaincodeStub}

Returns the ChaincodeStub instance for interacting with the ledger

Gets the chaincode stub

View Source contracts/ContractContext.ts, line 87

The chaincode stub

ChaincodeStub

# timestamp() → {Date}

Overrides the base timestamp getter to use the stub's timestamp

Gets the transaction timestamp

View Source contracts/ContractContext.ts, line 94

The transaction timestamp

Date