Skip to main content

useUpdateRoyaltySettings

Hook for updating royalty settings on a smart contract.

Available to use on smart contracts that implement the Royalty interface.

import { useUpdateRoyaltySettings } from "@thirdweb-dev/react";

const {
mutateAsync: updateRoyaltySettings,
isLoading,
error,
} = useUpdateRoyaltySettings(contract);

Usage

Provide your contract instance from the useContract hook as the argument.

import {
useUpdateRoyaltySettings,
useContract,
Web3Button,
} from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);
const {
mutateAsync: updateRoyaltySettings,
isLoading,
error,
} = useUpdateRoyaltySettings(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
updateRoyaltySettings({
seller_fee_basis_points: 0,
fee_recipient: "{{wallet_address}}",
})
}
>
Update Royalty Settings
</Web3Button>
);
}

Configuration

seller_fee_basis_points (required)

seller_fee_basis_points (required)

The seller_fee_basis_points property is a number between 0 - 10000 that defines the fee rate.

This number is in percentage points. i.e. 100 is a 1% fee and 10000 is a 100% fee.

import {
useUpdateRoyaltySettings,
useContract,
Web3Button,
} from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);
const {
mutateAsync: updateRoyaltySettings,
isLoading,
error,
} = useUpdateRoyaltySettings(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
updateRoyaltySettings({
seller_fee_basis_points: 1000, // 10% royalty fee
fee_recipient: "{{wallet_address}}",
})
}
>
Update Royalty Settings
</Web3Button>
);
}
fee_recipient (required)

fee_recipient (required)

The fee_recipient property is the address of the wallet that will receive the fees.

import {
useUpdateRoyaltySettings,
useContract,
Web3Button,
} from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);
const {
mutateAsync: updateRoyaltySettings,
isLoading,
error,
} = useUpdateRoyaltySettings(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
updateRoyaltySettings({
seller_fee_basis_points: 1000,
fee_recipient: "{{wallet_address}}",
})
}
>
Update Royalty Settings
</Web3Button>
);
}