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, error } = useContractMetadata(>);

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 Component = () => {
const {
mutate: updateMetadata,
isLoading,
error,
} = useUpdateMetadata(SmartContract);

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

return (
<button
disabled={isLoading}
onClick={() => updateMetadata({ updatePayload: { name: "My Contract", description: "This is my contract" } })}
>
Update Metadata
</button>
);
};

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

View in React SDK Documentation

Update

const Component = () => {
const {
mutate: updateMetadata,
isLoading,
error,
} = useUpdateMetadata(SmartContract);

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

return (
<button
disabled={isLoading}
onClick={() => updateMetadata({ updatePayload: { name: "My Contract", description: "This is my contract" } })}
>
Update Metadata
</button>
);
};

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(SmartContract);

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

View in React SDK Documentation

Update

const Component = () => {
const {
mutate: updateRoyaltySettings,
isLoading,
error,
} = useUpdateRoyaltySettings(SmartContract);

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

return (
<button
disabled={isLoading}
onClick={() => updateRoyaltySettings({ updatePayload: { fee_recipient: "0x123", 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();

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

View in React SDK Documentation

Update Specific Token

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(SmartContract);

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

View in React SDK Documentation

Update

const Component = () => {
const {
mutate: updatePlatformFees,
isLoading,
error,
} = useUpdatePlatformFees(SmartContract);

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

return (
<button
disabled={isLoading}
onClick={() => updatePlatformFees({ updatePayload: { fee_recipient: "0x123", 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: recipient, isLoading, error } = usePrimarySalesRecipient(SmartContract);

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

View in React SDK Documentation

Update

const Component = () => {
const {
mutate: updatePrimarySalesRecipient,
isLoading,
error,
} = useUpdatePrimarySaleRecipient(SmartContract);

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

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

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

View in React SDK Documentation