Consult with the Treasure team to gain access to a pre-release version of the Treasure Launcher.

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.

The auth token can be used to interact with the TDK API.

Public members

addons/tdk/tdk.gd
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

Usage

get_auth_token

# Get the auth token from the Treasure Launcher
var auth_token = TDK.get_auth_token()
if auth_token != null:
    print(str("Found auth token: ", auth_token))
else:
    print("No auth token found!")

get_user

# Get the user from the TDK API using the auth token
var result = await TDK.get_user("https://tdk-api.spellcaster.lol", auth_token)

Example result:

{
  "error_code": 0,
  "result": 0,
  "response_code": 200,
  "headers": [],
  "body": "{ 'id': '...', ... }"
}

Parsing the response body:

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

Example success response body:

{
  "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": []
}

Example error response body:

{
  "code": "AUTH_UNAUTHORIZED",
  "data": {
    "authError": "Invalid JWT header"
  },
  "name": "AuthError",
  "error": "Unauthorized"
}

start_session

# Start a user session via the Treasure Launcher
var session_result = await TDK.start_session("0x", [], 0, 0, 0)

Example result:

{
  "error_code": 0,
  "result": 0,
  "response_code": 200,
  "headers": [],
  "body": "{ 'result': true }"
}

Example success response body:

{
  "result": true
}

Example error response body:

{
  "error": "A user is not logged in to perform a start session call"
}