Usage

import { TreasureProvider } from "@treasure-dev/tdk-react";

function App() {
  return (
    <TreasureProvider
      apiUri="https://tdk-api.spellcaster.lol"
      chainId={421614}
      clientId="..."
      sessionOptions={{
        backendWallet: "...",
        approvedTargets: [
          "0x55d0cf68a1afe0932aff6f36c87efa703508191c",
        ],
      }}
    >
      {/** ... */}
    </TreasureProvider>
  );
}

Props

apiUri

string | undefined

  • The TDK API URI to use for all HTTP requests.
  • Defaults to "https://tdk-api.treasure.lol".
  • Development environment value is "https://tdk-api.spellcaster.lol".

chainId

number | undefined

  • The chain ID to use for initial connection.
  • Defaults to 42161 (Arbitrum One).

clientId

string

sessionOptions

SessionOptions | undefined

  • Options for creating user sessions, if using account abstraction.

backendWallet

string | undefined

approvedTargets

string[] | undefined

  • List of contract addresses that should be approved for interaction via the TDK API during the user’s session. Leave blank if no contract interactions are needed.

nativeTokenLimitPerTransaction

bigint | undefined

  • Maximum amount of native token that can be transferred in a single transaction, specified in wei. Leave blank if no native token transfers are needed besides gas fees.

sessionDurationSec

number | undefined

  • Duration of the user session, in seconds.
  • Defaults to 86,400 (24 hours).

sessionMinDurationLeftSec

number | undefined

  • Minimum duration left in the user session, in seconds, before the user is prompted to extend their session.
  • Defaults to 3,600 (1 hour).