Connect and Interact with a user wallet

Example

const balance = await sdk.wallet.balance();

Hierarchy

  • UserWallet

Constructors

  • Parameters

    • network: NetworkInput
    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      }
    • storage: ThirdwebStorage<IpfsUploadBatchOptions>

    Returns UserWallet

Properties

connection: RPCConnectionHandler
events: EventEmitter<UserWalletEvents, any> = ...
options: undefined | {
    clientId?: string;
    gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
    gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; });
    gatewayUrls?: string[];
    readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
    secretKey?: string;
    supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
}

Type declaration

  • Optional clientId?: string
  • Optional gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; }
  • Optional gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; })
  • Optional gatewayUrls?: string[]
  • Optional readonlySettings?: { rpcUrl: string; chainId?: number | undefined; }
  • Optional secretKey?: string
  • Optional supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[]
storage: ThirdwebStorage<IpfsUploadBatchOptions>

Methods

  • Fetch the native or ERC20 token balance of this wallet

    Parameters

    • currencyAddress: string = NATIVE_TOKEN_ADDRESS

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    Example

    // native currency balance
    const balance = await sdk.wallet.balance();
    // ERC20 token balance
    const erc20balance = await sdk.wallet.balance(tokenContractAddress);
  • Execute a raw transaction to the blockchain from the connected wallet and wait for it to be mined

    Parameters

    • transactionRequest: TransactionRequest

      raw transaction data to send to the blockchain

    Returns Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>

  • Get the number of transactions sent from this address.

    Parameters

    • Optional blockTag: BlockTag

      Optional - the block tag to read the nonce from

    Returns Promise<BigNumberish>

  • Recover the signing address from a signed message

    Parameters

    • message: string

      the original message that was signed

    • signature: string

      the signature to recover the address from

    Returns string

    the address that signed the message

    Example

    const message = "Sign this message...";
    const signature = await sdk.wallet.sign(message);

    // Now we can recover the signing address
    const address = sdk.wallet.recoverAddress(message, signature);
  • Request funds from a running local node to the currently connected wallet

    Parameters

    • amount: string | number

      the amount in native currency (in ETH) to request

    Returns Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>

  • Send a raw transaction to the blockchain from the connected wallet

    Parameters

    • transactionRequest: TransactionRequest

      raw transaction data to send to the blockchain

    Returns Promise<TransactionResponse>

  • Sign any message with the connected wallet private key

    Parameters

    • message: string

      the message to sign

    Returns Promise<string>

    the signed message

    Example

    // This is the message to be signed
    const message = "Sign this message...";

    // Now we can sign the message with the connected wallet
    const signature = await sdk.wallet.sign(message);
  • Sign a typed data structure (EIP712) with the connected wallet private key

    Parameters

    • domain: EIP712Domain

      the domain as EIP712 standard

    • types: Record<string, TypedDataField[]>

      the structure and data types as defined by the EIP712 standard

    • message: Record<string, any>

      the data to sign

    Returns Promise<{
        payload: any;
        signature: string;
    }>

    the payload and its associated signature

    Example

    // This is the message to be signed
    // Now we can sign the message with the connected wallet
    const { payload, signature } = await sdk.wallet.signTypedData(
    {
    name: "MyEIP721Domain",
    version: "1",
    chainId: 1,
    verifyingContract: "0x...",
    },
    { MyStruct: [ { name: "to", type: "address" }, { name: "quantity", type: "uint256" } ] },
    { to: "0x...", quantity: 1 },
    );
  • Transfer native or ERC20 tokens from this wallet to another wallet

    Parameters

    • to: string

      the account to send funds to

    • amount: string | number

      the amount in tokens

    • currencyAddress: string = NATIVE_TOKEN_ADDRESS

      Optional - ERC20 contract address of the token to transfer

    Returns Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>

    Example

     // transfer 0.8 ETH
    await sdk.wallet.transfer("0x...", 0.8);
    // transfer 0.8 tokens of `tokenContractAddress`
    await sdk.wallet.transfer("0x...", 0.8, tokenContractAddress);

Generated using TypeDoc