Skip to main content

Deploy an ERC-721 Token

OpenZeppelin provides secure, community-vetted smart contract templates that follow best practices for ERC-721 (NFT) development.

Step 0: Setup Foundry

If your Foundry project isn’t set up yet, please go to the Foundry setup section before proceeding.

Step 1: Create the ERC-721 Contract

Create a contract script in src/MyERC721.sol. Run:
Add the code:
This contract:
  • Inherits from OpenZeppelin’s ERC721 contract
  • Sets the name to "MyNFT" and symbol "MNFT"
  • Includes a mint function allowing the creation of NFTs
  • Tracks the next available token ID

Step 2: Compile the Contract

Compile your contract:

Step 3: Prepare Signer for Deployment

This tutorial uses the Foundry Keystore for increased security. Create a new keystore:
Provide a password to encrypt the keystore file when running the command. If you forget the password, it cannot be recovered.
Get your wallet address:
Visit the sFUEL Station, toggle testnet, and fill up on sFUEL.
Make sure testnet mode is enabled on the sFUEL Station if you’re using a testnet SKALE Chain!

Step 4: Deploy the Contract

Deploy your ERC-721 contract:
The --legacy flag is required for SKALE Chains. For more information, see Troubleshooting.
Example deployment output:

Step 5: Verify Your Smart Contract

Verify the contract on the block explorer:
Replace <DEPLOYED_ADDRESS> with your smart contract address.