Start an Auto-Signing Session for a Player with Session Keys


To learn more about the concept and design of Halliday session keys please read the Session Keys section of the Architecture + Concepts section.


Since this feature is in beta, please reach out to the Halliday team to get this enabled on your account either in your dedicated Slack, Telegram, or via email at [email protected].

By enabling your account, transactions will get forwarded to the pre-release version of the Halliday account that comes equipped with support for session keys!

This feature is currently in beta and must be enabled on your account. To install the beta version of the SDK:

npm install [email protected]


yarn add [email protected]

To start an auto-signing session, simply call .startSession() with the session length in seconds. After the session begins, all calls to transferAsset, transferBalance, callContract will use the newly generated session key and won't ask the user's non-custodial wallet to sign for the duration of the session. The maximum session length is one week.

const sessionLengthInSeconds = 2 * 60 * 60; // Two hours
await hallidayClient.startSession(sessionLengthInSeconds);

You can call .endSession() to end the session at anytime. Transactions will require signatures from the user's non-custodial wallet again.


You can also call .getSession() to see when the currently active session expires. It will return a Date object. If there is no active session, it will return null.

const expirationTime = hallidayClient.getSession();

Note: Session keys are stored in-memory and do not persist between reloads of the game, browser, etc.

Below is an example of a session key integration:

import {Halliday, BlockchainType} from "halliday-sdk";

// Initialize the Halliday client.
const hallidayClient = new Halliday(
    BlockchainType.DFK,     // Specifying blockchainType is optional - defaults to Mumbai
    true                    // This is an optional argument that makes the SDK interact with your testing environment

// Call logInWithGoogle, logInWithFacebook, logInWithTwitter to have the user log in.
// These will redirect the user to the corresponding website to log in. Once they log 
// in, they will be redirected back to your original page.

// Call getUserInfo() to see whether or not the user is logged in, either from
// being redirected back here or from not signing out from a previous session.
const userInfo = await hallidayClient.getUserInfo();

// Start the session.
const sessionLengthInSeconds = 2 * 60 * 60; // Two hours
await hallidayClient.startSession(sessionLengthInSeconds);

// Call an arbitrary contract.
const contractAddress = '0x1f6557356bfb310a556300a36fb18f54fb4791b1';
// The contract's ABI
const contractAbi = [...];                         // Replace with your contract's ABI
// Create an instance of the contract
const contract = new ethers.Contract(contractAddress, contractAbi, signer);
// Get the calldata for a contract call
const calldata = contract.interface.encodeFunctionData('someFunction', ['arg1', 'arg2']);

// Call the contract, with gas sponsored by the paymaster, and using the generated session key.
const contractCallTxInfo = await hallidayClient.callContract({
  from_in_game_player_id: userInGameId,            // Your user's id in your application
  target_address: contractAddress,
  value: "0",
  sponsor_gas: true,
console.log(contractCallTxInfo.status, contractCallTxInfo.on_chain_id);

// Later on, you can check whether the current session key is still active.
// If not, you can start a new session.
if (hallidayClient.getSession() === null) {
  await hallidayClient.startSession(sessionLengthInSeconds); 

// Continue transacting without requiring the user to approve every call!

// End the session.

What’s Next