• Stars
    star
    229
  • Rank 174,666 (Top 4 %)
  • Language
    JavaScript
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Start building full stack dApps fast with this starter kit!

Starter Kits

An Polygon Starter Kit Tutorial containing React, @web3-react, Alchemy.

0. Environment Setup

Install fundamental environments, including node, web3, react, truffle, etc

\0. Environment Setup

Install Ganacheใ€Truffle

img

Use Starter Kits build your DAPP right away!

An Polygon Starter Kit Tutorial containing React, @web3-react, Alchemy.

Developer Docs - A Polygon Starter Kit tutorial from Alchemy

Install ganache

Download Package from https://www.trufflesuite.com/ganache

img

Ganache Screenshot


granache is needed for dapp development on local blockchain, its capable of viewing txns informations, create workspace folder, deploy smart contracts and tracking its interface.

Install truffle

npm install -g truffle 

truflle is used for develop, test, and deploy smart contracts.

More tutorials about truffle: https://learnblockchain.cn/docs/truffle/

\0. Environment Setup

Create your DAPP using Starter Kits Template

Quick Start

npx create-react-app {YOUR_PROJECT_NAME} --template polygon-starter-kit
cd {YOUR_PROJECT_NAME}
npm run start 

npm start

(npx comes from npm 5.2+ or later)

Then fireup your browser and go to http://localhost:3000/ to check your application.

When you are preparing to deploy your project to production settings, use npm run build to create a compressed bundle and deploy.

Immediate Configuration

There is no need for you to install or configurate tools like Webpack or Babel. They comes pre-configurated and hiddened, therefore you are provided with the full environment pack where you only need to worry about coding part.

Just create a project with the template, then you are good to go!

Create Application

You will need to use Node that is higher or equal to version 6 on your local computer(on server you don't have to). There is nvm(macOS/Linux) or nvm-windows to help you eaily switch between different Node versions.

Create a new application

npx create-react-app {YOUR_PROJECT_NAME} --template polygon-starter-kit

Then a new folder named {YOUR_PROJECT_NAME} will be created under current folder location. The File structures under this new folder is as below:

{YOUR_PROJECT_NAME}
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ node_modules
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ migrations 
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ public
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ manifest.json
โ””โ”€โ”€ src
	โ”œโ”€โ”€ App.css
	โ”œโ”€โ”€ App.js
	โ”œโ”€โ”€ App.test.js
	โ”œโ”€โ”€ assets
	โ”‚   โ”œโ”€โ”€ icon-devx.svg
	โ”‚   โ”œโ”€โ”€ logo512.png
	โ”‚   โ””โ”€โ”€ polygon-logo.svg
	โ”œโ”€โ”€ components
	โ”‚   โ”œโ”€โ”€ Contents
	โ”‚   โ”‚   โ””โ”€โ”€ index.js
	โ”‚   โ”œโ”€โ”€ Footer
	โ”‚   โ”‚   โ”œโ”€โ”€ footer.css
	โ”‚   โ”‚   โ””โ”€โ”€ index.js
	โ”‚   โ”œโ”€โ”€ Headers
	โ”‚   โ”‚   โ””โ”€โ”€ index.js
	โ”‚   โ””โ”€โ”€ Wallet
	โ”‚       โ”œโ”€โ”€ ConnectWallet.js
	โ”‚       โ””โ”€โ”€ WalletInfo.js
	โ”œโ”€โ”€ contracts
	โ”‚   โ””โ”€โ”€ Migrations.sol
	โ”œโ”€โ”€ hooks
	โ”‚   โ””โ”€โ”€ index.js
	โ”œโ”€โ”€ index.css
	โ”œโ”€โ”€ index.js
	โ”œโ”€โ”€ lib
	โ”‚   โ””โ”€โ”€ connectors
	โ”‚       โ””โ”€โ”€ index.js
	โ”œโ”€โ”€ reportWebVitals.js
	โ””โ”€โ”€ setupTests.js
โ””โ”€โ”€ truffle-config.js

\0. Environment Setup

Truffle Environment Configuration

truffle-config.js
const mnemonic = process.env.MNEMONIC;
const HDWalletProvider = require("@truffle/hdwallet-provider");


module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,     
      network_id: "*" // Match any network id
    },
    polygon: {
      provider: new HDWalletProvider(mnemonic, process.env.POLYGON_RPC),
      network_id: 137,
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: true
    },
    mumbai: {
      provider: new HDWalletProvider(mnemonic, process.env.POLYGON_MUMBAI_RPC),
      network_id: 80001,
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: true
    }

Create .env File under root folder

