PrimarySale
import "@thirdweb-dev/contracts/extension/PrimarySale.sol";
PrimarySale
lets you set a recipient for any sale value you intend to collect in your smart contract.
Usage
The PrimarySale
extension is an abstract contract, and expects you to implement the following functions by yourself:
Name | Type | Returns | Description |
---|---|---|---|
_canSetPrimarySaleRecipient | internal view virtual | bool | Runs on every attempt to set a new primary sale recipient. Returns whether this info can be set in the given execution context. |
This is an example smart contract demonstrating how to inherit from this extension and override the functions to add (optional) custom functionality.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@thirdweb-dev/contracts/extension/PrimarySale.sol";
contract MyContract is PrimarySale {
/**
* We store the contract deployer's address only for the purposes of the example
* in the code comment below.
*
* Doing this is not necessary to use the `PrimarySale` extension.
*/
address public deployer;
constructor() {
deployer = msg.sender;
}
/**
* This function returns who is authorized to set primary sale recipient address for your contract.
*
* As an EXAMPLE, we'll only allow the contract deployer to set the primary sale recipient address.
*
* You MUST complete the body of this function to use the `PrimarySale` extension.
*/
function _canSetPrimarySaleRecipient()
internal
virtual
override
returns (bool)
{
return msg.sender == deployer;
}
}
SDK Usage
By adding this extension to a smart contract, the following features, hooks and functions are unlocked in the SDK:
Base Contracts Implementing This Extension
ERC20Drop
ERC20DropVote
ERC20SignatureMint
ERC20SignatureMintVote
ERC721Drop
ERC721SignatureMint
ERC1155Drop
ERC1155SignatureMint