Giter VIP home page Giter VIP logo

solidity-simple-store's Introduction

Getting Started

Develop simple store:

  • The administrator (owner) of the store should be able to add new products and the quantity of them.
  • The administrator should not be able to add the same product twice, just quantity.
  • Buyers (clients) should be able to see the available products and buy them by their id.
  • Buyers should be able to return products if they are not satisfied (within a certain period in blocktime: 100 blocks).
  • A client cannot buy the same product more than one time.
  • The clients should not be able to buy a product more times than the quantity in the store unless a product is returned or added by the administrator (owner)
  • Everyone should be able to see the addresses of all clients that have ever bought a given product.

Requirements

Quickstart

git clone https://github.com/Nedick/solidity-simple-store.git
cd solidity-simple-store
yarn

Usage

Deploy

yarn hardhat deploy

Test Coverage

yarn hardhat coverage

Testing

yarn hardhat test

Linting

To check linting / code formatting:

yarn lint

or, to fix:

yarn lint:fix

Deployment to a testnet or mainnet

  1. Setup environment variabltes

You'll want to set your RINKEBY_RPC_URL and PRIVATE_KEY as environment variables.

  • PRIVATE_KEY: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.
  • RINKEBY_RPC_URL: This is url of the rinkeby testnet node you're working with. You can get setup with one for free from Alchemy
  1. Get testnet ETH

Head over to faucets.chain.link and get some tesnet ETH & LINK. You should see the ETH and LINK show up in your metamask. You can read more on setting up your wallet with LINK.

Then run:

yarn hardhat deploy --network rinkeby --tags all

Estimate gas cost in USD

To get a USD estimation of gas cost, you'll need a COINMARKETCAP_API_KEY environment variable. You can get one for free from CoinMarketCap.

Then, uncomment the line coinmarketcap: COINMARKETCAP_API_KEY, in hardhat.config.js and set REPORT_GAS environment variable to get the USD estimation. Just note, everytime you run your tests it will use an API call, so it might make sense to have using coinmarketcap disabled until you need it. You can disable it by just commenting the line back out.

Verify on etherscan

If you deploy to a testnet or mainnet, you can verify it if you get an API Key from Etherscan and set it as an environemnt variable named ETHERSCAN_API_KEY. You can pop it into your .env file.

In it's current state, if you have your api key set, it will auto verify rinkeby contracts!

However, you can manual verify with:

yarn hardhat verify --constructor-args arguments.ts DEPLOYED_CONTRACT_ADDRESS

TODO:

  • Add unit tests for contracts
  • Add scripts for contract interaction on local or test network
  • Refactor the code to reduce gas costs and clean up the bugs
  • Find out how to use Multicall contract in the context of the task
  • Deploy contracts on actual test network like Rinkeby
  • Add user friendly front-end using ethers.js and next.js ?

solidity-simple-store's People

Contributors

nedick avatar

Watchers

 avatar

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.