The SDK is in alpha. APIs may change before the first stable release.
Quickstart
1
Install the package
Install the client package and
viem if you want to use the built-in viem signer adapters.2
Create a public client
Create a read-only client for public gacha discovery.
3
Fetch gacha machines
Fetch a page of active gacha machines.
4
Create an authenticated client
Sign in with SIWE, create a user API key, then pass that key and your approved builder API key to
createSecureClient for write workflows.5
Prepare the wallet and pull gacha
Make the user’s Safe wallet ready, then pull from a machine and update your UI through draw resolution. Token release continues asynchronously.
24 or later. By default, requests go to https://api.renaiss.xyz.
Set RENAISS_API_URL or pass baseUrl to point at another environment.
builderApiKey only on secure clients that call wallet, pull, or buyback write methods.
To attribute pulls on-chain, also set a builder code and pass it per pull as builderCode. See Builder code attribution.
SDK patterns
The SDK uses the same patterns across public and authenticated workflows: paginated list methods,Result values for expected failures, and action-specific error guard utilities.
Pagination
List methods return a lazy paginator. UsefirstPage() when you only need one page.
for await to iterate through pages. Each page is still a Result, so handle failures inside the loop.
Error handling
The SDK returns expected failures asResult values. It does not throw for request validation errors, API errors, schema validation errors, or handled signing failures.
Use isFailed() and getError() for general handling. Use action-specific error guard utilities when you want exhaustive handling for one action.
isListGachaMachinesErrorisPullGachaErrorisListGachaBuybackOffersErrorisFetchGachaDrawStatusesErrorisBuybackGachaErrorisIsSafeWalletDeployedErrorisDeploySafeWalletErrorisIsPermit2UsdtApprovedErrorisApprovePermit2UsdtErrorisEnsureSafeWalletReadyError
Public client
Public clients can call unauthenticated endpoints such as gacha machine discovery, machine detail, and machine contents.Authenticated client
Authenticated clients need a user API key. The SDK can create one by asking the user’s wallet to sign a SIWE message, then exchanging the session for an API key.createSecureClient({ apiKey }) is enough for authenticated reads:
fetchAuthenticatedUserlistGachaBuybackOfferslistUserActivitiesfetchGachaDrawStatuses
builderApiKey:
ensureSafeWalletReadyisSafeWalletDeployeddeploySafeWalletisPermit2UsdtApprovedapprovePermit2UsdtpullGachabuybackGacha
x-builder-api-key only for write-authorized requests, not for SIWE API key creation or authenticated reads.
Wallet integrations
The signer must implement the Renaiss signer interface. The viem adapter can use a private key, an existing viem wallet client, or an injected browser provider.Ensure wallet ready
Gacha write flows use the authenticated user’s deterministic Safe wallet and Permit2 USDT approval. They require both the user API key and the secure client’sbuilderApiKey.
Call ensureSafeWalletReady() before letting a user pull gacha or accept buyback offers. It deploys the Safe if needed and approves Permit2 USDT if needed. isSafeWalletDeployed() and isPermit2UsdtApproved() also need builderApiKey because they call prepare routes for sponsored write operations.
Check wallet deployed
UseisSafeWalletDeployed() when you only need to check whether the authenticated user’s Safe already exists.
Deploy wallet
UsedeploySafeWallet() when you want wallet deployment as a separate step.
Approve Permit2 for custom flows
Most integrations should callensureSafeWalletReady(). Use approvePermit2Usdt() explicitly when your flow handles deployment and token approval in separate screens.
Discovery
Use discovery methods to browse gacha machines, machine contents, buyback offers, and user activity feeds. List methods return paginatedResult values, so use the same pagination and error handling patterns from SDK patterns.
Gacha machine
Use gacha machine methods to fetch one machine, inspect its contents, pull from it, stream pull progress, and submit buybacks for eligible cards.Fetch a gacha machine
UsefetchGachaMachine() when you already have a machine slug and need the full machine object.
Pull gacha
UsepullGacha() from a secure client after the user’s wallet is ready. The secure client must include builderApiKey. The SDK prepares the pull, asks the signer for the Safe typed-data signature, submits the pull, and streams progress through aggregated draw resolution. Token release continues asynchronously after the stream closes.
Builder code attribution
pullGacha() accepts an optional builderCode for on-chain attribution. Pass a bytes32 value: 0x followed by 64 hex characters.
builderCode, the API signs and submits the zero bytes32 value.
builderCode is public on-chain data, not a secret. It is separate from builderApiKey, which authorizes the write and must stay server-side. A pull still needs builderApiKey on the secure client.builderCode is not a valid bytes32 value, the SDK returns a WRONG_REQUEST_PARAMS result before preparing the pull.
Pull gacha SSE stages
pullGacha() accepts onEvent, which receives validated SSE events in arrival order. Use these events to show progress until every selected draw resolves.
The final pullGacha() result still returns a Result. If the stream emits an error event or closes before every selected draw appears in a completed GACHA_V3_DRAW_RESOLVED event, the SDK returns a failed result. A successful result contains draws, events, and txHashes. It does not wait for token release.
Each action can arrive with these statuses:
Track asynchronous settlement
UsefetchGachaDrawStatuses() to recover resolved draws after an interrupted or timed-out stream. You can also use it to check whether each token was assigned, released, or bought back. This authenticated read needs the user’s API key. It does not need builderApiKey.
machineId is the gacha machine’s internal UUID, not its slug. pullTransactionHash is the transaction hash from the completed GACHA_V3_OPEN_PACK event.
Buyback
UselistGachaBuybackOffers() to show available offers, then pass one or more compatible offers to buybackGacha(). Listing offers is an authenticated read; submitting the buyback requires builderApiKey. Offers in one request must share a pack, vending machine, and token. The SDK combines up to 10 unique settlement IDs and aggregates their authorized amount before signing.