@@ -16,7 +16,7 @@ import { GemIcon } from "lucide-react";
1616import { useState } from "react" ;
1717import { useForm } from "react-hook-form" ;
1818import { toast } from "sonner" ;
19- import { type ThirdwebContract , ZERO_ADDRESS } from "thirdweb" ;
19+ import { type ThirdwebContract , ZERO_ADDRESS , isAddress } from "thirdweb" ;
2020import { getApprovalForTransaction } from "thirdweb/extensions/erc20" ;
2121import { claimTo } from "thirdweb/extensions/erc721" ;
2222import { useActiveAccount , useSendAndConfirmTransaction } from "thirdweb/react" ;
@@ -62,7 +62,19 @@ export const NFTClaimButton: React.FC<NFTClaimButtonProps> = ({
6262 < div className = "flex w-full flex-col gap-6 md:flex-row" >
6363 < FormControl isRequired isInvalid = { ! ! errors . to } >
6464 < FormLabel > To Address</ FormLabel >
65- < Input placeholder = { ZERO_ADDRESS } { ...register ( "to" ) } />
65+ < Input
66+ placeholder = { ZERO_ADDRESS }
67+ { ...register ( "to" , {
68+ validate : ( value ) => {
69+ if ( ! value ) {
70+ return "Enter a recipient address" ;
71+ }
72+ if ( ! isAddress ( value . trim ( ) ) ) {
73+ return "Invalid EVM address" ;
74+ }
75+ } ,
76+ } ) }
77+ />
6678 < FormHelperText > Enter the address to claim to.</ FormHelperText >
6779 < FormErrorMessage > { errors . to ?. message } </ FormErrorMessage >
6880 </ FormControl >
@@ -110,7 +122,7 @@ export const NFTClaimButton: React.FC<NFTClaimButtonProps> = ({
110122
111123 const transaction = claimTo ( {
112124 contract,
113- to : d . to ,
125+ to : d . to . trim ( ) ,
114126 quantity : BigInt ( d . amount ) ,
115127 from : account . address ,
116128 } ) ;
0 commit comments