@ Override public Response invoke ( ChaincodeStub stub ) { try { // Extract the function and args from the transaction proposal String func = stub . getFunction ( ) ; List < String > params = stub . getParameters ( ) ; if ( func . equals ( "set" ) ) { // Return result as success payload return newSuccessResponse ( set ( stub , params ) ) ; } else if ( func . equals ( "get" ) ) { // Return result as success payload return newSuccessResponse ( get ( stub , params ) ) ; } return newErrorResponse ( "Invalid invoke function name. Expecting one of: [\"set\", \"get\"" ) ; } catch ( Throwable e ) { return newErrorResponse ( e . getMessage ( ) ) ; } }
Invoke is called per transaction on the chaincode . Each transaction is either a get or a set on the asset created by Init function . The Set method may create a new asset by specifying a new key - value pair .