Skip to content

Commit f690ea1

Browse files
committed
current to July 20 2021
1 parent 641c6d4 commit f690ea1

File tree

10 files changed

+139
-15
lines changed

10 files changed

+139
-15
lines changed

04-my_token/contracts/my_token.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pragma solidity ^0.8.0;
44
import "OpenZeppelin/[email protected]/contracts/token/ERC20/ERC20.sol";
55

66

7-
contract DanielToken is ERC20 {
8-
constructor(uint256 initialSupply) ERC20("Daniel", "Dan") {
7+
contract TheFellowShip is ERC20 {
8+
constructor(uint256 initialSupply) ERC20("LordOFTheRings", "Tolkien") {
99
_mint(msg.sender, initialSupply);
1010
}
1111
}

09_guess_number_vrf/needed_data.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ABI=[{"inputs": [{"internalType": "address", "name": "vrfCoordinator", "type": "address"}, {"internalType": "address", "name": "link", "type": "address"}, {"internalType": "bytes32", "name": "keyHash", "type": "bytes32"}, {"internalType": "uint256", "name": "fee", "type": "uint256"}], "stateMutability": "nonpayable", "type": "constructor", "name": "constructor"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "bytes32", "name": "requestId", "type": "bytes32"}, {"indexed": true, "internalType": "uint256", "name": "roller", "type": "uint256"}], "name": "Dice_rolled", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "owner", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "game_index", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "time", "type": "uint256"}], "name": "Game_created", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "creator", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "game_index", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "time", "type": "uint256"}], "name": "Game_expired", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "bytes32", "name": "requestId", "type": "bytes32"}, {"indexed": true, "internalType": "uint256", "name": "game_id", "type": "uint256"}], "name": "Game_served", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "solver", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "game_index", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "time", "type": "uint256"}], "name": "Game_solved", "type": "event"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}], "name": "cancelGame", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "create_game", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "payable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}], "name": "get_game_balance", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}], "name": "get_game_guesses", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}], "name": "get_game_number_test", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}], "name": "is_game_active", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}, {"internalType": "uint256", "name": "guessed_number", "type": "uint256"}], "name": "play_game", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "payable", "type": "function"}, {"inputs": [{"internalType": "bytes32", "name": "requestId", "type": "bytes32"}, {"internalType": "uint256", "name": "randomness", "type": "uint256"}], "name": "rawFulfillRandomness", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "game_id", "type": "uint256"}, {"internalType": "uint256", "name": "seed", "type": "uint256"}], "name": "rollDice", "outputs": [{"internalType": "bytes32", "name": "requestId", "type": "bytes32"}], "stateMutability": "nonpayable", "type": "function"}]
2+
ADDRESS=0x1DDFeFBe4ff5EE5261c2a77B026e7dcD7172676c
3+
TOPIC= Game_created(address, uint256, uint256)

10_Flask_Dapp/static/js/logic.js

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

10_Flask_Dapp/views.py

-8
This file was deleted.

11_Eth_US_dApp/Readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# README
2+
1. For this project you need flask.
3+
2. From your virtual environment run pip install flask
4+
3. Done

11_Eth_US_dApp/app.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import Flask, render_template
2+
3+
app = Flask(__name__)
4+
5+
@app.route('/')
6+
def index():
7+
return render_template("index.html")
8+
9+
if __name__ == "__main__":
10+
app.run()

11_Eth_US_dApp/run.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from app import app
2+
3+
if __name__ == "__main__":
4+
app.run()

