Argent
  • Build with Argent
  • Argent Wallets
    • Argent X
      • Adding Custom RPCs
      • Network Switcher for Dapps
      • Verify signature of undeployed account
      • WalletAccount
    • Argent Mobile
      • Argent Mobile for your web app
      • Argent Mobile for your react native app
    • Web Wallet
      • Set up guide
      • Web Wallet UX
      • API reference
      • Key Management
    • Argent Multisig
      • How multisig works
      • Create a multisig
        • With Argent signer
        • With Ledger signer
      • Join a multisig
        • With Argent signer
        • With Ledger signer
      • Replace a multisig signer
      • Airgap
    • Telegram wallet (DEPRECATED)
  • TOOLS
    • 🎨STARKNETKIT
    • ✨Invisible SDK
      • Implementation
      • Other useful endpoints
      • Types and interfaces
      • Gas abstraction
  • Example Dapps
    • StarknetKit + Session keys Demo dapp
  • AA Use Cases
    • Session Keys
      • Implement session keys
      • Session keys with outside execution
      • Demo App
      • FAQ
      • Types
    • Paymasters
    • Verifying signatures and cosigners
      • Identifying a smart account onchain
    • Multicalls
    • Outside Execution
    • Deploy accounts on behalf of users
  • Optimize your Dapp
    • Dappland
    • Known dapps
    • Transaction reviews
    • Brand your token
  • Other Products
    • Argent Card
    • Spoks
    • Perkz
    • Argent Vault on Ethereum L1
  • SUPPORT & RESSOURCES
    • Contracts and audits
    • Get in touch
Powered by GitBook
On this page

Was this helpful?

  1. AA Use Cases
  2. Session Keys

Session keys with outside execution

PreviousImplement session keysNextDemo App

Last updated 5 months ago

Was this helpful?

(Meta-transactions in the Ethereum world) 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.

The setup is exactly the same as the "basic" session keys. We simply have a few more steps to do:

1. Prepare the contract call

// example for creating the calldata
const erc20Contract = new Contract(
  Erc20Abi as Abi,
  ETHTokenAddress,
  sessionAccount
)

const calldata = erc20Contract.populate("transfer", {
  recipient: address,
  amount: parseInputAmountToUint256(amount)
})

2. Prepare Execution from outside

Here you have two possibilities. Depending on your setup, you can chose between a "higher level" function with createOutsideExecutionCall which returns a signed call and a "lower level" with createOutsideExecutionTypedData which returns the session acout signature and the typed data.

a. Get the raw Execute from outside call

import { createOutsideExecutionCall } from "@argent/x-sessions"

const efoExecutionCall = await createOutsideExecutionCall({
        session, // same object as before
        sessionKey, // same object as before
        calls: [calldata],
        argentSessionServiceUrl: ARGENT_SESSION_SERVICE_BASE_URL,
        network:
          CHAIN_ID === constants.NetworkName.SN_SEPOLIA ? "sepolia" : "mainnet",
      })

2.b. Get the signed Execute from outside call

import { createOutsideExecutionTypedData } from "@argent/x-sessions"

const { signature, outsideExecutionTypedData } =
  await createOutsideExecutionTypedData({
    session,
    sessionKey,
    calls: [calldata],
    argentSessionServiceUrl: ARGENT_SESSION_SERVICE_BASE_URL
    network // values "mainnet" | "sepolia", default to "mainnet"
  })

Outside Execution