React
TreasureProvider
The main context wrapper for TDK-powered applications.
Usage
Treasure Connect
To get started with Treasure Connect and allow users to log into their Treasure Accounts, only a few configuration options are required
Enable backend transactions
To start on-chain sessions for your users that can enable the sending of backend transations, sessionOptions
and a backendWallet
must be provided:
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"
.
defaultChainId
number | undefined
- The chain ID to use for initial connection.
- Defaults to
42161
(Arbitrum One).
clientId
string
- Thirdweb client ID, provided by Treasure for ecosystem partners.
ecosystemId
string | undefined
- The ecosystem ID for the ecosystem wallets.
- Defaults to
"ecosystem.treasure"
. - Development environment value is
"ecosystem.treasure-dev"
.
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
- Thirdweb Engine backend wallet address, provided by Treasure for ecosystem partners.
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).