AI Agent OSGuarded mainnet beta. .rama identity, smart wallets, sponsored gas, permissions and scheduling are available for controlled testing.Open Agent OS
Back to Blog
Tutorial
December 8, 2024
12 min read

Building Your First dApp on Ramestta

Dev Relations
Ramestta Team Member
Building Your First dApp on Ramestta

Building Your First dApp on Ramestta


Ready to build on Ramestta? This comprehensive tutorial will guide you through deploying your first decentralized application on our Layer 3 network.


Prerequisites


Before we begin, make sure you have:

  • Node.js (v16 or higher)
  • MetaMask browser extension
  • Basic knowledge of Solidity
  • Familiarity with JavaScript/TypeScript

  • Step 1: Set Up Your Development Environment


    Install Hardhat

    npm install --save-dev hardhat

    npx hardhat init


    Configure Ramestta Network

    Add Ramestta to your `hardhat.config.js`:


    module.exports = {

    networks: {

    ramestta: {

    url: "https://blockchain.ramestta.com",

    chainId: 1370,

    accounts: [process.env.PRIVATE_KEY]

    }

    },

    solidity: "0.8.20"

    };


    Step 2: Write Your Smart Contract


    Create a simple token contract:


    // SPDX-License-Identifier: MIT

    pragma solidity ^0.8.20;


    import "@openzeppelin/contracts/token/ERC20/ERC20.sol";


    contract MyToken is ERC20 {

    constructor() ERC20("MyToken", "MTK") {

    _mint(msg.sender, 1000000 * 10 ** decimals());

    }

    }


    Step 3: Compile Your Contract


    npx hardhat compile


    Step 4: Deploy to Ramestta


    Create a deployment script:


    async function main() {

    const MyToken = await ethers.getContractFactory("MyToken");

    const token = await MyToken.deploy();

    await token.deployed();


    console.log("Token deployed to:", token.address);

    }


    main()

    .then(() => process.exit(0))

    .catch((error) => {

    console.error(error);

    process.exit(1);

    });


    Deploy:

    npx hardhat run scripts/deploy.js --network ramestta


    Step 5: Build Your Frontend


    Create a React frontend to interact with your contract:


    import { ethers } from 'ethers';


    const connectWallet = async () => {

    const provider = new ethers.providers.Web3Provider(window.ethereum);

    await provider.send("eth_requestAccounts", []);

    const signer = provider.getSigner();

    return signer;

    };


    const getTokenBalance = async (tokenAddress, userAddress) => {

    const signer = await connectWallet();

    const tokenContract = new ethers.Contract(

    tokenAddress,

    ['function balanceOf(address) view returns (uint256)'],

    signer

    );

    const balance = await tokenContract.balanceOf(userAddress);

    return ethers.utils.formatEther(balance);

    };


    Step 6: Test Your dApp


    1. Add Ramestta network to MetaMask

    2. Get test tokens from the faucet

    3. Connect your wallet

    4. Test contract interactions


    Best Practices


    Gas Optimization

  • Use `calldata` instead of `memory` for function parameters
  • Batch transactions when possible
  • Cache storage variables in memory

  • Security

  • Always validate user inputs
  • Use OpenZeppelin contracts
  • Implement proper access controls
  • Test thoroughly before mainnet deployment

  • Performance

  • Minimize on-chain storage
  • Use events for off-chain data
  • Optimize contract size

  • Advanced Features


    Once you're comfortable with the basics, explore:

  • Multi-signature wallets
  • Token staking mechanisms
  • Decentralized governance
  • Cross-chain bridging
  • NFT marketplaces

  • Debugging Tips


    Common Issues

  • **Transaction fails**: Check gas limits and token approvals
  • **Contract not found**: Verify deployment and network configuration
  • **Metamask errors**: Ensure correct network and sufficient balance

  • Useful Tools

  • Ramascan: Block explorer for transaction verification
  • Hardhat Console: Interactive contract testing
  • Tenderly: Transaction simulation and debugging

  • Conclusion


    Congratulations! You've deployed your first dApp on Ramestta. With sub-2 second finality and micro-fees, your users will experience lightning-fast transactions at minimal cost.


    Next Steps:

  • Join our [Developer Community](https://t.me/ramestta_dev)
  • Explore our [API Documentation](/developers)
  • Check out [Sample Projects](https://github.com/Ramestta-Blockchain)

  • Happy building! 🚀


    TutorialDevelopmentSmart ContractsdApp

    Share this article

    Explore More

    Discover more insights, tutorials, and updates from the Ramestta ecosystem.

    View All Articles