aboutsummaryrefslogtreecommitdiffstats
path: root/std
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-27 01:32:18 +0800
committerGitHub <noreply@github.com>2016-08-27 01:32:18 +0800
commitfb7836d87bba0eacb2454d6c50b1209365a89b6d (patch)
tree81810b473d4ae5f76e2cb97a959ff234382966ac /std
parent69acd25888007c536bef22e350725cf444db58ad (diff)
parent56558c0db2ad1e64aa81aaa05820388c2ba65a45 (diff)
downloaddexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.tar
dexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.tar.gz
dexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.tar.bz2
dexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.tar.lz
dexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.tar.xz
dexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.tar.zst
dexon-solidity-fb7836d87bba0eacb2454d6c50b1209365a89b6d.zip
Merge pull request #897 from Denton-L/remove-standard
BREAKING: Remove standard contracts
Diffstat (limited to 'std')
-rw-r--r--std/StandardToken.sol43
-rw-r--r--std/Token.sol11
-rw-r--r--std/mortal.sol8
-rw-r--r--std/owned.sol13
-rw-r--r--std/std.sol4
5 files changed, 79 insertions, 0 deletions
diff --git a/std/StandardToken.sol b/std/StandardToken.sol
new file mode 100644
index 00000000..db453492
--- /dev/null
+++ b/std/StandardToken.sol
@@ -0,0 +1,43 @@
+import "./Token.sol";
+
+contract StandardToken is Token {
+ uint256 public totalSupply;
+ mapping (address => uint256) public balanceOf;
+ mapping (address =>
+ mapping (address => uint256)) public allowance;
+
+ function StandardToken(address _initialOwner, uint256 _supply) {
+ totalSupply = _supply;
+ balanceOf[_initialOwner] = _supply;
+ }
+
+ function transfer(address _to, uint256 _value) returns (bool success) {
+ if (balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
+ balanceOf[msg.sender] -= _value;
+ balanceOf[_to] += _value;
+ Transfer(msg.sender, _to, _value);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
+ if (allowance[_from][msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
+ allowance[_from][msg.sender] -= _value;
+ balanceOf[_to] += _value;
+ Transfer(_from, _to, _value);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ function approve(address _spender, uint256 _value) returns (bool success) {
+ allowance[msg.sender][_spender] = _value;
+ Approval(msg.sender, _spender, _value);
+ return true;
+ }
+}
diff --git a/std/Token.sol b/std/Token.sol
new file mode 100644
index 00000000..50d9ab7a
--- /dev/null
+++ b/std/Token.sol
@@ -0,0 +1,11 @@
+contract Token {
+ event Transfer(address indexed _from, address indexed _to, uint256 _value);
+ event Approval(address indexed _owner, address indexed _spender, uint256 _value);
+
+ function totalSupply() constant returns (uint256 supply) {}
+ function balanceOf(address _owner) constant returns (uint256 balance) {}
+ function transfer(address _to, uint256 _value) returns (bool success) {}
+ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
+ function approve(address _spender, uint256 _value) returns (bool success) {}
+ function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
+}
diff --git a/std/mortal.sol b/std/mortal.sol
new file mode 100644
index 00000000..8de019ab
--- /dev/null
+++ b/std/mortal.sol
@@ -0,0 +1,8 @@
+import "./owned.sol";
+
+contract mortal is owned {
+ function kill() {
+ if (msg.sender == owner)
+ selfdestruct(owner);
+ }
+}
diff --git a/std/owned.sol b/std/owned.sol
new file mode 100644
index 00000000..37f0ecb9
--- /dev/null
+++ b/std/owned.sol
@@ -0,0 +1,13 @@
+contract owned {
+ address owner;
+
+ modifier onlyowner() {
+ if (msg.sender == owner) {
+ _
+ }
+ }
+
+ function owned() {
+ owner = msg.sender;
+ }
+}
diff --git a/std/std.sol b/std/std.sol
new file mode 100644
index 00000000..c3f66b1b
--- /dev/null
+++ b/std/std.sol
@@ -0,0 +1,4 @@
+import "./owned.sol";
+import "./mortal.sol";
+import "./Token.sol";
+import "./StandardToken.sol";