Skip to content

The goal of this project is creating an app through which gas buyers can join a promotion of a specific gas station. After joining this promotion, customers earn points/tokens when buying gas. These points/tokens are stored in ITFS network Infura and can be exchanged for NFTs - “Oil stains” or donated. Gas station owner administrates the promoti…

License

Notifications You must be signed in to change notification settings

VladislavGlupak/Gas-Promotion-Smart-Contract

Repository files navigation

Contributors Forks Stargazers

Main

Gas-Promotion-Smart-Contract

This project repository represents a pay-to-earn promotion where a gas station owner can offer their customers rewards through gasoline purchases. Rewards can be accumulated, exchanged for unique NFT art ("Oil stains”), or donated to a non-profit of their choice. The NFT’s are kept in the IPFS network - Infura. The administrator manages the promotion and the customer decides how to use their rewards.


Table of Contents


Technologies and tools

This project leverages the following tools, API and libraries:

  • Solidity ^0.6.6 - programming language for implementing smart contracts.

  • Remix IDE - Remix IDE allows developing, deploying and administering smart contracts for Ethereum like blockchains.

  • Ganache - a personal Ethereum blockchain.

  • Metamask - is a software cryptocurrency wallet.

  • Infura - IPFS Api - an IPFS network.

  • Streamlit - is an open-source app framework for Machine Learning and Data Science teams.

  • Web3.py - is a Python library for interacting with Ethereum.

  • OpenZepplelin - ERC721 - set of interfaces, contracts, and utilities are all related to the ERC721 Non-Fungible Token Standard.

OpenZeppelin libraries:

ERC721 token:

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.0.0/contracts/token/ERC721/ERC721.sol"

App flows

Simple:

Simple Flows

Detailed:

Flows


Project structure

contracts/GasPromo.sol           - smart contract
contracts/compiled/compiled.json - ABI
Pictures                         - different pictures
infura.py                        - Infura API IPFS
random_pic.py                    - script for generating pictures
app.py                           - the main application that connects all the components together
SAMPLE.env                       - file contains description of important variables
LICENSE                          - MIT license
run.sh                           - bash script for running app

Installation

  1. Download and install Metamask crypto wallet.

  2. Download and install Ganache.

  3. Configure the Ganache network in the Metamask.

    Network name: Ganache
    RPC: http://127.0.0.1:7545
    Chain ID: 1337
    Currency symbol: ETH
    
  4. Import any account to the Metamask from the Ganache.

  5. Copy smart contract (contracts/GasPromo.sol) to the Remix IDE.

  6. Compile (compiler 0.6.12), select Injected Web3 as an environment and deploy the smart contract (confirm with the Metamask) to the Ganache network.

Deploy

  1. Fill out the SAMPLE.env:

    • provide Infura secret keys (you need to be registered here https://infura.io);

    • provide address of the deployed smart contract.

    INFURA_PROJECT_ID=<your infura project id>
    INFURA_PROJECT_SECRET=<your infura project secret key>
    WEB3_PROVIDER_URI=http://127.0.0.1:7545
    SMART_CONTRACT_ADDRESS=<deployed smart contract>
    
  2. Install Streamlit pip install streamlit.

  3. Install pip install randimage

  4. Run ./run.sh


Demonstration of functionality

1 Switch account to contract owner

Account

2 Stop promotion

Stop

3 Mint bonus points

Mint

4 Set exchange rates for gas types

SetRates

5 Set exchange rate for NFT

SetRates

6 Run promotion (refer to step 2)

7 Switch account to any other account and join the promotion

Join

8 Buy no less than 5 gallons of any gas

Join

9 Try to donate

Join

10 Mint NFT (Pls, be aware that you should have enougth balance. Pls refer to step 5)

Join

11 Check your NFT collection

Join


Troubleshooting

AttributeError: module ‘click’ has no attribute ‘get_os_args’

Please install:

pip install -U click==8


Contributors

Glupak Vladislav Linkedin

Magdalena Švimberská Linkedin

Thomas Brierton Linkedin

Siddharth Venkumahanti Linkedin

License

License: MIT

About

The goal of this project is creating an app through which gas buyers can join a promotion of a specific gas station. After joining this promotion, customers earn points/tokens when buying gas. These points/tokens are stored in ITFS network Infura and can be exchanged for NFTs - “Oil stains” or donated. Gas station owner administrates the promoti…

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages