Ethereum Coin Aj007
Solidity Smart Contract
pragma solidity 0.4.8;
contract Aj007{
mapping (address => uint256) public balanceOf;
// allowing others to execute transactions on your behalf
mapping (address => mapping (address => uint256)) public allowance;
// balanceOf[address] = 5;
string public standard = "Aj007 v1.0";
string public name;
string public symbol;
uint8 public decimal; // 1.23 Number of decimal
uint256 public totalSupply;
//indexed address passsed will be stored in log memory and not contract data
event Transfer(address indexed from, address indexed to, uint256 _value);
function Aj007 (uint256 initialSupply, string tokenName, string tokenSymbol, uint8 decimalUnits){
balanceOf[msg.sender] = initialSupply;
totalSupply = initialSupply;
decimal = decimalUnits;
name = tokenName;
symbol = tokenSymbol;
}
function transfer (address _to,uint256 _value){
if(balanceOf[msg.sender] < _value) throw;
//0-255 8 bit
// 250,10 = 4 Buffer overflow
if(balanceOf[_to] + _value < balanceOf [_to]) throw;
// Any number of conditions can be added here
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
// Can be used for debugging values of smart contract and also act as an event for other clients
// Technically a logging method
Transfer(msg.sender,_to,_value);
}
function approve (address _spender, uint256 _value) returns(bool res){
allowance[msg.sender][_spender] = _value;
return true;
}
function transferFrom (address _from, address _to, uint256 _value) returns(bool res){
if(balanceOf[_from] < _value) throw;
if(balanceOf[_to] + _value < balanceOf[_to]) throw; if(_value > allowance[_from][msg.sender]) throw;
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from,_to, _value);
return true;
}
}