Deployment Process walk through
This project aims to become a tool for selling space on your website for advertisement purposes. Brands can buy Advertisement Space from your website.
Goal: the goal is to define a rotatory model for owning website space by advertisers.
- The website owner can generate Advertisement spaces in his/her website and put them for Sale
- Brands can buy Ad spaces and place their Advertisement in the Space that they have pruchased.
- Advertisement Spaces come in 3 different versions:
- Small: this is a small advertisement area, it costs 100 units of token
- Medium: this is a medium advertisement area, it costs 250 units of token
- Big: this is a big advertisement area, it costs 500 units of token
- An Ad will be represented as an struct with the followign parameters:
struct Ad { State state; Size size; bytes32 brand; address payable owner; uint256 price; }```
- State can be ForSale or Sold, and each Advertisement will have an owner. If the Ad is not already sol, the owner of the ad is the owner of the website.
- The website owner can take down existing ads.
- The website owner can also Pause or Resume the contract
Note: Further tokenomics must be defined, like how often the ownership can be changed (i.e. days / months) until a new auction is open again
- A life working version can be found at the Github page.
- Deployed address and network can be found at the txt file.
Design Patterns and Security Practices used in this project, for avoiding common attacks can be found on the corresponding files.
In the following console print you can see a high level overview of the project functionalities.
This export has been done using Surya capabilities, a tool developed by Consensys. You can install it by following their repo instructions and run the command:
surya ftrace APMRegistry::_newRepo all MyContract.sol
- Download or clone the repo
- Setup environment: create .env file (copy .env.safe) and include your Infura, mnemonic and EtherScan API
This is the example of the run of the following commands:
- Go to
contacts
folder:
cd contracts
- Compile contracts:
truffle compile
-
Start truffle development environment:
truffle dev
-
Migrate contracts on the desired network:
(truffle) migrate --reset --network develop
(truffle) migrate --reset --network rinkeby
(truffle) migrate --reset --network mainnet
(truffle) migrate --reset --network bsctestnet
(truffle) migrate --reset --network bsc
- Run Smart Contract Unit Tests:
truffle compile
It is possible to verify and publish the code of your contract(s), so anyone can audit it on the blockchain. If you implement this, people will be able to see all the code and interact with the contract on the Read/Write tabs.
For implementing this, after deploying to the network (testnet or mainnet) you can follow these steps:
- Install the dev dependency truffle-plugin-verify (already installed if you used the last package.json file)
- Include ETHERSCAN_API_KEY= for interacting with EtherScan
- Check plugin is added to the truffle-config file
- Run the following command on the terminal:
npx truffle run verify ContractName --network rinkeby
After some minutes, you should see this on your console:
This project is designed with the user interface in mind. For that, most of the functions of the smart contract trigger events. The events can be found on the Events tag of Etherscan.
For each network, if unspecified, transaction options will default to the following values:
- gas: Gas limit used for deploys. Default is 6721975.
- gasPrice: Gas price used for deploys. Default is 20000000000 (20 Gwei).
For checking the rela time gasPrice, go to Eth Gas Station and for converting Gwei to Wei check the Eth Unit Converter.
Deploying this contracted costed on Rinkeby:
- Go to
frontend
folder:
cd frontend
- Install the required dependencies
npm i
- Run the frontend client:
Smart Contracts:
- Truffle as development environment for compiling, depoying and testing the smart contracts
- Networks configured: Rinkeby, Develop, Binancechain, Binancetestnet and Develop
- Etherscan API is used for contract verification
Frontend:
- React
- Starter Setup based on Alchemy's NFT Minter tutorial for frontend design
- Metamask provider
Ethereum Account for Certification: 0x0297196d753045df822C67d23F9aB10c7128b102
- Choose Ad position by Priority (enum Position {Best, Medium, Worse}) depending on the visibility of the position
- Add more units tests to include test coverage
- Build this as a pluggable extension for any website
- Event indexing for a better UI/UX experience