The Godot TDK will automatically detect if the user is using the Treasure Launcher and provides the developer with access to the user’s auth token.
get_auth_token() -> String
get_user(api_url: String, auth_token: String) -> Dictonary
start_session(
backendWallet: String,
approvedTargets: Array,
nativeTokenLimitPerTransaction: int = 0,
sessionDurationSec: int = 0,
sessionMinDurationLeftSec: int = 0
) -> Dictionary
var auth_token = TDK.get_auth_token()
if auth_token != null:
print(str("Found auth token: ", auth_token))
else:
print("No auth token found!")
var result = await TDK.get_user("https://tdk-api.spellcaster.lol", auth_token)
{
"error_code": 0,
"result": 0,
"response_code": 200,
"headers": [],
"body": "{ 'id': '...', ... }"
}
if result.response_code == 200:
var success_body = JSON.parse_string(result.body.get_string_from_utf8())
else:
var error_body = JSON.parse_string(result.body.get_string_from_utf8())
{
"id": "clziu5ii600029tse5hb91byg",
"address": "0x6BF87Db1c25e40bEE4AB51D8382E1Eb8dFa2B3E2",
"smartAccountAddress": "0x6BF87Db1c25e40bEE4AB51D8382E1Eb8dFa2B3E2",
"email": null,
"phoneNumber": null,
"tag": null,
"discriminant": null,
"tagClaimed": false,
"tagModifiedAt": null,
"tagLastCheckedAt": null,
"emailSecurityPhrase": null,
"emailSecurityPhraseUpdatedAt": null,
"featuredNftIds": [],
"featuredBadgeIds": [],
"highlyFeaturedBadgeId": null,
"about": null,
"pfp": null,
"banner": null,
"showMagicBalance": true,
"showEthBalance": true,
"showGemsBalance": true,
"testnetFaucetLastUsedAt": null,
"allActiveSigners": []
}
{
"code": "AUTH_UNAUTHORIZED",
"data": {
"authError": "Invalid JWT header"
},
"name": "AuthError",
"error": "Unauthorized"
}
var session_result = await TDK.start_session("0x", [], 0, 0, 0)
{
"error_code": 0,
"result": 0,
"response_code": 200,
"headers": [],
"body": "{ 'result': true }"
}
{
"error": "A user is not logged in to perform a start session call"
}