11_Eth_US_dApp/static/js/logic.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//initializing Moralis
2+
Moralis.initialize(""); // Application id from moralis.io
3+
Moralis.serverURL = ""; //Server url from moralis.io
4+
5+
/*Creating a contract object
6+
This is a sample contract found in the 05_chainlink_moralis brownie project discussed in the following video https://youtu.be/s79cWDT1oaY, feel free to deploy your own to have a more realistic feel of the project*/
7+
window.web3 = new Web3(window.ethereum);
8+
const Price_ETHAbi = [{"inputs": [], "stateMutability": "nonpayable", "type": "constructor", "name": "constructor"}, {"inputs": [], "name": "getThePrice", "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], "stateMutability": "view", "type": "function"}];
9+
const PriceETH = new window.web3.eth.Contract(Price_ETHAbi,'0xF6c976a00d85c675f7ec730E48c3cae3bE161AB7');
10+
11+
//dApp frontend logic
12+
async function convertEth(){
13+
PriceETH.methods.getThePrice().call().then(convert_populate);
14+
}
15+
16+
function convert_populate(_value){
17+
const amountEth = document.getElementById('amountEth').value
18+
const result = (_value*amountEth)/(10**8);
19+
document.getElementById("amountUSD").setAttribute("value", result);
20+
}
21+
22+
async function login(){
23+
document.getElementById('submit').setAttribute("disabled", null);
24+
document.getElementById('username').setAttribute("disabled", null);
25+
document.getElementById('useremail').setAttribute("disabled", null);
26+
Moralis.Web3.authenticate().then(function (user) {
27+
user.set("name",document.getElementById('username').value);
28+
user.set("email",document.getElementById('useremail').value);
29+
user.save();
30+
document.getElementById("amountEth").removeAttribute("disabled");
31+
document.getElementById("convert").removeAttribute("disabled");
32+
})
33+
}

11_Eth_US_dApp/templates/index.html

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% extends "templates/base_template.html" %}
2+
{% block title %}Your Dapp{% endblock %}
3+
{% block head%}
4+
{% endblock %}
5+
{% block main %}
6+
7+
<div class="container">
8+
<div class="row">
9+
<div class="col">
10+
<h1>Connect to Convert</h1>
11+
<hr>
12+
<div class="mb-3">
13+
<div class="form-group">
14+
<div class="input-group mb-3">
15+
<input id="username" type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
16+
</div>
17+
<div class="input-group mb-3">
18+
<input id="useremail" type="text" class="form-control" placeholder="Email" aria-label="Email" aria-describedby="basic-addon1">
19+
</div>
20+
</div>
21+
<div>
22+
<button class="btn btn-primary" id="submit" onclick="login();">Connect MetaMask</button>
23+
</div>
24+
<hr>
25+
<div class="form-group">
26+
<div class="input-group mb-3">
27+
<input disabled = "true" id="amountEth" type="text" class="form-control" placeholder="Input Amount ETH" aria-label="Amount ETH" aria-describedby="basic-addon1">
28+
</div>
29+
<div>
30+
<button disabled = "true" class="btn btn-primary" id="convert" onclick="convertEth();">Convert</button>
31+
</div>
32+
<hr>
33+
<div class="input-group mb-3">
34+
<input disabled = "true" id="amountUSD" type="text" class="form-control" placeholder="Amount USD" aria-label="Amount USD" aria-describedby="basic-addon1">
35+
</div>
36+
</div>
37+
</div>
38+
</div>
39+
</div>
40+
</div>
41+
42+
{% endblock %}
43+
{% block script %}
44+
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
45+
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
46+
<script src="{{ url_for('static', filename='js/logic.js') }}"></script>
47+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<!--Head Content-->
5+
<title>{% block title %}{% endblock %}</title>
6+
<!-- Required meta tags -->
7+
<meta charset="UTF-8">
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
{% block links %}
10+
<!-- Import the Bootstrap stylesheet -->
11+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
12+
{% endblock %}
13+
</head>
14+
<body>
15+
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-3">
16+
<a class="navbar-brand" href="/">Home</a>
17+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
18+
<span class="navbar-toggler-icon"></span>
19+
</button>
20+
</nav>
21+
<main>
22+
{% block main %}{% endblock %}
23+
</main>
24+
{% block script %}
25+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
26+
{% endblock %}
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)