Back to Blog
·15 min

Ethereum Smart Contract Development: From Solidity to Production dApp

Smart contracts are the foundation of decentralized applications on Ethereum.

Setting Up Your Development Environment

npx hardhat init
npm install @nomicfoundation/hardhat-toolbox ethers

Writing a Marketplace Contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import '@openzeppelin/contracts/access/AccessControl.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';

contract Marketplace is AccessControl, ReentrancyGuard {
    struct Listing { address seller; uint256 price; bool active; }
    uint256 private listingCounter;
    mapping(uint256 => Listing) public listings;

    function createListing(uint256 price) external returns (uint256) {
        listingCounter++;
        listings[listingCounter] = Listing(msg.sender, price, true);
        return listingCounter;
    }

    function buyListing(uint256 id) external payable nonReentrant {
        Listing storage l = listings[id];
        require(l.active && msg.value == l.price);
        l.active = false;
        payable(l.seller).transfer(msg.value);
    }
}

Testing with Hardhat

import { expect } from 'chai'
import { ethers } from 'hardhat'

describe('Marketplace', function () {
  it('Should create a listing', async function () {
    const Factory = await ethers.getContractFactory('Marketplace')
    const marketplace = await Factory.deploy()
    await marketplace.createListing(ethers.parseEther('1.0'))
    const listing = await marketplace.listings(1)
    expect(listing.price).to.equal(ethers.parseEther('1.0'))
  })
})

Frontend Integration with wagmi

Connect your contract to Next.js using wagmi hooks for read/write operations and RainbowKit for wallet connection.

The Bottom Line

The Dapp Starter Kit from BreafIO provides a complete frontend with wallet connection and contract hooks. The NFT Marketplace Pro includes marketplace integration. The DAO Governance App provides governance patterns. The Blockchain Explorer tracks on-chain data, and the Web3 Auth Kit handles authentication.

Ready to Build?

Get started with our production-ready starter kits and ship your project faster.

Browse Starter Kits