useUpdatePrimarySaleRecipient
Hook for updating the primary recipient of tokens from a smart contract.
import { useUpdatePrimarySaleRecipient } from "@thirdweb-dev/react";
Usage
Provide your contract as the argument.
import { useUpdatePrimarySaleRecipient, useContract, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: updatePrimarySaleRecipient, isLoading, error } = useUpdatePrimarySaleRecipient(contract);
if (error) {
console.error("failed to update primary recipient", error);
}
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
updatePrimarySaleRecipient({
to: "{{wallet_address}}", // Use useAddress hook to get current wallet address
})
}
>
Update Primary Recipient
</Web3Button>
);
}