Skip to content

Getting user data

Once your user has successfully authenticated, you can get a PrivyUser object containing their account data via:

csharp
// User will be null if no user is authenticated
PrivyUser user = PrivyManager.Instance.User;

The PrivyUser implements the interface below:

csharp
public interface IPrivyUser
{
    // The user's ID
    string Id { get; }

    // List of the User's linked accounts
    PrivyLinkedAccount[] LinkedAccounts { get; }

    // A list of the user's embedded wallets
    IEmbeddedWallet[] EmbeddedWallets { get; }

    // Creates an embedded wallet for the user
    Task<IEmbeddedWallet> CreateWallet();

    // Custom user metadata, stored as a set of key-value pairs.
    // This custom metadata is set server-side.
    Dictionary<string, string> CustomMetadata { get; }
}

WARNING

Make sure you subscribe to the Authentication State Updates and avoid calling the IPrivyUser object without being Authenticated, as properties will return a default value otherwise.

See the default values for the PrivyUser when the user is not authenticated:
  • user.Id = ""
  • user.LinkedAccounts = []
  • user.EmbeddedWallets = []
  • user.CustomMetadata = new Dictionary()

TIP

You can set custom metadata for a user via Privy's backend server SDK and/or API endpoints!