Skip to main content

Contract Settings

Additionally, you can add the following settings interfaces to your contracts as shown below.

Contract Metadata

Using the Contract Metadata extension on your contract allows you to add information about your contract (image, description, etc). This information is stored in IPFS and linked to your contract using the standard contractURI accessor. This is compatible with marketplaces like Opensea.

You can use our ContractMetadata implementation as shown below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/feature/ContractMetadata.sol";

// We add the interface to the contract
contract MyCustomContract is ContractMetadata {

// you now have contract metadata functionality in your contract

// Remember to implement the access control function
function _canSetContractURI() internal view override returns (bool) {
// example implementation:
return msg.sender == owner;
}
}

Contract Primary Sale

Using the Contract Primary Sale features on your contract allows you to control the primary sales recipients for your contract.

You can use our PrimarySale implementation as shown below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/feature/PrimarySale.sol";

// We add the interface to the contract
contract MyCustomContract is PrimarySale {

// you now have primary sale recipients getters and setters in your contract

// Remember to implement the access control function
function _canSetPrimarySaleRecipient() internal view override returns (bool) {
// example implementation:
return msg.sender == owner;
}

}

If your contract implements all the functions in this standard, you will get support for the following SDK interface.

const contract = await sdk.getContract("{{contract_address}}");
const salesRecipient = await contract.sales.getRecipient();
await contract.roles.setRecipient(recipientWalletAddress);
View in Javascript SDK Documentation

Contract Platform Fee

Using the Contract Platform Fee features on your contract allows you to control the platform fees for your contract.

You can use our PlatformFee implementation as follows:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/feature/PlatformFee.sol";

// We add the interface to the contract
contract MyCustomContract is PlatformFee {

// you now have platform fee getters and setters in your contract

// Remember to implement the access control function
function _canSetPlatformFeeInfo() internal view override returns (bool) {
// example implementation:
return msg.sender == owner;
}

}

If your contract implements all the functions in this standard, you will get support for the following SDK interface.

const contract = await sdk.getContract("{{contract_address}}");
const feeInfo = await contract.platformFee.get();
await contract.platformFee.set({
platform_fee_basis_points: 100, // 1% fee
platform_fee_recipient: "0x..." // the fee recipient
})
View in Javascript SDK Documentation