Crowdsale contract for ERC721

Hi there, I want to use something like the crowdsale contract but for erc721. What approach should I follow? I saw this was scoped in this PR, but is stale atm(?

I’m learning and planned to build a lottery, where the tickets are NFTs. Using something similar to the crowdsale contract makes sense, right?

Thanks in advance!

1 Like

Hi @fpetra,

Welcome to the community :wave:

If you are selling NFTs, then using the equivalent of a crowdsale sounds like a viable option.

A user purchases a number of tokens (in this case NFTs) for a fixed price and is issued the tokens. (if the user overpays, then they can be refunded any over payment).

Any such solution should have appropriate testing (Test smart contracts like a rockstar) and auditing (https://openzeppelin.com/security-audits/). Along with obtaining appropriate regulatory advice for the relevant jurisdictions.

You could look at ERC721Metadata.baseURI in OpenZeppelin Contracts 2.5:

OpenZeppelin Contracts v2.5
ERC721Metadata.baseURI : a neat extension for massive gas savings when the token URIs share a prefix, like https://my.cool.app/token/<id>

As an aside Crowdsales are being removed from OpenZeppelin Contracts as of version 3: https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2068

I couldn't see where in the PR you linked where an ERC721 crowdsale was scoped.

You may want to look at what functionality OpenSea offers as far as initial selling of NFTs. OpenSea has a guide to all things NFT: https://opensea.io/blog/guides/non-fungible-tokens/

In the lottery space, you could look at PoolTogether, which is a protocol that allows users to join a trust-minimized no-loss lottery on the Ethereum network. OpenZeppelin recently published an audit: https://blog.openzeppelin.com/pooltogether-audit/

2 Likes

Hi @fpetra,

How are you getting on?
Feel free to ask all the questions that you need.