paint-brush
Deploying Your Smart Contract on Ethereum’s Sepolia Testnet using Remix | dApp Development Series by@lumoslabshq
9,340 reads
9,340 reads

Deploying Your Smart Contract on Ethereum’s Sepolia Testnet using Remix | dApp Development Series

by Lumos LabsJune 1st, 2023
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Web3 development is here to stay. If the number of smart contracts deployed on the Ethereum Mainnet is any indication, this spurt in growth since 2021 is only set to continue. This growth in terms of numbers stands at an astonishing 293% between 2021 and 2022. If that’s not enough, the Goerli Testnet has seen a substantial increase in the deployment of smart contract by 721% annually.
featured image - Deploying Your Smart Contract on Ethereum’s Sepolia Testnet using Remix | dApp Development Series
Lumos Labs HackerNoon profile picture

Web3 development is here to stay! If the number of smart contracts deployed on the Ethereum Mainnet is any indication, this spurt in growth since 2021 is only set to continue.

Speaking of which, this growth in terms of numbers stands at an . If that’s not enough, the Goerli Testnet has seen a substantial increase in the deployment of smart contracts by 721% annually. 
All of this has occurred despite the decline of crypto, in particular, when the FTX collapse took place. What this translates to is that there’s room for more Web3 developers to hone their skills and add to that growing list of smart contracts deployed. So, let’s dive into how these smart contracts are deployed on the Ethereum Testnet first, using Sepolia. But before that, let’s understand what an Ethereum Testnet is and how one can use it by procuring some Testnet Ether. 

An Introduction to the Ethereum Testnet

As mentioned in an earlier blog post, a public Testnet is an environment in which developers can test their smart contracts with test tokens like Ether or MATIC. This is well before they deploy the smart contract to the Mainnet, so that they can iron out all the kinks in advance. Much like developers in any other Technology domain who test their software prior to deployment in a production environment. Now, this is important to do because once the contract is deployed, no changes can be made.
So, if there are any bugs, making changes to the code will not be possible.
However, given how closely the Testnet simulates its real-world counterpart, debugging and refactoring your code is possible until you get it absolutely right. Still, no smart contract is 100% bug-free, so while perfection is desirable, it isn’t necessarily attainable.
Which brings us to the Ethereum Testnet: one can safely say that there are a few that have come and gone. Ropstein, Kovan and Rinkeby are now deemed deprecated along with Goerli that will operate for a few more months. As of 2023, the Sepolia Testnet is considered to be the right network to use in order to handle application development. But for us to be able to use the Sepolia Testnet, we need test Ether to pay gas fees. One must remember that the Sepolia Testnet has its own test Ether that one must procure from a faucet. For example, a faucet with respect to Testnet Ether is a website where you can request for test Ether, which would be Sepolia test Ether in this case.

Steps to Obtain Sepolia Testnet Ether

Now, there are several ways to obtain Testnet Ether for Sepolia and which includes visiting designated faucets that will send Sepolia Ether to your account.Assuming that you already have an Ethereum address linked to a wallet like Metamask, the simplest one involves navigating to this that allows you to mine for Sepolia Ether. Once you paste your Ethereum address and complete the “I’m not a robot” reCaptcha, select ‘Start Mining’. As you can see, the longer you mine for Sepolia Ether, the more you can collect.
After you’ve gathered enough Sepolia Ether, select the ‘Stop Mining & Claim Rewards’ option. 
Finally, check your wallet after 10-20 seconds to see if you’ve received Sepolia Ether. If you haven’t, then check your Ethereum wallet details and start all over again. 
If you have sufficient test Ether, then it’s time to deploy the Donut Vending Machine Solidity Smart Contract to the Sepolia Testnet.

Deploying the Donut Vending Machine Solidity Smart Contract

Now, in order to understand how smart contract deployment works, we need to use the Remix Integrated Development Environment but use a smart contract whose implementation is easily understandable.For this purpose, we’ve selected the Donut Vending Machine Solidity Smart Contract available at this . Once you copy the smart contract code, add it to a new .sol file in Remix and compile the contract until you see the green tick mark as part of the Solidity Compiler icon.


With that out of the way, it’s time to deploy the smart contract using the Sepolia Testnet Ether that you obtained. For this, you select the “Deploy & Run Transactions” icon as shown below:
After you’ve completed that step, you should find the Deploy & Run Transactions section
Select Injected Provider - Metamask from the drop-menu under Environment and unlock your Metamask wallet with your password
Select Deploy and pay the stipulated gas fees by hitting Confirm when your Metamask wallet opens up.
Open your deployed smart contract in the Deployed Contracts section
Lastly, if you want to purchase 2 donuts for 1 Ether, make sure you update the “Value” section with 1 Ether, add 2 in the Purchase method text box and hit the red ‘Purchase’ button
Yet again, you will have to confirm the purchase being made by approving the transaction in your Metamask wallet
You should receive confirmation that the purchase went through with the updated contract balance!
That said, you can also take a count of the number of donuts by invoking the getBalance function, as shown below:
With the initial number of donuts being 100, that number is now reduced to 98 after the purchase went through!Now, it must be mentioned that experienced developers use Hardhat and Truffle but that’s a discussion for another day.

How to Use EtherScan to Confirm the Smart Contract’s Deployment on Sepolia

With the Donut Vending Machine smart contract allowing customer purchases, you might want to keep track of the transactions being made using your smart contract. A tool that we discussed earlier comes to mind: EtherScan.
In order to use EtherScan for Sepolia Testnet transactions, we need to navigate to and paste the address of the smart contract that can be found in the Deployed Contracts section in Remix.
At first glance, this is how the Donut Vending Machine smart contract looks on EtherScan
If you haven’t noticed, the very first transaction in the list is defined as Contract Creation. Once a purchase is made through the method shown above, the Purchase transaction gets updated on EtherScan

That said, the smart contract now has a balance of 1 ETH for the purchase of 2 donuts made too.

We’re done!For the next blog post, we’ll demonstrate how customers can interact with your smart contract by building a basic webpage with the necessary UI components.That said, we’re also building - a Web3 education platform dedicated to teaching you blockchain development concepts with comprehensive curriculums.
Take a look and get ahead of the learning curve:
바카라사이트 바카라사이트 온라인바카라