Skip to main content

Contract Settings

Configure the settings of your smart contract.

Contract Metadata

Read, write, and update the metadata of a smart contract using the SDK, such as the name, description and image.

Read

const { data: contractMetadata, isLoading } = useContractMetadata(contract);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Write (Overwrite)

danger

This will overwrite the existing metadata.

const appURI = "ipfs://some_ipfs_hash";
await contract.appURI.set(appURI);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Update

await contract.metadata.update({
description: "My new contract description"
})

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Royalty Fees

Read and update the royalty fees of a collection or a specific token.

Read

const { data: settings, isLoading, error } = useRoyaltySettings(contract);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Update

const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: updateRoyaltySettings,
isLoading,
error,
} = useUpdateRoyaltySettings(contract);

if (error) {
console.error("failed to update royalty settings", error);
}

return (
<button
disabled={isLoading}
onClick={() => updateRoyaltySettings({ updatePayload: { fee_recipient: "{{wallet_address}}", seller_fee_basis_points: 5_00 } })}
>
Update Royalty Settings
</button>
);
};

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Read Specific Token

const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo();
console.log(royaltyInfo.fee_recipient);
console.log(royaltyInfo.seller_fee_basis_points);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Update Specific Token

const tokenId = 0;
await contract.roles.setTokenRoyaltyInfo(tokenId, {
seller_fee_basis_points: 100, // 1% royalty fee
fee_recipient: "0x...", // the fee recipient
});

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Platform Fees

Platform fees allow you to charge a percentage fee wherever there is a transfer of currency in your contract.

Read

const { data: platformFees, isLoading, error } = usePlatformFees(contract);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Update

const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: updatePlatformFees,
isLoading,
error,
} = useUpdatePlatformFees(contract);

if (error) {
console.error("failed to update platform fees", error);
}

return (
<button
disabled={isLoading}
onClick={() => updatePlatformFees({ updatePayload: { fee_recipient: "{{wallet_address}}", platform_fee_basis_points: 5_00 } })}
>
Update Platform fees
</button>
);
};

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Primary Sale

Configure the recipient of the primary sale fees.

Read

const { data: primarySaleRecipient, isLoading, error } = usePrimarySalesRecipient(contract);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Update

const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: updatePrimarySalesRecipient,
isLoading,
error,
} = useUpdatePrimarySaleRecipient(contract);

if (error) {
console.error("failed to update recipient", error);
}

return (
<button
disabled={isLoading}
onClick={() => updatePrimarySalesRecipient({ newRecipient: "{{wallet_address}}" })}
>
Update Recipient
</button>
);
};

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation