DEV Community

Cover image for How to deploy you NFT on Sepolia - Simple and 100% under control
Sebastien Levy
Sebastien Levy

Posted on

How to deploy you NFT on Sepolia - Simple and 100% under control

In a previous article about Transparent Upgradeable Proxy in solidity, I showed how this pattern has been used in a real NFT project.

In this article, let's focus on how this kind of project can easily and efficiently be deployed on a testnet to ensure it works well before jumping to mainnet.

Why bother with testnets?

Deploying smart contracts on a testnet offers several advantages over skipping this step entirely. Testnets provide a realistic simulation of the Ethereum Mainnet environment, allowing developers to test contract functionality, interactions, and user flows in a live blockchain setting without risking real funds.
This enables thorough end-to-end testing and allows beta testers to evaluate the application under real-world conditions.

In contrast, skipping testnet deployment means missing out on these critical validation steps. Without testing on a testnet, developers risk deploying untested logic to the mainnet, where bugs could lead to irreversible financial losses or security vulnerabilities.

While local development networks are useful for initial testing, they do not fully replicate the behavior of the Ethereum Virtual Machine (EVM) or the dynamics of a live network, making testnet deployment a necessary intermediate step before mainnet release.

You should not skip this kind of deployment for any serious project.

The project

To illustrate, let's focus on the NFT project I've already talked about: Nifty.

This is a complete NFT project thoroughly tested and able to be deployed at will on sepolia, provided you have the necessary API key from etherscan, a node provider for instance alchemy giving you an access to the test network as well as test ethers you can obtain from a faucet such as chainlink.

Tooling used

Developping and deploying a blockchain project has never been so easy with todays's tooling.

Though you've to keep in mind that some configuration is necessary, in this article I'll briefly cover 2 tools I use on an every day basis when I develop blockchain projects.

Foundry

Must have. Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Nideovim

A tool I made.
You can see it as an attempt to provide isolated and deterministic development environments for any kind of project.
It combines the power of several well-known technologies such as Linux, Docker and Neovim that are fuelled by an evergrowing community that get them more and more powerful.

I'll do a dedicated article on nideovim should you be interested (let me know in comments).

Setup before deployments

Let keep things simple.

  1. Clone the repository:
    • git clone https://github.com/MetaBarj0/Nifty.git
  2. Go to the contracts directory:
    • cd contracts
  3. Ensure the project can be deployed by running tests:
    • make test
    • everything should be green
  4. Edit the .env configuration file to allow deployement on the test network:
    • set the MAINNET_URL variable to a RPC endpoint of your chosing (I use alchemy as a node provider but any other can do)
    • set the SEPOLIA_URL variable using the same way as for the MAINNET_URL variable.
    • set the MAINNET_FORK_BLOCK to a valid block number for instance 23739277 but any valid block number is ok. You can get a valid block number of the homepage of etherscan
    • setup the PRIVATE_KEY variable using the private key of a wallet containing enough test ETH to deploy the contract. (NEVER EVER use a wallet containing other non test token, you should have a test wallet for these kind of purposes)
    • setup the ETHERSCAN_API_KEY to an etherscan API key you or your organization own (you can create one for free).

That's it for tedious configuration steps. The next part is the actual deployment.

Simply deploy

Only one command to rule the deployment:

  • make sepolia_deploy.

It will deploy the entire set of smart contract to sepolia that are:

  • The NFT (Nifty contract)
  • The crowd sale (Crowdsale contract)
  • a pair of proxies (TransparentUpgradeableProxy contract)
    • one for Nifty contract
    • one for the Crowdsale contract

This step can take few minutes to complete. Once it's successful, you should see something like All (4) contracts were verified!

Etherscan post deploy steps

As I said, 4 contracts have been deployed and 2 of them are proxies. The next things to do is to get the 2 proxies deployed contract addresses and tell to sepolia that those contract are proxies.

Getting the contract addresses

  1. Go to the broadcast deployment directory: cd broadcast/SepoliaDeploy.s.sol/11155111
  2. look into the run-latest.json file to get addresses of the 2 proxy contracts:
    • look for these 2 lines in the file : "contractName": "TransparentUpgradeableProxy"
    • get the 2 addresses in the field: contractAddress of the object you found.

Setup proxies

  • Go to sepolia etherscan
  • in the search bar, put one of the 2 addresses you got from run-latest.json file
  • go to the contract tab
  • sepolia etherscan should tell you this contract may be a proxy (and he's right)
  • then setup this contract as a proxy
    • at the right of the contract source code line there is a more options dropdown, click on it.
    • click on is this a proxy?
    • on the new page click on verify
    • once done you'll get notified the address of the implementation contract
    • click save and go back to the proxy contract page
    • repeat the same process for the other proxy

Deployment done

Once those steps are done, in the contract tab you can see 2 new buttons: read as proxy and write as proxy allowing you to interact with the proxy contract as if it were the underlying implementation contract (Nifty or Crowdsale).

Next steps

Now contracts have been deployed on a public test net, you can interact with them freely using any mean (RPC endpoint using a Node provider, Remix IDE, ...)

Play with deployed contracts

As an exercise left to the reader, make few transactions to deployed contracts using Remix.

I let you same addresses of a previous deployment I made here, should you have any issue deploying yourself:

  • Nifty at 0x4a6e3713ce9cc0b18de00e195a0d6ab4d09c2175
  • Crowdsale at 0xe51979cea418896991f17e7a432db652094d6271
  • Nifty proxy at 0xdb03331289ceae8ceb3ca9d3888c45d24e5b72a4
  • Crowdsale proxy at 0xc2c46f98946b5373b489542f07f42e1993020821

Conclusion

I hope this article has been clear enough and is relevant enough to prove you can deploy projects on test nets to ensure things are going well before deploying it to main net.

Let me know about your thoughts in comment.

Thanks

  • @christopherkade for it's banner generator
  • Brave Leo's AI to have helped me to build arguments chapter regarding why bother about deploying on test net
  • contributor to fantastic dev tools I use every day to build.
  • all the community for all invaluable resources I consume every day to be able to make something eventually useful

Top comments (0)