Class: Context

Context

The Context class provides the transactional context per a transactional execution. This can be subclassed to provided additional functional behaviour to support smart contract execution. An example would be to provide additional help to map application object ids to world state composite keys. In the constructor, do not reference the stub or clientidentity functions.

new Context()

Example
class ScenarioContext extends Context{

	constructor(){
		super();
	}


	generateKey(){
		return this.stub.createCompositeKey('type',['keyvalue']);
	}

  }

Methods


setChaincodeStub(stub)

This sets the chaincode stub object with api to use for worldstate access. MUST NOT BE CALLED FROM SMART CONTRACT CODE
Parameters:
Name Type Description
stub ChaincodeStub chaincode stub instance

setClientIdentity(clientIdentity)

This sets the ClientIdentity object to use for information on the transaction invoking identity MUST NOT BE CALLED FROM SMART CONTRACT CODE
Parameters:
Name Type Description
clientIdentity ClientIdentity chaincode stub instance