⚠️ ONE-TIME OPERATION PER USER: Each user should only call this function once. The generated managed wallet should be reused for all future file registrations. Store the returned walletAddress and use it for subsequent operations instead of creating new wallets.

Function Signature

function createWallet(
  options: Options
): Promise<Response>;
options
[Options](/sdk-reference/types#createwallet-options)
The options for creating a wallet.
Promise
Promise<[Response](/sdk-reference/types#createwallet-response)>
A promise that resolves with the response from creating a wallet.
Type Definitions: For detailed type information including all properties and their descriptions, visit the Types page.

Usage

import { TrustEngineSDK } from '@trust-engine/sdk';
import { useState } from 'react';

const sdk = new TrustEngineSDK();

export default function WalletCreator() {
  const [walletAddress, setWalletAddress] = useState<string | null>(null);
  const [isLoading, setIsLoading] = useState(false);

  const handleCreateWallet = async () => {
    setIsLoading(true);
    try {
      const result = await sdk.createWallet({ userID: 'user_12345' });
      setWalletAddress(result.details.walletAddress);
    } catch (error) {
      console.error('Failed to create wallet:', error.message);
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <div>
      <button onClick={handleCreateWallet} disabled={isLoading}>
        {isLoading ? 'Creating...' : 'Create Wallet'}
      </button>
      {walletAddress && <p>Wallet Created: {walletAddress}</p>}
    </div>
  );
}