{
address: "0xce7e65b9cfadb8cb904b757f263297aa29988fe7",
balance: {
type: "BigNumber",
hex: "0x00"
string: "0"
ether: "0.0"
},
"transactions": [],
code: "/*
Name: DoubleOrQuits Token
Version: 0.0.3
*/
class Ownable {
owner = '0x0000000000000000000000000000000000000000';
OwnershipTransferred(oldOwner, newOwner) {} // event
constructor() {
this.owner = msg.sender;
}
getOwner() {
return [this.owner];
}
transferOwnership(newOwner) {
require(newOwner != address(0), "Ownable: new owner is the zero address");
this._transferOwnership(newOwner);
}
_transferOwnership(newOwner) {
newOwner = newOwner.toLowerCase();
const oldOwner = this.owner;
this.owner = newOwner;
emit('OwnershipTransferred', [oldOwner, newOwner]);
}
_onlyOwner(next) {
require(msg.sender.toLowerCase() == this.owner, 'only owner can execute this');
next();
}
}
// Methods
Ownable.prototype.OwnershipTransferred.event = true;
Ownable.prototype.OwnershipTransferred.inputs = ['address indexed', 'address indexed'];
// Methods
Ownable.prototype.getOwner.view = true;
Ownable.prototype.getOwner.outputs = ['address'];
Ownable.prototype.transferOwnership.inputs = ['address'];
Ownable.prototype.transferOwnership.modifiers = ['_onlyOwner'];
Ownable.prototype._transferOwnership.internal = true;
Ownable.prototype._onlyOwner.internal = true;
class ERC20Token extends Ownable {
name = 'ERC20 Token';
symbol = 'ERC20';
decimals = 18;
totalSupply = number('0');
allowed = {};
balances = {};
supportedInterfaces = {
'0x36372b07': true, // ERC20
'0x06fdde03': true, // ERC20 name
'0x95d89b41': true, // ERC20 symbol
'0x313ce567': true, // ERC20 decimals
};
Transfer(sender, recipient, amount) {} // event
Approval(owner, spender, amount) {} // event
Mint(minter, amount) {} // event
Burn(burner, amount) {} // event
balanceOf(holderAddress) {
holderAddress = holderAddress.toLowerCase();
var tokenBalances = this.balances || {};
if (holderAddress in tokenBalances) {
const balance = tokenBalances[holderAddress];
return [balance];
}
return [number(0)];
}
transfer(recipient, amount) {
recipient = recipient.toLowerCase();
const sender = msg.sender;
var tokenBalances = this.balances || {};
if (! (sender in tokenBalances)) {
_throw('INSUFFICIENT_TOKEN_BALANCE');
}
if (tokenBalances[sender].lt(amount)) {
_throw('INSUFFICIENT_TOKEN_BALANCE');
}
if (this._decrementUserBalance.bind(this)(sender, amount)) {
this._incrementUserBalance.bind(this)(recipient, amount)
}
emit('Transfer', [sender, recipient, amount]);
return [true];
}
transferFrom(sender, recipient, amount) {
sender = sender.toLowerCase();
recipient = recipient.toLowerCase();
var tokenBalances = this.balances || {};
var tokenAllowances = this.allowed || {};
require(sender in tokenBalances, 'MISSING_TOKEN_BALANCE');
if (tokenBalances[sender].lt(amount)) {
_throw('INSUFFICIENT_TOKEN_BALANCE');
}
require(sender == msg.sender || (sender in tokenAllowances && msg.sender in tokenAllowances[sender]), "MISSING_ALLOWANCE");
if (sender != msg.sender && tokenAllowances[sender][msg.sender].lt(amount)) {
_throw('INSUFFICIENT_TOKEN_ALLOWANCE');
}
tokenAllowances[sender][msg.sender] = tokenAllowances[sender][msg.sender].sub(amount);
if (this._decrementUserBalance.bind(this)(sender, amount)) {
this._incrementUserBalance.bind(this)(recipient, amount)
}
emit('Transfer', [sender, recipient, amount]);
return [true];
}
allowance(owner, spender) {
owner = owner.toLowerCase();
spender = spender.toLowerCase();
var tokenAllowances = this.allowed || {};
if (owner in tokenAllowances && spender in tokenAllowances[owner]) {
return [tokenAllowances[owner][spender]];
}
return [number(0)];
}
approve(spender, value) {
spender = spender.toLowerCase();
var tokenAllowances = this.allowed || {};
if (! (msg.sender in tokenAllowances)) {
tokenAllowances[msg.sender] = {};
}
tokenAllowances[msg.sender][spender] = value;
emit('Approval', [msg.sender, spender, value]);
return [true];
}
mint(userAddress, amount) {
this._mint(userAddress, amount);
}
_mint(userAddress, amount) {
userAddress = userAddress.toLowerCase();
if (userAddress == address(0).address) {
_throw('ERC20: mint to the zero address');
}
if (this._incrementUserBalance.bind(this)(userAddress, amount)) {
this.totalSupply = this.totalSupply.add(amount);
}
emit('Mint', [userAddress, amount]);
}
burn(userAddress, amount) {
this._burn(userAddress, amount);
}
_burn(userAddress, amount) {
userAddress = userAddress.toLowerCase();
if (userAddress == address(0).address) {
_throw('ERC20: burn from the zero address');
}
if (this._decrementUserBalance.bind(this)(userAddress, amount)) {
this.totalSupply = this.totalSupply.sub(amount);
}
emit('Burn', [userAddress, amount]);
}
supportsInterface(interfaceID) {
const _interfaces = this.supportedInterfaces || {};
return [
((interfaceID in _interfaces)
? _interfaces[interfaceID]
: false)
];
}
_decrementUserBalance(holderAddress, amount) {
var tokenBalances = this.balances || {};
if (! (holderAddress in tokenBalances)) {
_throw('INSUFFICIENT_TOKEN_BALANCE');
}
if (amount.gt(tokenBalances[holderAddress])) {
_throw('INSUFFICIENT_TOKEN_BALANCE');
}
tokenBalances[holderAddress] = tokenBalances[holderAddress].sub(amount);
return true;
}
_incrementUserBalance(holderAddress, amount) {
var tokenBalances = this.balances || {};
if (! (holderAddress in tokenBalances)) {
tokenBalances[holderAddress] = number(0);
}
tokenBalances[holderAddress] = tokenBalances[holderAddress].add(amount);
return true;
}
}
// Events
ERC20Token.prototype.Transfer.event = true;
ERC20Token.prototype.Transfer.inputs = ['address indexed', 'address indexed', 'uint256'];
ERC20Token.prototype.Approval.event = true;
ERC20Token.prototype.Approval.inputs = ['address indexed', 'address indexed', 'uint256'];
ERC20Token.prototype.Mint.event = true;
ERC20Token.prototype.Mint.inputs = ['address indexed', 'uint256'];
ERC20Token.prototype.Burn.event = true;
ERC20Token.prototype.Burn.inputs = ['address indexed', 'uint256'];
// Methods
ERC20Token.prototype.balanceOf.view = true;
ERC20Token.prototype.balanceOf.inputs = ['address'];
ERC20Token.prototype.balanceOf.outputs = ['uint256'];
ERC20Token.prototype.transfer.inputs = ['address', 'uint256'];
ERC20Token.prototype.transfer.outputs = ['bool'];
ERC20Token.prototype.transferFrom.inputs = ['address', 'address', 'uint256'];
ERC20Token.prototype.transferFrom.outputs = ['bool'];
ERC20Token.prototype.allowance.view = true;
ERC20Token.prototype.allowance.inputs = ['address', 'address'];
ERC20Token.prototype.allowance.outputs = ['uint256'];
ERC20Token.prototype.approve.inputs = ['address', 'uint256'];
ERC20Token.prototype.approve.outputs = ['bool'];
ERC20Token.prototype.mint.inputs = ['address', 'uint256'];
ERC20Token.prototype.mint.modifiers = ['_onlyOwner'];
ERC20Token.prototype._mint.internal = true;
ERC20Token.prototype.burn.inputs = ['address', 'uint256'];
ERC20Token.prototype.burn.modifiers = ['_onlyOwner'];
ERC20Token.prototype._burn.internal = true;
ERC20Token.prototype.supportsInterface.view = true;
ERC20Token.prototype.supportsInterface.inputs = ['bytes4'];
ERC20Token.prototype.supportsInterface.outputs = ['bool'];
ERC20Token.prototype._decrementUserBalance.internal = true;
ERC20Token.prototype._incrementUserBalance.internal = true;
class DoubleOrQuitsToken extends ERC20Token {
name = 'Double Or Quits';
symbol = 'DOQ';
doubleOrQuits() {
const userAddress = msg.sender.toLowerCase();
var tokenBalances = this.balances || {};
let win = false;
if (userAddress in tokenBalances && tokenBalances[userAddress].gt(0)) {
const balance = tokenBalances[userAddress];
const rand = Math.random() * 100;
win = (Math.round(rand) % 2 == 0);
if (win) {
this.mint(userAddress, balance);
emit('Win', [userAddress, balance]);
} else {
this.burn(userAddress, balance);
emit('Loose', [userAddress, balance]);
}
} else {
const mintAmount = number('1000000000000000000'); // 1 DOQ
this.mint(userAddress, mintAmount);
win = true;
emit('FreeToken', [userAddress, mintAmount]);
}
return [win];
}
transfer(recipient, amount) {
recipient = recipient.toLowerCase();
const sender = msg.sender;
var tokenBalances = this.balances || {};
if (! (sender in tokenBalances)) {
throw new Error('INSUFFICIENT_TOKEN_BALANCE');
}
if (tokenBalances[sender].lt(amount)) {
throw new Error('INSUFFICIENT_TOKEN_BALANCE');
}
const burnAmount = amount.div(2);
this.burn(sender, burnAmount);
const recipientAmount = amount.sub(burnAmount);
this._decrementUserBalance.bind(this)(sender, recipientAmount);
this._incrementUserBalance.bind(this)(recipient, recipientAmount)
emit('Transfer', [sender, recipient, recipientAmount]);
return [true];
}
transferFrom(sender, recipient, amount) /* external returns (bool) */ {
sender = sender.toLowerCase(); // sender est celui dont les tokens vont etre dépensés par msg.sender
recipient = recipient.toLowerCase();
var tokenBalances = this.balances || {};
var tokenAllowances = this.allowed || {};
if (! (sender in tokenBalances)) {
throw new Error('INSUFFICIENT_TOKEN_BALANCE');
}
if (tokenBalances[sender].lt(amount)) {
throw new Error('INSUFFICIENT_TOKEN_BALANCE');
}
if (tokenAllowances[sender][msg.sender].lt(amount)) {
throw new Error('INSUFFICIENT_TOKEN_ALLOWANCE');
}
const burnAmount = number(0); //amount.div(2);
//this.burn(sender, burnAmount);
const recipientAmount = amount.sub(burnAmount);
this._decrementUserBalance.bind(this)(sender, recipientAmount);
this._incrementUserBalance.bind(this)(recipient, recipientAmount)
emit('Transfer', [sender, recipient, recipientAmount]);
return [true];
}
}
// Methods
DoubleOrQuitsToken.prototype.doubleOrQuits.outputs = ['bool'];
DoubleOrQuitsToken.prototype.transfer.inputs = ['address', 'uint256'];
DoubleOrQuitsToken.prototype.transfer.outputs = ['bool'];
DoubleOrQuitsToken.prototype.transferFrom.inputs = ['address', 'address', 'uint256'];
DoubleOrQuitsToken.prototype.transferFrom.outputs = ['bool'];
return DoubleOrQuitsToken;",
codeHash: "0x920104eb039bd57ed65888b1a91bd3d9cce69fe16b4b372fb2e36ebe647c7d0d",
codeAbi: {
0x8da5cb5b: {
constant: true,
"inputs": [],
name: "owner",
outputs: [
{
name: "",
type: "address"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x06fdde03: {
constant: true,
"inputs": [],
name: "name",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x95d89b41: {
constant: true,
"inputs": [],
name: "symbol",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x313ce567: {
constant: true,
"inputs": [],
name: "decimals",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x18160ddd: {
constant: true,
"inputs": [],
name: "totalSupply",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x19e1fca4: {
constant: true,
"inputs": [],
name: "allowed",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x7bb98a68: {
constant: true,
"inputs": [],
name: "balances",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x037cc0e6: {
constant: true,
"inputs": [],
name: "supportedInterfaces",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0xa8ac9b50: {
constant: true,
"inputs": [],
name: "prototype",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x4aec70cb: {
"inputs": [],
name: "doubleOrQuits",
outputs: [
{
name: "",
type: "bool"
}
],
stateMutability: "nonpayable",
type: "function"
},
0xddf252ad: {
inputs: [
{
name: "sender",
type: "address",
indexed: true
},
{
name: "recipient",
type: "address",
indexed: true
},
{
name: "amount",
type: "uint256",
indexed: false
}
],
name: "Transfer",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x8c5be1e5: {
inputs: [
{
name: "owner",
type: "address",
indexed: true
},
{
name: "spender",
type: "address",
indexed: true
},
{
name: "amount",
type: "uint256",
indexed: false
}
],
name: "Approval",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x0f6798a5: {
inputs: [
{
name: "minter",
type: "address",
indexed: true
},
{
name: "amount",
type: "uint256",
indexed: false
}
],
name: "Mint",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0xcc16f5db: {
inputs: [
{
name: "burner",
type: "address",
indexed: true
},
{
name: "amount",
type: "uint256",
indexed: false
}
],
name: "Burn",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x70a08231: {
inputs: [
{
name: "holderAddress",
type: "address"
}
],
name: "balanceOf",
outputs: [
{
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
0xa9059cbb: {
inputs: [
{
name: "recipient",
type: "address"
},
{
name: "amount",
type: "uint256"
}
],
name: "transfer",
outputs: [
{
name: "",
type: "bool"
}
],
stateMutability: "nonpayable",
type: "function"
},
0x23b872dd: {
inputs: [
{
name: "sender",
type: "address"
},
{
name: "recipient",
type: "address"
},
{
name: "amount",
type: "uint256"
}
],
name: "transferFrom",
outputs: [
{
name: "",
type: "bool"
}
],
stateMutability: "nonpayable",
type: "function"
},
0xdd62ed3e: {
inputs: [
{
name: "owner",
type: "address"
},
{
name: "spender",
type: "address"
}
],
name: "allowance",
outputs: [
{
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
0x095ea7b3: {
inputs: [
{
name: "spender",
type: "address"
},
{
name: "value",
type: "uint256"
}
],
name: "approve",
outputs: [
{
name: "",
type: "bool"
}
],
stateMutability: "nonpayable",
type: "function"
},
0x40c10f19: {
inputs: [
{
name: "userAddress",
type: "address"
},
{
name: "amount",
type: "uint256"
}
],
name: "mint",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
},
0x9dc29fac: {
inputs: [
{
name: "userAddress",
type: "address"
},
{
name: "amount",
type: "uint256"
}
],
name: "burn",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
},
0x01ffc9a7: {
inputs: [
{
name: "interfaceID",
type: "bytes4"
}
],
name: "supportsInterface",
outputs: [
{
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
0x8be0079c: {
inputs: [
{
name: "oldOwner",
type: "address",
indexed: true
},
{
name: "newOwner",
type: "address",
indexed: true
}
],
name: "OwnershipTransferred",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x893d20e8: {
"inputs": [],
name: "getOwner",
outputs: [
{
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
0xf2fde38b: {
inputs: [
{
name: "newOwner",
type: "address"
}
],
name: "transferOwnership",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
}
},
contractName: "DoubleOrQuitsToken",
storage: {
owner: "0x131a190fa22cb867abf58193bf9e7640e9fce682",
name: "Double Or Quits",
symbol: "DOQ",
decimals: 18,
totalSupply: {
type: "BigNumber",
hex: "0x00"
string: "0"
ether: "0.0"
},
"allowed": {},
"balances": {},
supportedInterfaces: {
0x36372b07: true,
0x06fdde03: true,
0x95d89b41: true,
0x313ce567: true
},
prototype: {
address: "0xce7e65b9cfadb8cb904b757f263297aa29988fe7"
}
},
storageHash: "0xb48d38f93eaa084033fc5970bf96e559c33c4cdc07d889ab00b4d63f9590739d",
savedOnBlockNumber: {
type: "BigNumber",
hex: "0x06"
string: "6"
ether: "0.000000000000000006"
}
}