thirdweb Documentation

website·Indexed 38 days ago

https://docs.thirdweb.com/

Developer tools and SDKs for building web3 applications, featuring UI components like BridgeWidget and TransactionButton, React hooks such as useReadContract and useWalletInfo, and deployment utilities for ERC20, ERC721, and ERC1155 contracts. Includes support for wallet connection, account abstraction, EIP-1193 providers, and marketplace contract deployment.

Tokens
254.8K
Snippets
2K
Records
2.1K
Agent score
60%

What's inside thirdweb

  1. Display social usernames with the AccountName component

    The AccountName component is used to resolve and display social profile usernames (such as ENS, Farcaster, or Lens) associated with a specific wallet address. It provides built-in support for loading states, fallback mechanisms to the wallet address if resolution fails, and custom formatting of the resolved name.
    <AccountName // props here 
    />
  2. Retrieve a block by its hash using eth_getBlockByHash

    The eth_getBlockByHash function retrieves detailed information about a block using its hash. You can optionally specify whether to include full transaction objects or just the transaction hashes via the includeTransactions parameter.
    import { getRpcClient, eth_getBlockByHash } from "thirdweb/rpc";
    
    const rpcRequest = getRpcClient({ client, chain });
    const block = await eth_getBlockByHash(rpcRequest, {
      blockHash: "0x...",
      includeTransactions: true,
    });
  3. Reference for getCallPoliciesForSigner function signature

    The getCallPoliciesForSigner function accepts BaseTransactionOptions<GetCallPoliciesForSignerParams> and returns a Promise that resolves to an array of policy objects. Each policy object contains details about the target, selector, maxValuePerUse, valueLimit, and a set of constraints (including conditions, indices, and reference values).
    function getCallPoliciesForSigner(options: BaseTransactionOptions<GetCallPoliciesForSignerParams>) : Promise<readonly Array<{ constraints: readonly Array<{ condition: number; index: bigint; limit: { limit: bigint; limitType: number; period: bigint }; refValue: `0x${string}` }>; maxValuePerUse: bigint; selector: `0x${string}`; target: string; valueLimit: { limit: bigint; limitType: number; period: bigint } }>>
  4. Retrieve a Lens publication using getPublication

    The getPublication function from the thirdweb/extensions/lens library allows you to call the getPublication function on a Lens contract to retrieve details about a specific publication. It requires a contract instance, the profile ID, and the publication ID.
    import { getPublication } from "thirdweb/extensions/lens";
     
    const result = await getPublication({
     contract,
     profileId: ..., // The ID of the profile
     pubId: ...,     // The ID of the publication
    });
  5. Fetch a published contract's metadata

    Use fetchPublishedContract to retrieve details about a published contract, including its bytecode hash, contract ID, implementation address, metadata URI, and publish timestamp.
    const publishedContract = await fetchPublishedContract({
      publisherAddress: "0x1234",
      contractName: "MyContract",
      version: "1.0.0",
      client: client,
    });
  6. Retrieve NFT information using ERC721.getNFT

    The getNFT extension from thirdweb/extensions/erc721 retrieves detailed information about a specific ERC721 non-fungible token (NFT). It returns a promise that resolves to an NFT object containing the chain ID, token ID, metadata, owner address, token address, and token URI.
    import { getNFT } from "thirdweb/extensions/erc721";
    
    const nft = await getNFT({
      contract,
      tokenId: 1n,
    });
  7. Retrieve follow data using LENS.getFollowData

    The getFollowData function from the thirdweb/extensions/lens module calls the getFollowData function on the Lens contract to retrieve detailed information about a specific follow relationship, including the follower's profile ID and timestamps.
    import { getFollowData } from "thirdweb/extensions/lens";
     
    const result = await getFollowData({
      contract,
      followTokenId: ..., // The ID of the follow token to query
    });
  8. Use the AccountBalance component to display wallet balances

    The AccountBalance component fetches and displays the balance of a specified wallet address on a given blockchain. It supports custom formatting, loading states, and error fallbacks.
  9. Retrieve ERC1155 NFT information using getNFT

    The getNFT function from the thirdweb/extensions/erc1155 module retrieves detailed information about a specific ERC1155 non-fungible token (NFT). It returns a promise that resolves to an NFT object containing the token's metadata, owner, address, and URI. The return type varies depending on whether the token is identified as an ERC721 or ERC1155 type, with ERC1155 types additionally including the token supply.
    import { getNFT } from "thirdweb/extensions/erc1155";
    
    const nft = await getNFT({
      contract,
      tokenId: 1n,
    });
  10. Burn ERC20 tokens from an account using burnFrom

    The burnFrom extension prepares a transaction to call the burnFrom function on an ERC20 contract. This allows the contract to burn a specified amount of tokens from a given account, provided the caller has the necessary allowance. The resulting prepared transaction must be executed using sendTransaction.
    import { sendTransaction } from "thirdweb";
    import { burnFrom } from "thirdweb/extensions/erc20";
     
    const transaction = burnFrom({
     contract,
     account: ..., // The account from which tokens will be burned
     amount: ...,   // The amount of tokens to burn
     overrides: {
       ...
     }
    });
     
    // Send the transaction
    await sendTransaction({ transaction, account });
  11. MintableERC1155.install API Reference

    The MintableERC1155.install method prepares a transaction to install the MintableERC1155 module. It takes an options object containing the account, the target contract, and installation parameters.
    function install(options: {
      account: Account;
      contract: Readonly;
      params: EncodeBytesOnInstallParams & { publisher?: string };
    }): PreparedTransaction;
  12. Encode installation data for the RoyaltyERC721 module

    Use the RoyaltyERC721.encodeInstall function to generate the encoded installation data required to install the RoyaltyERC721 module. This function takes an EncodeBytesOnInstallParams object and returns the encoded data as a hex string.
    function encodeInstall(
      params: EncodeBytesOnInstallParams,
    ): `0x${string}`;