PART 2: OminiSwap Project Setup

Johnson awah Alfred's photo
Johnson awah Alfred
ยทApr 5, 2022ยท

3 min read

Subscribe to my newsletter and never miss my upcoming articles

In a previous article which can be found here, we talked about this awesome project to be built. I asked a few questions concerning the project, one of which was "What shall we name our token?" From the look of things, we've got a name already.

Throughout this series, we would call our app OminiSwap, yunno.. like Uniswap. The reason behind this name is that, I've considered introducing an additional blockchain, you'll get to know about this new chain later on in this course. So there we have it, let the party begin already!!!!

Smart Contract Framework

For building and deploying the necessary contracts, I decided we make use of hardhat framework for this. So feel free to head over to their official website to see what they've got cooking. The reason behind hardhat over of course truffle is that hardhat features a better debugging experience, nothing else. For example, hardhat offers a "console.log" feature, this is useful to print out messages while you run or compile your contracts. It's as simple as importing the console package and just using console.log anywhere in the contract.


pragma solidity ^0.6.0;

import "hardhat/console.sol";

contract Token {
 function transfer(address to, uint256 amount) external {
    console.log("Sender balance is %s tokens", balances[msg.sender]);
    console.log("Trying to send %s tokens to %s", amount, to);

    require(balances[msg.sender] >= amount, "Not enough tokens");

    balances[msg.sender] -= amount;
    balances[to] += amount;
}
}

Front End Development

You know this already, we are taking the react route to building out a public-facing user interface. In it would be some starter files from the ethereum-boilerplate. Currently, It has this swap functionality that uses some cool library, but that's not our goal. We want to write the smart contract ourselves and see how the thing goes.

Some heads Up

In as much as I'll try my very best to actually explain something that I feel would be confusing, I'll advise every beginner out there to just get some solidity superpowers from this Resource. One last thing, I'm not gonna be teaching javascript or react here, but I'll explain stuff I think could be complicated ( doubt if any would rise though).

Starter Files

Head over to github and clone the repo where our contracts would live. It contains a fruit of the spirit, the sword of solidity (hardhat framework), and over here holds the breast blate of javascript ( react project).

Set-Up

Just take your time and look through the READMEfiles for each project. For our contract project here are a few things you could do to make me happy. Run the following commands after you've gone through the whole process on the README file.

npx hardhat compile

Compiles all .sol files found inside the contracts folder.

npx hardhat test

Runs any available test suite, which can be found inside the test folder.

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

Deploys your contracts to the rinkeby network

ย 
Share this