As you can learn about here, Super Agreement calls (like stream creations) in Super App callbacks require the updating of a context bytes variable. That context is returned at the end of the callback.
Below, the newCtx is the context bytes variable that will be updated with each Super Agreement call.
// Example Super App CallbackfunctiononFlowCreated(ISuperToken superToken,address sender,bytescalldata ctx) internaloverridereturns (bytesmemory/*newCtx*/) { newCtx = ctx; // `newCtx` is context bytes variable for updating// ... callback logic}
So, to do CFA operations inside of Super App callbacks, you'll need to use the -WithCtx versions of each function. These calls all return the updated context (a bytes memory)
// We're assuming here that newCtx is what you've named the context bytes // object that will be updated throughout the callback and returned// Without user datatoken.createFlowWithCtx(address receiver,int96 flowRate,bytesmemory ctx // Pass in the context bytes variable for updating here) returns (bytesmemory);// these functions look very similar for updates and deletionstoken.updateFlowWithCtx(address receiver,int96 flowRate,bytesmemory ctx) returns (bytesmemory);token.deleteFlowWithCtx(address sender,address receiver,bytesmemory ctx) returns (bytesmemory);// ACL functions also need to be called with context if called in a callbackfunctioncreateFlowFromWithCtx(ISuperToken token,address sender,address receiver,int96 flowRate,bytesmemory ctx) internalreturns (bytesmemory newCtx)functionupdateFlowFromWithCtx(ISuperTokentoken,addresssender,addressreceiver,int96flowRate,bytesmemoryctx) internalreturns (bytesmemory newCtx)functiondeleteFlowWithCtx(ISuperTokentoken,addresssender,addressreceiver,bytesmemoryctx) internalreturns (bytesmemory newCtx)functionsetFlowPermissionsWithCtx(ISuperTokentoken,addressflowOperator,boolallowCreate,boolallowUpdate,boolallowDelete,int96flowRateAllowance,bytesmemoryctx) internalreturns (bytesmemory newCtx)functionsetMaxFlowPermissionsWithCtx(ISuperTokentoken,addressflowOperator,bytesmemoryctx) internalreturns (bytesmemory newCtx)functionrevokeFlowPermissionsWithCtx(ISuperTokentoken,addressflowOperator,bytesmemoryctx) internalreturns (bytesmemory newCtx)
Example - Here's the callback snippet continued showing the proper syntax
// Example Super App CallbackfunctionafterAgreementCreated(ISuperToken superToken,address agreementClass,bytes32,// _agreementId,bytescalldata /_agreementData/,bytescalldata,// _cbdata,bytescalldata ctx) externalreturns (bytesmemory newCtx) { newCtx = ctx; // `newCtx` is context bytes variable for updating// start a stream to another address//note that `token` is the asset you want to stream newCtx = token.createFlowWithCtx( [someReceiverAddress], [flow rate], newCtx // notice `newCtx` being passed in and updated here );}