How to transfer native tokens using thirdweb SDK

Transferring native tokens on a blockchain is crucial for various tasks, like sending tokens, making payments, or integrating transfers into apps. Here are examples using the thirdweb SDK v4 in React, TypeScript, and Unity:

  1. how to transfer the native token of your blockchain using the thirdweb SDK v4 (React)
    1. const Component = () => {
        const {
          mutate: transferNativeToken,
          isLoading,
          error,
        } = useTransferNativeToken();
      
        if (error) {
          console.error("failed to transfer tokens", error);
        }
      
        return (
          <button
            disabled={isLoading}
            onClick={() =>
              transferNativeToken({
                to: "{{wallet_address}}",
                amount: "0.1",
              })
            }
          >
            Transfer
          </button>
        );
      };
      
  1. how to transfer the native token of your blockchain using the thirdweb SDK v4 (typescript)
    1. await sdk.wallet.transfer("0x...", 0.8);
  1. how to transfer the native token of your blockchain using the thirdweb SDK v4 (unity)
    1. var data = await sdk.wallet.Transfer("{{to_address}}", "{{amount}}")
       
 

That's it! It's that simple to use the thirdweb SDK to transfer native tokens.

 

Can’t get this working? If you’ve followed the above and still have issues, contact our support team for help.

 
Did this answer your question?
😞
😐
🤩