Tutorial
Heading
Oct 18, 2023

Create and deploy a standard ERC721 Smart Contract

This guide explains hot to create and deploy an ERC721 smart contract via OpenZeppelin Wizard and Remix IDE, catering to all skill levels with a Metamask account

The mission

In this guide, you will learn how to create and deploy a standard ERC721 contract and then perform transactions on it.

Before we start

  • To complete this guide, you only need to have a Metamask account and funds in some blockchain.
  • This guide is intended for people of all skill levels, whether they have programming knowledge or not.

Resources

  • OpenZeppelin Wizard: Contracts Wizard is an interface that allows you to interactively build a smart contract using components from OpenZeppelin Contracts.
  • Remix: Remix IDE allows you to develop, deploy, and manage smart contracts for Ethereum-like blockchains.

Workflow

Open Zeppelin Wizard

You can choose between the ERC20, ERC721, ERC1155, and Governor standards.

We will select the ERC721 tab and enter the name and symbol of our contract.

ERC721 button selection in OpenZeppelin

In the Base URI tab, we will also type https://ipfs.io/ipfs/ so that we can reference our files on IPFS.

Settings

  • Name: Set a name for the collection.
  • Symbol: sert a symbol for the collection.
  • Base URI: this will be concatenated with token ID to generate the token URIs.

OpenZeppelin settings configurator

Features

  • Mintable: allows privilegial accounts to create new tokens.
  • Auto Increment IDs: automatically assigns incremental IDs to new tokens.
  • Burnable: creates an ERC721 Token that can be irreversibly burned(destroyed).
  • Pausable: adds a contract module that allows authorized accounts to trigger an emergency stop mechanism.
  • Enumerable: implements an optional extension of ERC721 defined in the EIP, which adds enumerability of all token IDs in the contract as well as all token IDs owned by each account.
  • URI Storage: provides an ERC721 token with storage-based token URI management.

OpenZeppelin features

Access Control

This directory provides ways to restrict who can access the functions of a contract or when they can do it.

  • Ownable: this contract module provides basic access control, where there is an account (an owner) that has exclusive access to specific functions. By default, the owner account is the one that deploys the contract, but this can later be changed with transferOwnership. This module is used through inheritance and makes the onlyOwner modifier available, which can be applied to functions to restrict their use to the owner.
  • Roles: this contract module allows children to implement role-based access control mechanisms. It's a lightweight version that doesn't allow enumeration of role members except through off-chain means by accessing the contract event logs. For cases requiring on-chain enumerability, see AccessControlEnumerable. Roles are referred to by their bytes32 identifier, and these should be exposed in the external API as unique identifiers. The best way to achieve this is by using public constant hash digests.

OpenZeppelin acess control

Upgradeability

OpenZeppelin provides tooling for deploying and securing upgradeable smart contracts.

  • Transparent: uses a more complex proxy with higher overhead but requires fewer changes in your contract. Can also be used with beacons.
  • UUPS: uses a simple proxy with less overhead but requires including extra code in your contract. Allows flexibility for authorizing upgrades.
OpenZeppelin upgradeabilidty

Information

  • Security contract: provide a contact where people can report security issues. This will only be visible if contract metadata is verified.
  • License: the MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it places very limited restrictions on reuse and is, therefore, highly compatible.
OpenZeppelin info tab
OpenZeppelin go to remix

Remix

Solidity compiler

  • Compiler: choose the same version of the compiler that appears in the code.
Compiler pragma solidity version

Compile our contract by clicking the compile button.

Compile contract button

Deploy & run transaction

  • Enviroment: select the "Injected Web3" option and connect Metamask to Remix.
Remix environment configuration

  • Deploy: click the "Deploy" button and confirm the transaction.
Remix deploy button

  • Deployed Contracts: you can access your contract in the "Deployed Contracts" tab. Click on it to display all the functions of your contract. It's as simple as entering the parameters and clicking the actions.
Remix deployed contracts interact buttons

Conclusion

There are increasingly more platforms that allow you to create smart contracts without having to write code.

Remix offers incredible facilities for both beginners in blockchain programming and experienced developers looking to explore new functionalities in smart contracts.

Code
Web3
David Beatove
Blockchain Developer
Case Study
Making 3D Avatars for Bored Ape Yacht Club
Tutorial
How to import Decentraland SkyboxEditor into Unity
Tutorial
Doing a MANA transaction in a Decentraland scene