CreateSessionKey

For Smart Wallets only, grants restricted Smart Wallet access to a signer.

Extremely useful in many situations, see the Smart Wallets documentation for more information.

Usage

See Prefab_SmartWallet.cs for a full example.

try
{
// Create session key granting restricted smart wallet access to the local wallet for 1 day
var contractsAllowedForInteraction = new List<string>() { "0x450b943729Ddba196Ab58b589Cea545551DF71CC" }; // contracts the local wallet is allowed to interact with
var permissionEndTimestamp = Utils.GetUnixTimeStampNow() + 86400; // 1 day from now
var result = await ThirdwebManager.Instance.SDK.Wallet.CreateSessionKey(
signerAddress: randomAddress,
approvedTargets: contractsAllowedForInteraction,
nativeTokenLimitPerTransactionInWei: "0",
permissionStartTimestamp: "0",
permissionEndTimestamp: permissionEndTimestamp.ToString(),
reqValidityStartTimestamp: "0",
reqValidityEndTimestamp: Utils.GetUnixTimeStampIn10Years().ToString()
);
Debugger.Instance.Log("[CreateSessionKey] Sucess", result.ToString());
}
catch (System.Exception e)
{
Debugger.Instance.Log("[CreateSessionKey] Error", e.Message);
}

Configuration

signerAddress

The address of the signer to add.

Must be a string.

approvedTargets

A list of contract addresses that the signer is approved to interact with.

Must be a List<string>.

nativeTokenLimitPerTransactionInWei

The maximum amount of native token that can be transferred in a single transaction.

Must be a string.

permissionStartTimestamp

The UNIX timestamp of when the signer's permissions start.

Must be a string.

permissionEndTimestamp

The UNIX timestamp of when the signer's permissions end.

Must be a string.

reqValidityStartTimestamp

The UNIX timestamp of when the signer's permissions request validity starts.

Must be a string.

reqValidityEndTimestamp

The UNIX timestamp of when the signer's permissions request validity ends.

Must be a string.

Return Value

Returns a TransactionResult object.