pragma solidity 0.5.11;
contract ITokenRecipient {
function tokenFallback(address from, uint value) public;
}
contract SafeMath {
uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
function safeAdd(uint256 x, uint256 y) pure internal returns (uint256 z) {
if (x > MAX_UINT256 - y) revert();
return x + y;
}
function safeSub(uint256 x, uint256 y) pure internal returns (uint256 z) {
if (x < y) revert();
return x - y;
}
}
contract InternationalFinancialAsset is SafeMath {
mapping(address => uint) public balances;
mapping (address => mapping (address => uint256)) public allowance;
string public name = "International Financial Asset";
string public symbol = "IFA";
uint8 public decimals = 18;
uint256 public totalSupply = 500000000000000000000000000;
event Transfer(address indexed from, address indexed to, uint value);
event Burn(address indexed from, uint256 value);
constructor() public { balances[msg.sender] = totalSupply; }
function isContract(address ethAddress) private view returns (bool) {
uint length;
assembly { length := extcodesize(ethAddress) }
return (length > 0);
}
function transfer(address to, uint value) public returns (bool success) {
require(value > 0);
balances[msg.sender] = safeSub(balances[msg.sender], value);
balances[to] = safeAdd(balances[to], value);
if(isContract(to)) {
ITokenRecipient receiver = ITokenRecipient(to);
receiver.tokenFallback(msg.sender, value);
}
emit Transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool success) {
require(value > 0);
allowance[msg.sender][spender] = value;
return true;
}
function transferFrom(address fromAddress, address toAddress, uint256 value) public returns (bool success) {
require(uint256(toAddress) != 0 && value > 0);
balances[fromAddress] = safeSub(balances[fromAddress], value);
balances[toAddress] = safeAdd(balances[toAddress], value);
allowance[fromAddress][msg.sender] = safeSub(allowance[fromAddress][msg.sender], value);
emit Transfer(fromAddress, toAddress, value);
return true;
}
function burn(uint256 value) public returns (bool success) {
require(value > 0);
balances[msg.sender] = safeSub(balances[msg.sender], value);
totalSupply = safeSub(totalSupply,value);
emit Burn(msg.sender, value);
return true;
}
function balanceOf(address ethAddress) public view returns (uint balance) {
return balances[ethAddress];
}
}
{
"compilationTarget": {
"InternationalFinancialAsset.sol": "InternationalFinancialAsset"
},
"evmVersion": "petersburg",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_UINT256","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"ethAddress","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Burn","type":"event"}]