DecaneDocs
DataServer-side wallets
Data

Server-side wallet creation

Create a user, and their wallet, before they have signed in. Decane keys the user exactly as the matching sign-in will, so their first sign-in opens the wallet made here. The key is generated inside the enclave; your server sees only the addresses.

rust
use decane::{CreateUserOptions, UserIdentifier, WalletOutcome};

let made = decane
    .create_user(UserIdentifier::email("ada@example.com"), CreateUserOptions::default())
    .await?;
made.user.addresses.evm; // fund it now; Ada finds it when she signs in
made.created;            // true when this call made the user
made.wallet;             // WalletOutcome::Created | Exists | None

Identifiers

ConstructorValue
UserIdentifier::email(..)Any case. A later email-code or Google sign-in with this verified address opens the same wallet.
UserIdentifier::phone(..)E.164, +<country><number>.
UserIdentifier::custom(subject, provider_id)The subject your own JWTs assert, with the provider id from the dashboard.
UserIdentifier::kingschat(..), ::x(..)The provider’s stable user id, never an @handle.
rust
decane.create_user(
    UserIdentifier::phone("+2348012345678"),
    CreateUserOptions { metadata: Some(patch), ..Default::default() },
).await?;

decane.create_user(
    UserIdentifier::custom("auth0|123", provider_id),
    CreateUserOptions { create_wallet: Some(false), ..Default::default() },
).await?;

decane.create_user_wallet(&made.user.id).await?; // for an existing user with no wallet

Rules

  • Idempotent on the identifier: calling twice returns the same user.
  • Off until the Decane team switches it on for your project; until then calls fail with ServerWalletsDisabled.
  • Sixty calls a minute per project.
  • Other failures: InvalidIdentifier, WalletExists (from create_user_wallet), WalletFrozen, RetryLater, EnclaveUnavailable.