Usage

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

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

Props

appName

string

  • The name of the application, used in the connect modal flow.

appIconUri

string | undefined

  • An icon URI for the application, used in the connect modal flow.

autoConnectTimeout

number | undefined

  • Time in milliseconds to wait before the wallet auto-connect feature times out.
  • Defaults to 5_000 (5 seconds).

language

"en" | "es" | "ja" | "ru" | undefined

  • Language to use for UI elements.
  • Defaults to the user’s browser language, if supported. Otherwise, falls back to “en”.

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

ecosystemId

string | undefined

  • The ecosystem ID for the ecosystem wallets.
  • Defaults to "ecosystem.treasure".

ecosystemPartnerId

string

  • The ecosystem partner ID for the ecosystem wallets.

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).