Session Keys - Alpha release

Our current implementation of the session keys allow you to create a signer that will be able to send transactions to whitelisted contract during a limited timeframe.

When you create a session key you'll need to indicate a targeted contract address linked and a time period during which the key will be valid.

You can then add or remove targeted destinations for that session key.

You can also modify the whitelisted addresses linked to a session key.

Add a Session Key

const txHash = await smartAccountClient.addSessionKey({
    // ACTIVATE RIGHT NOW
    validAfter:Date.now()
    // ONE YEAR
    validUntil: Date.now() + 1000 * 60 * 60 * 24 * 365,
    destinations: [TARGETED_CONTRACT_ADDRESS],
})

Send a transaction with a session key

const hash = await smartAccountClient.sendTransactionWithSessionKey({
    to: TARGETED_CONTRACT_ADDRESS,
    data: calldata,
});

Send batch transactions with a session key

const hash = await smartAccountClient.sendTransactionsWithSessionKey({
  transactions: [
    {
      to: TARGETED_CONTRACT_ADDRESS,
      data: calldata,
    },
    {
      to: TARGETED_CONTRACT_ADDRESS,
      data: calldata,
    },
  ],
});

Get Session Key Signer Address

const sessionKeySignerAddress = await smartAccountClient.getCurrentSessionSignerAddress({
    smartAccountAddress: ADDRESS    
})

Remove a Session Key

const txHash = await smartAccountClient.revokeSessionKey({
    sessionKey: SESSION_KEY_SIGNER_ADDRESS    
})

Add Whitelist destinations

const txHash = await smartAccountClient.addWhitelistDestination({
    sessionKey: SESSION_KEY_SIGNER_ADDRESS,
    destination: NEW_TARGET_ADDRESS;  
})

Remove Whitelist destinations

const txHash = await smartAccountClient.removeWhitelistDestination({
    sessionKey: SESSION_KEY_SIGNER_ADDRESS,
    destination: TARGET_ADDRESS_TO_DELETE;  
})

Last updated