This repository has been archived by the owner on Mar 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
14 changed files
with
3,831 additions
and
1 deletion.
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
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,8 @@ | ||
pragma solidity ^0.4.4; | ||
|
||
library ConvertLib{ | ||
function convert(uint amount,uint conversionRate) returns (uint convertedAmount) | ||
{ | ||
return amount * conversionRate; | ||
} | ||
} |
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,34 @@ | ||
pragma solidity ^0.4.4; | ||
|
||
import "./ConvertLib.sol"; | ||
|
||
// This is just a simple example of a coin-like contract. | ||
// It is not standards compatible and cannot be expected to talk to other | ||
// coin/token contracts. If you want to create a standards-compliant | ||
// token, see: https://github.com/ConsenSys/Tokens. Cheers! | ||
|
||
contract MetaCoin { | ||
mapping (address => uint) balances; | ||
|
||
event Transfer(address indexed _from, address indexed _to, uint256 _value); | ||
|
||
function MetaCoin() { | ||
balances[tx.origin] = 10000; | ||
} | ||
|
||
function sendCoin(address receiver, uint amount) returns(bool sufficient) { | ||
if (balances[msg.sender] < amount) return false; | ||
balances[msg.sender] -= amount; | ||
balances[receiver] += amount; | ||
Transfer(msg.sender, receiver, amount); | ||
return true; | ||
} | ||
|
||
function getBalanceInEth(address addr) returns(uint){ | ||
return ConvertLib.convert(getBalance(addr),2); | ||
} | ||
|
||
function getBalance(address addr) returns(uint) { | ||
return balances[addr]; | ||
} | ||
} |
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.4; | ||
|
||
contract Migrations { | ||
address public owner; | ||
uint public last_completed_migration; | ||
|
||
modifier restricted() { | ||
if (msg.sender == owner) _; | ||
} | ||
|
||
function Migrations() { | ||
owner = msg.sender; | ||
} | ||
|
||
function setCompleted(uint completed) restricted { | ||
last_completed_migration = completed; | ||
} | ||
|
||
function upgrade(address new_address) 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,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,8 @@ | ||
var ConvertLib = artifacts.require("./ConvertLib.sol"); | ||
var MetaCoin = artifacts.require("./MetaCoin.sol"); | ||
|
||
module.exports = function(deployer) { | ||
deployer.deploy(ConvertLib); | ||
deployer.link(ConvertLib, MetaCoin); | ||
deployer.deploy(MetaCoin); | ||
}; |
Oops, something went wrong.