I have created a contract implementing ERC2981 and ERC1155, however I am not being able to understand how can I take a, eg. 5%, fee each time tokens change owners.

I am using openzeppelin implementation of ERC1155, which contains the following:

     * @dev See {IERC1155-safeTransferFrom}.
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        _safeTransferFrom(from, to, id, amount, data);

What do I need to change to allow charging a fee of 5% of the value the NFT is being sold, and still be compliant with the ERC1155 standard?

1 Answer 1


First, please note that it is always possible for somebody to avoid the fee. The "official" transfer is reported as "$0" and then actual money changes hands outside the system.

Anybody who has sold a car or a house understands the incentive to underreporting the value of a transaction.

In general, the only way to collect a fee is to also control the movement of money, and that means making a marketplace.

You probably don't want to make a marketplace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.