Git Product home page Git Product logo

start2impact_solidity-project's Introduction

Start2Impact Solidity Project:
Echoes Of The Past

Description:

Prototype of a fantasy themed NFT marketplace.
This is a decentralized application through which NFTs can be minted and sold for the platform's token.
Minting and sale are managed by smart contracts, while the metadata are saved via the IPFS protocol.

Notes for use:

  • In order to interact with the dapp you must connect the Metamask wallet and select the Ropsten network, in addition you will need some Ethers ($rETH) to be able to pay the gas fees. You can get $rETH for free via a faucet. (Dimensions, Egorfine, Ropsten faucet)
  • You can get the platform token ($WISP) for free via this faucet.
  • The dapp recognizes only the NFTs of the TreasureNFT smart contract. You can mint them from the appropriate form in the "Den" section.

Disclaimer:

This project is for illustrative and educational purposes only, therefore some structural choices such as index sales management and the absence of a back-end or sub-graphs are not intended as definitive and suitable solutions for a real use case.

Docs: Project presentation slides
Live demo: Echoes Of The Past


Index

  1. User interface
    1. Welcome chest
    2. Den
    3. Merchant
    4. NFT detail
  2. Components and technologies
    1. Smart contracts
    2. Front-end
    3. Storage
  3. Deploy in production
    1. Setup
    2. IPFS
    3. Nginx
    4. Reboot
    5. Debugging

User interface

The interface is very similar to a common NFT marketplace but with a customized user experience. This means that the classic minting and trading operations are contextualized in a fantasy world, where NFTs are simple items to craft and the sale is brokered by a merchant.
To facilitate testing, there is a form to request some platform's tokens for free.

Welcome chest

/welcome-chest
This page is the equivalent of a faucet where you can request free tokens ($WISP) in order to interact with the platform without friction.

Den

/den
This page is similar to a profile page. The Den is divided into three sections:

  • Craft new items
    In this section you can mint new NFTs, the metadata will be saved via IPFS and associated with the token that is being minted.
  • Your items available
    Shown here are your NFTs that are not for sale and available for transfer or sale.
  • Your items for sale
    Shown here are your NFTs which are blocked by the Merchant smart contract for sale.

Merchant

/merchant
This is the main page, all NFTs for sale are listed here. By clicking on one of them you will be redirected to the dedicated page in order to see the detailed information of the selected NFT and possibly proceed with the purchase.

NFT detail

/merchant/<TOKEN_ID>
This page shows the complete details of the NFT, if it is yours you can decide to put it on sale or withdraw it if it is already, otherwise if it is not yours and it is for sale you can proceed with the purchase. In addition to these operations, you can consult the description and additional information such as the ID of the token, the standard and the address of the contract that issued it.


Components and technologies

Smart contracts

The dapp is made up of 4 main smart contracts:

  1. WispToken
    • Standard: ERC-20
    • Description: Token contract that keeps track of the token of the platform, made with Openzeppelin libraries.
  2. TreasureNFT
    • Standard: ERC-721
    • Description: NFT contract that keeps track and manage the NFTs of the platform, made with Openzeppelin libraries.
  3. WelcomeChest
    • Standard: None
    • Description: Faucet contract that transfers some $WISP from its account to the account provided.
  4. Merchant
    • Standard: None
    • Description: Contract that manages the sale of NFTs. Users can list NFTs by setting the price in WISP. Once the sales order is created, the smart contract blocks the NFT until the order is executed or canceled. If the order is executed the NFT for sale will be transferred to the buyer and the sum in WISP will be transferred to the seller.

Front-end

Storage

The server hosting the webapp also provide an IPFS node to allow users to upload and request metadata and resources quickly.
The node is publicly accessible at the following routes:

  • /api/v0/add - Resource upload
  • /ipfs - Resource request

Deploy in production

Setup

Clone the repository and install the required packages:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install net-tools nginx
$ git clone https://github.com/pogginicolo98/start2impact_solidity-project.git

IPFS

Download and init IPFS:

$ mkdir ipfs-node
ipfs-node$ wget https://dist.ipfs.io/go-ipfs/v0.12.0/go-ipfs_v0.12.0_linux-amd64.tar.gz
ipfs-node$ tar -xvzf go-ipfs_v0.12.0_linux-amd64.tar.gz
ipfs-node$ sudo bash go-ipfs/install.sh
$ ipfs init --profile server
$ sudo systemctl daemon-reload
$ sudo systemctl enable ipfs
$ sudo systemctl start ipfs
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
$ sudo systemctl restart ipfs

Check that the service is running correctly:

$ sudo systemctl status ipfs

Nginx

Configure Nginx to Proxy Pass to IPFS and serve the vue.js app. It helps to protect the website from attackers.
Update /etc/nginx/nginx.conf Nginx config file in order to upload large files (images in that case)

http{
	...
	client_max_body_size 100M; 
}

Open start2impact_solidity-project/setup/PROJECT_NAME and replace placeholders with production data.
Then add the website configuration:

start2impact_solidity-project$ sudo cp setup/PROJECT_NAME /etc/nginx/sites-available/echoes_of_the_past
$ sudo ln -s /etc/nginx/sites-available/echoes_of_the_past /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl restart nginx
$ sudo systemctl enable nginx

Check that the service is running correctly:

$ sudo systemctl status nginx

Reboot

If everythings is running correctly reboot the system and then the web-app should be available at the address of the server: $ sudo reboot

Debugging

List of commands useful for debugging possible errors:
$ sudo journalctl -u <service>: Service logs
$ sudo systemctl status <service>: Service status

Services

  • ipfs
  • nginx

start2impact_solidity-project's People

Contributors

pogginicolo98 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

wizadr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.