Skip to content

thirdweb@5.88.0

Compare
Choose a tag to compare
@joaquim-verges joaquim-verges released this 08 Feb 00:15
· 1185 commits to main since this release
a322e16

Minor Changes

  • #6194 9663079 Thanks @joaquim-verges! - Added session keys to smart wallet options

    You can now pass a sessionKey to the smartWallet options function to immediately add a session key to the smart wallet upon connection.

    This is great in combination with an engine backend wallet! Let's you act on behalf of the user from your backend, making executing transactions as easy as a REST API call. Also unblocks automations, like renewing a subscription, or paying for a service.

    const wallet = smartWallet({
      sessionKey: {
        address: "0x...", // the session key address (ex: engine backend wallet)
        permissions: {
          approvedTargets: ["0x..."], // allowed contract addresses (or * for all)
          nativeTokenLimitPerTransaction: 0.1, // max spend per transaction in ETH
          permissionEndTimestamp: new Date(Date.now() + 1000 * 60 * 60), // expiration date
        },
      },
    });
    
    // this will connect the user wallet and add the session key if not already added
    await wallet.connect({
      client: TEST_CLIENT,
      personalAccount,
    });

    You can also pass the sessionKey to the ConnectButton, ConnectEmbed components and useConnect hook.

    <ConnectButton
      client={client}
      accountAbstraction={{
        chain,
        sponsorGas: true,
        sessionKey: {
          address: "0x...",
          permissions: {
            approvedTargets: "*",
          },
        },
      }}
    />

    Also works for the inAppWallet smartAccount option!

    const wallet = inAppWallet({
      smartAccount: {
        chain,
        sponsorGas: true,
        sessionKey: {
          address: "0x...",
          permissions: {
            approvedTargets: "*",
          },
        },
      },
    });

Patch Changes