* Added new Deploy Contract page // Use Brace in React #2276 * Adding Web Wrokers WIP * Compiling Solidity code // Getting mandatory params #2276 * Working editor and deployment #2276 * WIP : displaying source code * Added Solidity hightling, editor component in UI * Re-adding the standard Deploy Modal #2276 * Using MobX in Contract Edition // Save to Localstorage #2276 * User select Solidity version #2276 * Loading Solidity versions and closing worker properly #2276 * Adds export to solidity editor #2276 * Adding Import to Contract Editor #2276 * Persistent Worker => Don't load twice Solidity Code #2276 * UI Fixes * Editor tweaks * Added Details with ABI in Contract view * Adds Save capabilities to contract editor // WIP on Load #3279 * Working Load and Save contracts... #3231 * Adding loader of Snippets // Export with name #3279 * Added snippets / Importing from files and from URL * Fix wrong ID in saved Contract * Fix lint * Fixed Formal errors as warning #3279 * Fixing lint issues * Use NPM Module for valid URL (fixes linting issue too) * Don't clobber tests.
61 lines
3.1 KiB
Solidity
61 lines
3.1 KiB
Solidity
/*
|
|
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.
|
|
|
|
In other words. This is intended for deployment in something like a Token Factory or Mist wallet, and then used by humans.
|
|
Imagine coins, currencies, shares, voting weight, etc.
|
|
Machine-based, rapid creation of many tokens would not necessarily need these extra features or will be minted in other manners.
|
|
|
|
1) Initial Finite Supply (upon creation one specifies how much is minted).
|
|
2) In the absence of a token registry: Optional Decimal, Symbol & Name.
|
|
3) Optional approveAndCall() functionality to notify a contract if an approval() has occurred.
|
|
|
|
.*/
|
|
|
|
import "StandardToken.sol";
|
|
|
|
contract HumanStandardToken is StandardToken {
|
|
|
|
function () {
|
|
//if ether is sent to this address, send it back.
|
|
throw;
|
|
}
|
|
|
|
/* Public variables of the token */
|
|
|
|
/*
|
|
NOTE:
|
|
The following variables are OPTIONAL vanities. One does not have to include them.
|
|
They allow one to customise the token contract & in no way influences the core functionality.
|
|
Some wallets/interfaces might not even bother to look at this information.
|
|
*/
|
|
string public name; //fancy name: eg Simon Bucks
|
|
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.
|
|
string public symbol; //An identifier: eg SBX
|
|
string public version = 'H0.1'; //human 0.1 standard. Just an arbitrary versioning scheme.
|
|
|
|
function HumanStandardToken(
|
|
uint256 _initialAmount,
|
|
string _tokenName,
|
|
uint8 _decimalUnits,
|
|
string _tokenSymbol
|
|
) {
|
|
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens
|
|
totalSupply = _initialAmount; // Update total supply
|
|
name = _tokenName; // Set the name for display purposes
|
|
decimals = _decimalUnits; // Amount of decimals for display purposes
|
|
symbol = _tokenSymbol; // Set the symbol for display purposes
|
|
}
|
|
|
|
/* Approves and then calls the receiving contract */
|
|
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
|
|
allowed[msg.sender][_spender] = _value;
|
|
Approval(msg.sender, _spender, _value);
|
|
|
|
//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.
|
|
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
|
|
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
|
|
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
|
|
return true;
|
|
}
|
|
}
|