Files: a0851a84040bdc2bc5a6f2067d00bc5974724c5d / contracts / tokens / EntropyToken.sol
2163 bytesRaw
1 | pragma solidity ^0.4.4; |
2 | |
3 | /* |
4 | This Token Contract implements the standard token functionality (https://github.com/ethereum/EIPs/issues/20) as well as the following OPTIONAL extras intended for use by humans. |
5 | |
6 | In other words. This is intended for deployment in something like a Token Factory or Mist wallet, and then used by humans. |
7 | Imagine coins, currencies, shares, voting weight, etc. |
8 | Machine-based, rapid creation of many tokens would not necessarily need these extra features or will be minted in other manners. |
9 | |
10 | 1) Initial Finite Supply (upon creation one specifies how much is minted). |
11 | 2) In the absence of a token registry: Optional Decimal, Symbol & Name. |
12 | 3) Optional approveAndCall() functionality to notify a contract if an approval() has occurred. |
13 | |
14 | .*/ |
15 | |
16 | import "./StandardToken.sol"; |
17 | |
18 | contract EntropyToken is StandardToken { |
19 | /* Public variables of the token */ |
20 | string public name; |
21 | uint8 public decimals; // How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. |
22 | string public symbol; // identifier |
23 | string public version; // human 0.1 standard. Just an arbitrary versioning scheme. |
24 | uint public totalValue; // Total value in wei |
25 | uint public safety_limit; // Maximum safe amount of ether to hold |
26 | |
27 | /* Approves and then calls the receiving contract */ |
28 | function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { |
29 | allowed[msg.sender][_spender] = _value; |
30 | Approval(msg.sender, _spender, _value); |
31 | |
32 | //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. |
33 | //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) |
34 | //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. |
35 | if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } |
36 | return true; |
37 | } |
38 | } |
39 |
Built with git-ssb-web