Meta-transactions (outside execution) allows external contracts to execute transactions from outside an account contract, thereby opening up new use-cases such as sponsored transactions, deploying an account on behalf of a user, transaction scheduling (limit orders) etc.
Get outside execution call
To retrieve the data needed to perform an execute_from_outside:
sessionRequest , accountSessionSignature and the account address are needed
import ArgentSessionService and SessionDappService from @argent/x-sessions .
The first is required to instantiate SessionDappService
SessionDappService expose the method getOutsideExecutionCall
consttransferCallData=erc20Contract.populate("transfer", { recipient: address, amount:parseInputAmountToUint256(amount),});constbeService=newArgentSessionService(dappKey.publicKey, accountSessionSignature,ARGENT_SESSION_SERVICE_BASE_URL// Do not share publicly);constsessionDappService=newSessionDappService(beService,awaitprovider.getChainId(), dappKey);const { contractAddress,entrypoint,calldata } =awaitsessionDappService.getOutsideExecutionCall( sessionRequest,stark.formatSignature(accountSessionSignature),false,// keep false, will be a feat for caching [transferCallData], address, chainId,shortString.encodeShortString("ANY_CALLER"),// Optional: default value ANY_CALLER execute_after, // Optional: timestamp in seconds - this is the lower value in the range. Default value: 5 mins before Date.now()
execute_before, // Optional: timestamp in seconds - this is the upper value in the range. Default value: 20 mins after Date.now()
nonce: BigNumberish,// Optional: nonce, default value is a random nonce);
The result can be executed by another account or at backend level
Get outside execution TypedData
To retrieve the TypedData for an outside execution along with the compiled signature (session + guardian).
sessionRequest , accountSessionSignature and the account address are needed
import ArgentSessionService and SessionDappService from @argent/x-sessions .
The first is required to instantiate SessionDappService
SessionDappService expose the method getOutsideExecutionTypedData
it takes the same parameters as getOutsideExecutionCall
If needed, @argent/x-sessions provides the sessionBackenService to directly call the argent backend for signing a session or signing a session for en execution from outside