vim .env
MNEMONIC=" {YOUR_MNEMONIC OR YOUR_PRIVATE_KEY} "
POLYGON_RPC = " {PUBLIC_POLYGON_RPC} OR https://rpc-mainnet.matic.network"
POLYGON_MUMBAI_RPC = " {PUBLIC_POLYGON_MUMBAI_RPC} or https://rpc-mumbai.maticvigil.com/"

More about PUBLIC_RPC please reference on๏ผšDevelopment Docs

1.Project Structure

Polygon-Starter-Kit Project Template Introduction, and how to utilize different modules in it.

1.Project Structure

Project Structure

Polygon-Starter-Kit Project Structure is as below

{YOUR_PROJECT_NAME}
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ node_modules
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ migrations 
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ public
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ manifest.json
โ””โ”€โ”€ src
	โ”œโ”€โ”€ App.css
	โ”œโ”€โ”€ App.js
	โ”œโ”€โ”€ App.test.js
	โ”œโ”€โ”€ assets
	โ”‚   โ”œโ”€โ”€ icon-devx.svg
	โ”‚   โ”œโ”€โ”€ logo512.png
	โ”‚   โ””โ”€โ”€ polygon-logo.svg
	โ”œโ”€โ”€ components
	โ”‚   โ”œโ”€โ”€ Contents
	โ”‚   โ”‚   โ””โ”€โ”€ index.js
	โ”‚   โ”œโ”€โ”€ Footer
	โ”‚   โ”‚   โ”œโ”€โ”€ footer.css
	โ”‚   โ”‚   โ””โ”€โ”€ index.js
	โ”‚   โ”œโ”€โ”€ Headers
	โ”‚   โ”‚   โ””โ”€โ”€ index.js
	โ”‚   โ””โ”€โ”€ Wallet
	โ”‚       โ”œโ”€โ”€ ConnectWallet.js
	โ”‚       โ””โ”€โ”€ WalletInfo.js
	โ”œโ”€โ”€ contracts
	โ”‚   โ””โ”€โ”€ Migrations.sol
	โ”œโ”€โ”€ hooks
	โ”‚   โ””โ”€โ”€ index.js
	โ”œโ”€โ”€ index.css
	โ”œโ”€โ”€ index.js
	โ”œโ”€โ”€ lib
	โ”‚   โ””โ”€โ”€ connectors
	โ”‚       โ””โ”€โ”€ index.js
	โ”œโ”€โ”€ reportWebVitals.js
	โ””โ”€โ”€ setupTests.js
โ””โ”€โ”€ truffle-config.js
  • migrations is used to contain JS scripts for smart contract migration and deployment
  • src DAPP Client source code
  • src/contracts For containing smart contract๏ผŒand its also the contract location pointer in the truffle configuration
  • src/abis for containing abi files after Truffle Compilation
  • hooks/index.js initialize Providerโ€˜s request hook in @web3-react

More Repositories

1

Tutorial-nft-marketplace

Crypto Collectible NFT Tutorial with ERC-721 Tokens
JavaScript
48
star
2

Polygon-in-Chinese

All Polygon Chinese Materials Organized.
JavaScript
44
star
3

Polygon-Academy-Home

For the Polygon Developers, by the Polygon Developers!
38
star
4

basicnfts

Basic smart contract + frontend for deploying NFTs on Polygon
JavaScript
22
star
5

Web3GamingBootcamp_CN

Repo for Web3 Gaming Bootcamp hosted with ChainIDE and Denglian in 2021 Dec
Solidity
18
star
6

Tutorial-defi-tutorial

Solidity
13
star
7

Tutorial-ChainIDE

ChainIDE Polygon Tutorial
Solidity
11
star
8

Tutorial-DAO

An Example of DAO implementation, Built by Denglian Community
Solidity
11
star
9

Polygon-Cookbook

The Polygon Cookbook is a developer resource that provides the essential concepts and recipes for building applications on Polygon.
10
star
10

Decentralized-University

A repository for all universities to contribute and learn together.
10
star
11

nftmarketexample

JavaScript
6
star
12

crowdfund-starter

A crowdfunding starter dApp example
JavaScript
4
star
13

superfluid

a very simple integration with superfluid - a dashboard that allows you to set up / cancel payment streams via. superfluid SDK & mumbai token addresses.
JavaScript
4
star
14

svgnfts

JavaScript
4
star
15

Tutorial-subgraph-defi

subgraph for the defi-tutorial about LendingPool
TypeScript
2
star
16

oraclescaffold

JavaScript
2
star
17

aaveexample

JavaScript
2
star
18

lender-kit

A demo fork of Aave
JavaScript
1
star
19

developer-curations

1
star
20

zkBootCamp

A basic introduction to all things zero-knowledge-proofs.
1
star
21

starter-kit-typescript

A dApp starter kit, in Typescript
TypeScript
1
star
22

starter-kits-hardhat

Polygon Starter Kit for Hardhat users.
CSS
1
star