Other Contract Settings
Additionally, you can add the following settings interfaces to your contracts as shown below.
Contract Primary Sale
Using the Contract Primary Sale features on your contract allows you to control the primary sales for your contract.
You can add this interface to your contract by implementing all of the functions in the IPrimarySale interface as shown below:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@thirdweb-dev/contracts/ThirdwebContract.sol";
import "@thirdweb-dev/contracts/feature/interface/IPrimarySale.sol";
// We add the interface to the contract
contract MyCustomContract is ThirdwebContract, IPrimarySale {
// Implement the permissions functions below
}
Alternatively, you can use our PrimarySale implementation of the IPrimarySale interface to get primary sale functionality for your contract out-of-the-box as follows:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@thirdweb-dev/contracts/ThirdwebContract.sol";
import "@thirdweb-dev/contracts/feature/interface/PrimarySale.sol";
// We add the interface to the contract
contract MyCustomContract is ThirdwebContract, PrimarySale {
// Now this contract will have primary sales out of the box
}
If your contract implements all the functions in this standard, you will get support for the following SDK interface.
- Javascript
const contract = await sdk.getContract("{{contract_address}}");
const salesRecipient = await contract.sales.getRecipient();
await contract.roles.setRecipient(recipientWalletAddress);
Contract Platform Fee
Using the Contract Platform Fee features on your contract allows you to control the platform fees for your contract.
You can add this interface to your contract by implementing all of the functions in the IPlatformFee interface as shown below:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@thirdweb-dev/contracts/ThirdwebContract.sol";
import "@thirdweb-dev/contracts/feature/interface/IPlatformFee.sol";
// We add the interface to the contract
contract MyCustomContract is ThirdwebContract, IPlatformFee {
// Implement the permissions functions below
}
Alternatively, you can use our PlatformFee implementation of the IPlatformFee interface to get platform fee functionality for your contract out-of-the-box as follows:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@thirdweb-dev/contracts/ThirdwebContract.sol";
import "@thirdweb-dev/contracts/feature/interface/PlatformFee.sol";
// We add the interface to the contract
contract MyCustomContract is ThirdwebContract, PlatformFee {
// Now this contract will have platform fees out of the box
}
If your contract implements all the functions in this standard, you will get support for the following SDK interface.
- Javascript
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
})