I am using OpenZeppelin as my open sourced framework for my blockchain development. I am interested to see if there is a work around to accept ERC-20 tokens as payment for the ERC-721 token?

Example: I have some OmiseGo and would Like to Purchase an ERC-721 Token (developed by myself using OpenZeppelin).

I have not come across any instance of this in the OpenZeppelin documentation or online.

  • Have you tried 0x protocol yet? 0x v2 supported trade ERC721
    – Haidt_vn
    Jun 20, 2019 at 4:34

2 Answers 2


I guess what you are expecting is trading of erc 721 to erc20. I don't see any standart or EIPs on this. But you can write another smart contract (a trading one) to trade your ERC 721 with ERC 20. This is more of an exchange than related to any specific ERC. You can write contract to trade ERC 20 vs ERC 20 (that is what we have as DEX (a lot more, obviously)). In similar fashion, you have a ERC 721 to ERC-721 exchange or even ERC20 to ERC 721 exchange.

There are different methodologies to implement the trading. I will see, if I can provide some code for ref when I get some more free time.

  • Thanks for your reply! I would appreciate it if you could provide a basic code example of what you mean. Thanks again.
    – Matoneski
    Jun 28, 2018 at 5:49

Look into the source code for fractional NFTs like TheDogeNFT.

If you're only mapping only one ERC721 to one ERC20:

pragma solidity ^0.8.21;

abstract contract ERC20 is IERC20, IERC20Metadata {} // ERC20 standard implementation

contract YourCustomERC20 is ERC20 {} // Your custom features

contract YourNFTContract {

    YourCustomERC20 public immutable CustomToken;

    constructor() {

        // The ERC20 token bonded to this ERC721 NFT contract.
        CustomToken = new YourCustomERC20({
            name: "CustomToken",
            symbol: "YCT",
            version: "1.2",
            totalSupply: 1e8,
            decimals: 18

    function getERC20Balance(address account) public view returns (uint ERC20Balance) {
        return CustomToken.balanceOf(account);

In the case of ERC1155, it can actually be implemented on top of ERC20 due to function overloading:

    function balanceOf(address account) public view returns (uint) {} // ERC20
    function balanceOf(address account, uint id) public view returns (uint) {} // ERC1155

So the same contract (contract address) can be both ERC1155 and ERC20 compliant without actually needing 2 separate contracts. A complete implementation will eventually be provided on my github page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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