Skip to content

Commit

Permalink
Add some contracts and compile them with web3-loader and solc-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgepigdaniel committed Sep 18, 2017
1 parent 90412ab commit e7f7e94
Show file tree
Hide file tree
Showing 11 changed files with 558 additions and 13 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dependencies": {
"babel-polyfill": "^6.23.0",
"cookie-parser": "^1.4.3",
"ethereumjs-testrpc": "^4.1.3",
"express": "^4.15.2",
"fetch-everywhere": "^1.0.5",
"history": "^4.6.3",
Expand Down Expand Up @@ -66,8 +67,11 @@
"prettier": "^1.4.4",
"react-hot-loader": "next",
"rimraf": "^2.6.1",
"solc-loader": "^1.1.1",
"stats-webpack-plugin": "^0.5.0",
"travis-github-status": "^1.4.0",
"web3": "0.20.2",
"web3-loader": "^1.1.2",
"webpack": "^3.5.4",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.18.2",
Expand Down
8 changes: 8 additions & 0 deletions src/contracts/ConvertLib.sol
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;
}
}
34 changes: 34 additions & 0 deletions src/contracts/MetaCoin.sol
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];
}
}
5 changes: 5 additions & 0 deletions src/contracts/counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma solidity ^0.4.10;

contract Counter {
uint value;
}
Loading

0 comments on commit e7f7e94

Please sign in to comment.