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
0 parents
commit 999971d
Showing
8 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
package-lock.json | ||
node_modules/ |
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,23 @@ | ||
pragma solidity ^0.4.23; | ||
|
||
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); | ||
} | ||
} |
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,51 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
contract dEventTicket { | ||
|
||
struct Ticket{ | ||
string name; | ||
uint256 price; | ||
uint256 amount; | ||
} | ||
|
||
|
||
mapping (address => uint256[]) paidTickets; | ||
mapping (uint256 => address) ticketCreator; | ||
mapping (uint256 => uint256) revenueOfTicket; | ||
|
||
Ticket[] tickets; | ||
|
||
function createTicket(string _name, uint256 _price, uint256 _amount) external{ | ||
Ticket memory ticket = Ticket({name:_name, price:_price, amount:_amount}); | ||
tickets.push(ticket); | ||
} | ||
|
||
function getTicketsLength() external view returns (uint256 size) { | ||
return tickets.length; | ||
} | ||
|
||
function getTicket(uint index) external view returns(string name, uint256 price, uint256 amount){ | ||
Ticket memory ticket = tickets[index]; | ||
name = ticket.name; | ||
price = ticket.price; | ||
amount = ticket.amount; | ||
} | ||
|
||
function payForTicket(uint index) external payable{ | ||
Ticket storage ticket = tickets[index]; | ||
require(msg.value >= ticket.price); | ||
require(msg.sender.send(msg.value-ticket.price)); | ||
require(ticket.amount>0); | ||
paidTickets[msg.sender].push(index); | ||
ticket.amount = ticket.amount - 1; | ||
} | ||
|
||
function getMyTickets() external view returns (uint[] mytickets){ | ||
return paidTickets[msg.sender]; | ||
} | ||
|
||
function getMoneyBack(){ | ||
|
||
} | ||
|
||
} |
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,5 @@ | ||
var Migrations = artifacts.require("./Migrations.sol"); | ||
|
||
module.exports = function(deployer) { | ||
deployer.deploy(Migrations); | ||
}; |
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,5 @@ | ||
const dEventTicket = artifacts.require("./dEventTicket.sol"); | ||
|
||
module.exports = function (deployer) { | ||
deployer.deploy(dEventTicket) | ||
}; |
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,22 @@ | ||
{ | ||
"name": "ticket-dapp", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "truffle-config.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/colendi-project/ticket-dapp.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/colendi-project/ticket-dapp/issues" | ||
}, | ||
"homepage": "https://github.com/colendi-project/ticket-dapp#readme" | ||
} |
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,18 @@ | ||
/* | ||
* NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a | ||
* function when declaring them. Failure to do so will cause commands to hang. ex: | ||
* ``` | ||
* mainnet: { | ||
* provider: function() { | ||
* return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') | ||
* }, | ||
* network_id: '1', | ||
* gas: 4500000, | ||
* gasPrice: 10000000000, | ||
* }, | ||
*/ | ||
|
||
module.exports = { | ||
// See <http://truffleframework.com/docs/advanced/configuration> | ||
// to customize your Truffle configuration! | ||
}; |
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,31 @@ | ||
const HDWalletProvider = require("truffle-hdwallet-provider-privkey"); | ||
|
||
const walletAddr = process.env.WALLET_ADDRESS; | ||
const privateKey = process.env.WALLET_PRIVATE_KEY; | ||
const infuraURLKovan = process.env.INFURA_URL_KOVAN; | ||
const infuraKeyKovan = process.env.INFURA_KEY_KOVAN; | ||
const infuraURLRinkeby = process.env.INFURA_URL_RINKEBY; | ||
const infuraKeyRinkeby = process.env.INFURA_KEY_RINKEBY; | ||
|
||
module.exports = { | ||
networks: { | ||
development: { | ||
host: "localhost", | ||
port: 8545, | ||
network_id: "*" | ||
}, | ||
rinkeby: { | ||
provider: () => { | ||
return new HDWalletProvider(privateKey, (infuraURLRinkeby+infuraKeyRinkeby)); | ||
}, | ||
network_id: 4 | ||
}, | ||
kovan: { | ||
provider: () => { | ||
return new HDWalletProvider(privateKey, (infuraURLKovan+infuraKeyKovan)); | ||
|
||
}, | ||
network_id: 42 | ||
} | ||
} | ||
}; |