Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zorixid committed May 19, 2021
0 parents commit f4a3aa4
Show file tree
Hide file tree
Showing 15 changed files with 21,962 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "stage-2", "stage-3"]
}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
5 changes: 5 additions & 0 deletions migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
deployer.deploy(Migrations);
};
21,655 changes: 21,655 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "token-staking-dapp",
"version": "0.0.1",
"description": "Yield Farming / Token Staking dApp",
"author": "Justinas Kairys",
"dependencies": {
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-2": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"babel-register": "6.26.0",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"chai-bignumber": "3.0.0",
"react": "16.8.4",
"react-dom": "16.8.4",
"react-scripts": "2.1.3",
"truffle": "5.1.39",
"web3": "1.2.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"main": "truffle-config.js",
"license": "ISC"
}
Binary file added public/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Yield Farming / Token Staking dApp</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Starter Kit",
"name": "Dapp Token Farm",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
22 changes: 22 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { useState } from 'react';
import classes from './App.module.css';

const App = () => {
const [account, setAccount] = useState('0x0');


return (
<div className={classes.Grid}>
<div className={classes.Child}>
<h1>Yield Farming / Token Staking dApp</h1>
<p>account from Metamask: {account}</p>
<div>
<button className={classes.stakeButton}>Stake</button>&nbsp;
<button className={classes.unstakeButton}>Unstake</button>
</div>
</div>
</div>
);
};

export default App;
42 changes: 42 additions & 0 deletions src/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.Grid {
display: grid;
grid-gap: 1px;
grid-template-columns: 30em 50em 30em;
grid-template-rows: 10em auto 30em;

height: 99em;
}

.Child {
background: rgb(16, 46, 86);
background: linear-gradient(
16deg,
rgb(10, 33, 63) 0%,
rgb(13, 45, 88) 42%,
rgb(8, 45, 95) 100%
);
border: rgb(13, 27, 66) solid 0.5em;
border-radius: 2.5em;
grid-column: 2;
grid-row: 2;
text-align: center;
color: white;
}

.stakeButton {
background-color: #3084e4;
color: white;
border: none;
border-radius: 0.5em;
height: 3em;
width: 7em;
}

.unstakeButton {
background-color: #224374;
color: white;
border: none;
border-radius: 0.5em;
height: 3em;
width: 7em;
}
51 changes: 51 additions & 0 deletions src/contracts/ERC20Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
pragma solidity ^0.5.0;

contract ERC20Token {
string public name = "ERC20Token";
string public symbol = "E2T";
uint256 public totalSupply = 1000000000000000000000000; // 1 million tokens
uint8 public decimals = 18;

event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);

event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);

mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

constructor() public {
balanceOf[msg.sender] = totalSupply;
}

function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}

function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
}
23 changes: 23 additions & 0 deletions src/contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pragma solidity >=0.4.21 <0.6.0;

contract Migrations {
address public owner;
uint public last_completed_migration;

constructor() public {
owner = msg.sender;
}

modifier restricted() {
if (msg.sender == owner) _;
}

function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
13 changes: 13 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* {
box-sizing: border-box;
}

html {
font-family: sans-serif;
}

body {
margin: 0;
background-color: #061121;
color: white;
}
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';

ReactDOM.render(<App />, document.getElementById('root'));
23 changes: 23 additions & 0 deletions truffle-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require('babel-register');
require('babel-polyfill');

module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
},
contracts_directory: './src/contracts/',
contracts_build_directory: './src/abis/',
compilers: {
solc: {
optimizer: {
enabled: true,
runs: 200
},
evmVersion: "petersburg"
}
}
}

0 comments on commit f4a3aa4

Please sign in to comment.