This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
519 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
html { | ||
font-size: 14px; | ||
} | ||
@media (min-width: 768px) { | ||
html { | ||
font-size: 16px; | ||
} | ||
} | ||
|
||
.container { | ||
max-width: 960px; | ||
} | ||
|
||
.pricing-header { | ||
max-width: 700px; | ||
} | ||
|
||
.card-deck .card { | ||
min-width: 220px; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
var ticketABI = [ | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "_price", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"name": "_amount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "createTicket", | ||
"outputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "index", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "getMoneyBack", | ||
"outputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "index", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "payForTicket", | ||
"outputs": [], | ||
"payable": true, | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "getMyTickets", | ||
"outputs": [ | ||
{ | ||
"name": "mytickets", | ||
"type": "uint256[]" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [ | ||
{ | ||
"name": "index", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "getTicket", | ||
"outputs": [ | ||
{ | ||
"name": "name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "price", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"name": "amount", | ||
"type": "uint256" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "getTicketsLength", | ||
"outputs": [ | ||
{ | ||
"name": "size", | ||
"type": "uint256" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
]; | ||
|
||
const contractAddress = "0xae5d5f77e3f7394fb617e1e5e0168be220f450b0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> | ||
<meta name="description" content="" /> | ||
<meta name="author" content="Colendi" /> | ||
<link rel="icon" type="image/x-icon" href="./assets/favicon.ico"> | ||
<title>Ticket ÐApp Demo</title> | ||
<!-- Bootstrap core CSS --> | ||
<link href="assets/bootstrap-4.1.3/css/bootstrap.min.css" rel="stylesheet" /> | ||
<!-- Custom styles for this template --> | ||
<link href="assets/style.css" rel="stylesheet" /> | ||
<script src="assets/jquery-3.3.1.min.js"></script> | ||
<!-- ETH related dependencies --> | ||
<script src="assets/web3.min.js"></script> | ||
<script type="text/javascript" src="assets/truffle-contract.min.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div | ||
class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm"> | ||
<h5 class="my-0 mr-md-auto font-weight-normal">Ticket ÐApp</h5> | ||
<nav class="my-2 my-md-0 mr-md-3"> | ||
<a class="p-2 text-dark" href="tickets.html">My Tickets</a> | ||
</nav> | ||
<a class="btn btn-outline-primary" href="index.html">Buy Ticket</a> | ||
</div> | ||
|
||
<div class="m-md-5 text-center"> | ||
<div class="alert alert-primary" role="alert"> | ||
<h6><strong>Selected Network: </strong><span id="accountStatus"></span></h6> | ||
<h6><strong>Wallet Address: </strong><span id="accountAddress"></span></h6> | ||
<h6><strong>Balance: </strong><span id="accountBalance"></span></h6> | ||
</div> | ||
|
||
<div id="trxAlert" class="alert" role="alert"> | ||
<a target="_blank"><span id="trxStatus"></span></a> | ||
</div> | ||
</div> | ||
|
||
<div class="pricing-header px-3 py-3 pb-md-4 mx-auto text-center"> | ||
<h1 class="display-4">Tickets</h1> | ||
<p class="lead"> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
</p> | ||
</div> | ||
|
||
<div class="container"> | ||
<div class="card-deck mb-3 text-center"> | ||
<div class="card mb-4 shadow-sm"> | ||
<div class="card-header"> | ||
<h4 id="ticket-title-0" class="my-0 font-weight-normal"></h4> | ||
</div> | ||
<div class="card-body"> | ||
<h1 class="card-title pricing-card-title"> | ||
<span id="ticket-price-0"></span> ETH | ||
</h1> | ||
<ul class="list-unstyled mt-3 mb-4"> | ||
<li>Available: <span id="ticket-available-0"></span></li> | ||
</ul> | ||
<button | ||
id="ticket-buy-0" | ||
type="button" | ||
class="btn btn-lg btn-block btn-outline-dark" | ||
> | ||
Buy ticket | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="card mb-4 shadow-sm"> | ||
<div class="card-header bg-warning"> | ||
<h4 id="ticket-title-1" class="my-0 font-weight-normal"></h4> | ||
</div> | ||
<div class="card-body"> | ||
<h1 class="card-title pricing-card-title"> | ||
<span id="ticket-price-1"></span> ETH | ||
</h1> | ||
<ul class="list-unstyled mt-3 mb-4"> | ||
<li>Available: <span id="ticket-available-1"></span></li> | ||
</ul> | ||
<button | ||
id="ticket-buy-1" | ||
type="button" | ||
class="btn btn-lg btn-block btn-outline-dark" | ||
> | ||
Buy ticket | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="card mb-4 shadow-sm"> | ||
<div class="card-header bg-secondary"> | ||
<h4 id="ticket-title-2" class="my-0 font-weight-normal"></h4> | ||
</div> | ||
<div class="card-body"> | ||
<h1 class="card-title pricing-card-title"> | ||
<span id="ticket-price-2"></span> ETH | ||
</h1> | ||
<ul class="list-unstyled mt-3 mb-4"> | ||
<li>Available: <span id="ticket-available-2"></span></li> | ||
</ul> | ||
<button | ||
id="ticket-buy-2" | ||
type="button" | ||
class="btn btn-lg btn-block btn-outline-dark" | ||
> | ||
Buy ticket | ||
</button> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
<footer class="pt-4 my-md-5 pt-md-5 border-top"> | ||
<div class="row"> | ||
<div class="col-12 col-md"><span>Source: <a target="_blank" href="https://github.com/colendi-project/ticket-dapp">https://github.com/colendi-project/ticket-dapp</a></span> | ||
<small class="d-block mb-3 text-muted">© Colendi - 2018</small> | ||
</div> | ||
</footer> | ||
</div> | ||
|
||
<!-- | ||
Bootstrap core JavaScript | ||
================================================== | ||
--> | ||
<!-- Placed at the end of the document so the pages load faster --> | ||
<script | ||
src="https://code.jquery.com/jquery-3.3.1.slim.min.js" | ||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" | ||
crossorigin="anonymous" | ||
></script> | ||
|
||
<script src="assets/bootstrap-4.1.3/js/bootstrap.min.js"></script> | ||
<script src="src/initWeb3.js"></script> | ||
<script src="contracts/dEventTicket.js"></script> | ||
<script src="src/initContract.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
$("#trxAlert").hide(); | ||
|
||
//deploys contract with ABI and address | ||
var ticketContract = web3.eth.contract(ticketABI); | ||
var contractInstance = ticketContract.at(contractAddress); | ||
|
||
var tickets = []; | ||
|
||
//makes a call to get ticket list length | ||
contractInstance.getTicketsLength.call({}, function(err, ticketCount) { | ||
if (!err) { | ||
//gets each tickets information | ||
for (let i = 0; i < parseInt(ticketCount, 10); i++) { | ||
contractInstance.getTicket(i, function(err, ticketInfo) { | ||
if (!err) { | ||
var price = parseFloat(ticketInfo[1] / Math.pow(10, 18), 10); | ||
//initializes ticket information | ||
$("#ticket-title-" + i).text(ticketInfo[0]); | ||
$("#ticket-price-" + i).text(price); | ||
$("#ticket-available-" + i).text(parseInt(ticketInfo[2], 10)); | ||
$("#ticket-buy-" + i).on("click", function() { | ||
buyTicket(i, parseFloat(ticketInfo[1], 10)); | ||
}); | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
} | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
|
||
function buyTicket(ticketId, ticketPrice) { | ||
contractInstance.payForTicket.sendTransaction( | ||
ticketId, | ||
{ from: web3.eth.accounts[0], gas: 3000000, value: ticketPrice }, | ||
function(err, res) { | ||
$("#trxAlert").show(); | ||
if (!err) { | ||
$("#trxAlert").removeClass("alert-success"); | ||
$("#trxAlert").addClass("alert-success"); | ||
$("a").attr("href", "https://rinkeby.etherscan.io/tx/" + res); | ||
$("#trxStatus").text(res); | ||
} else { | ||
$("#trxAlert").removeClass("alert-success"); | ||
$("#trxAlert").addClass("alert-danger"); | ||
$("#trxStatus").text(err.message); | ||
} | ||
} | ||
); | ||
} | ||
|
||
function myTickets() { | ||
contractInstance.getMyTickets.call({}, function(err, res) { | ||
var totalPrice = 0; | ||
if (!err) { | ||
res.sort(); | ||
$("#total-ticket").text(res.length); | ||
|
||
for (let i = 0; i < res.length; i++) { | ||
contractInstance.getTicket(parseInt(res[i], 10), function( | ||
err, | ||
ticketInfo | ||
) { | ||
if (!err) { | ||
var price = parseFloat(ticketInfo[1] / Math.pow(10, 18), 10); | ||
totalPrice += price; | ||
$("#my-ticket-list").append("<tr><th>" + (i + 1) + "</th><td>" + ticketInfo[0] + "</td><td>" + price + " ETH</td></tr>"); | ||
$("#total-price").text(totalPrice); | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
} | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
} |
Oops, something went wrong.