DID ERC20 Token Source Code
So, it was very tough to give up control. I have a 100k+ active devices spread all over the world; mostly APs. From servers to kiosks and APs to electronic displays, I have always kept a backdoor to every device in case of an emergency. It’s been a couple of years since my devices have been on and a few haven’t rebooted for 4–5 years. I take pride in that and I do feel responsible for all the devices that run my software.
With DID, I have to release the schema in a public domain and have to relinquish control. I believe in a public network; this is a public project and I intend to provide the complete software in its entirety to the proposed DID foundation. Baby steps; the source code for DID Token is available below:
Token.sol
pragma solidity ^0.4.4;
contract Token {
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) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
SafeMath.sol
pragma solidity ^0.4.4;
contract SafeMath{
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a — b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
function assert(bool assertion) internal {
if (!assertion) {
revert();
}
}
}
StandardToken.sol
pragma solidity ^0.4.4;
import “./Token.sol”;
import “./SafeMath.sol”;
contract StandardToken is Token , SafeMath{
function transfer(address _to, uint256 _value) returns (bool success) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to],_value);
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = safeAdd(balances[_to],_value);
balances[_from] = safeSub(balances[_from],_value);
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_value);
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
}
DID.sol
pragma solidity ^0.4.4;
import “./StandardToken.sol”;
contract DID is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
string public name = “DID”;
uint8 public decimals = 18;
string public symbol = “DID”;
uint256 public INITIAL_SUPPLY = 20000000000000000000000000000;
function DID() {
balances[msg.sender] = INITIAL_SUPPLY;
totalSupply = INITIAL_SUPPLY;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3(“receiveApproval(address,uint256,address,bytes)”))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
}
Contract Address:
0x315970bE5a362Fc89ab4240c52A78043211FFF1E
Decimals:
18
Symbol:
DID
To a brighter, better future. A Public token, in the public domain, for the public.