A simple Backend for Hereum app and ERC20 token interaction using Metmask wallet.
This installation guide is a continuation of the frontend. Please consider going there first.
First, go back to the root folder and once you're there, type this
user@me:~$ mkdir server && cd server
Now you're in the server directory.
You can initialize npm by
user@me:~$ npm init --y
Once npm is initialized you can now initialize a local git repo by
user@me:~$ git init
Boom! Done!
Now we have both npm and git initialized we can now clone this repo and install its dependencies.
First we have to clone this repo, kindly type
user@me:~$ git clone https://github.com/JoshMatthew/BACKEND-erc20-demo-Hereum.git
After that, we can now install our dependencies by doing
user@me:~$ npm i
Truffle is a framework for creating smart contracts.
user@me:~$ npm install truffle -g
Let's also install this guy globally and save it as a dev dependency by
user@me:~$ npm install nodemon -g -D
In this server, for this to be able to run, we need to create an account in infura and also mongodb.
Go to infura and create a new account. Once created, click the Ethereum button on the upper left of the window. After that, go and click the Create new project in the upper right, a modal with show that's waiting you to name your project. You can name it anything you want. Now you will be in the Project Details Window.
Look at the Endpoints section and choose Ropsten from the select input, then copy the https link below it. Now go to .env
file and paste your infura url there.
Go to mongodb and create a new account if you don't have yet. Once created, look at the top right and click on Create a new Cluster. Select the MO Sandbox from tiers and go the very bottom and change the cluster name to anything you want. Once created, click the connect after that, select Connect your application and click copy.
Copy that mongo uri and then paste it to the .env
file as well.
You also have to get your metamask public and private key by opening your metamask wallet and also paste that in the .env
file.
In your metamask wallet, kindly copy your public key and go to this website, paste your public key and click on Send me test Ether. Do not spam the button to avoid you from getting temporarily blocked.
Now your .env
file should be something like this
ADDRESS = "0x2573F143d3674D995C339Af3682Fc4cc29eb7882"
PRIVATE_KEY = "//YOUR PRIVATE KEY"
INFURA_URL = "https://ropsten.infura.io/v3/<API_KEY>"
DATABASE_URI = "Your MONGO URI"
Now in the server directory, type this in your command line
user@me:~$ truffle migrate --network ropsten --reset
If you did it all right, it should not give errors.
For the Play Peewpeew button to work, you also have to clone peewpeew anywhere in your machine.
user@me:~$ git clone https://github.com/JoshMatthew/PeewPeew.git
Then on docs/scripts/actions.js
line 84, change the url from the post request to http://localhost:8080/peewpeew/points_add
. To make it able to open on button click, copy its path and paste it on erc20demo/client/src/components/Home/Section1.js
line 36, in the url of window.open
method.