createExplicitSession
This is the main function you’ll use to build your smart session. It takes a single options object and bundles everything into the final format required by the wallet.
Example
Params
chainId
The chain ID of a Sequence supported chain where the session’s permissions will be valid.
See Supported Chains.
nativeTokenSpending
This object controls the session’s access to the user’s native currency.
valueLimit
: The maximum cumulative amount of the native currency (in wei) that can be spent across all contract calls and fees during the session.allowedRecipients
: Allows direct native transfers to these addresses.
expiresIn
An object to define the session’s expiry.
days
: The number of days the session will be valid.hours
: The number of hours the session will be valid.minutes
: The number of minutes the session will be valid.
permissions
An array of permission objects.
target
: The address of the contract to interact with.rules
: An array of rules for thetarget
address.
target
smart contract can have a set of rules.
cumulative
: Whether the rule is cumulativeoperation
: The operation to perform on thevalue
.value
: The expected value (stored as a bytes32) used for comparison.offset
: The byte offset in the call data from which the 32-byte parameter is extracted.mask
: A bitmask applied to the extracted data. This isolates the relevant bits, allowing validation even when the field is embedded within a larger data structure.
Return type
Returns anExplicitParams
object.
createContractPermission
This helper function is used to create a permission for a smart contract function.
Example
Params
address
The address of the target contract.
functionSignature
The human-readable function signature.
rules
An array of rules to apply to the function’s arguments.
onlyOnce
If true, this function can only be successfully called once during the session.
Return type
Returns a Permission.createContractPermissions
Same as createContractPermission
, but it creates multiple permissions for the same contract.
Example
Params
Very similar to CreateContractPermission, but it uses an array offunctions
.
Return type
Returns aPermission[]
.