This repository has been archived by the owner on Jul 19, 2023. 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 959a2cb
Showing
25 changed files
with
11,470 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.
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,27 @@ | ||
pragma solidity ^0.4.21; | ||
|
||
contract TokenSale { | ||
mapping(address => uint256) public balanceOf; | ||
uint256 constant PRICE_PER_TOKEN = 1 ether; | ||
|
||
function TokenSale(address _player) public payable { | ||
require(msg.value == 1 ether); | ||
} | ||
|
||
function isComplete() public view returns (bool) { | ||
return address(this).balance < 1 ether; | ||
} | ||
|
||
function buy(uint256 numTokens) public payable { | ||
require(msg.value == numTokens * PRICE_PER_TOKEN); | ||
|
||
balanceOf[msg.sender] += numTokens; | ||
} | ||
|
||
function sell(uint256 numTokens) public { | ||
require(balanceOf[msg.sender] >= numTokens); | ||
|
||
balanceOf[msg.sender] -= numTokens; | ||
msg.sender.transfer(numTokens * PRICE_PER_TOKEN); | ||
} | ||
} |
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,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,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! | ||
}; |
Oops, something went wrong.