Transaction Hash:
Block:
8762976 at Oct-18-2019 05:19:59 AM +UTC
Transaction Fee:
0.000258967349111375 ETH
$0.51
Gas Used:
946,069 Gas / 0.273729875 Gwei
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
| 0x00000000...438691c04 | |||||
| 0x08f03D12...40a042764 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x20943705...5879E79F5 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x2AfB80AB...f8F93ae2c |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x3Ef5102F...47E72fF02 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x4562f1A4...e992C4bcB |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x4db86A2a...623403378 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
|
0x52bc44d5...b7d7bE3b5
Miner
| (Nanopool) | 5,255.254823395374705521 Eth | 5,255.255082362723816896 Eth | 0.000258967349111375 | |
| 0x5d4bCff0...15F7d11DD |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x63530e07...83974fa77 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x725122b4...4756226F9 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x790E514b...dE4c243C9 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x7d5Bc78B...76F550B51 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x816CDddE...bDb6a1a60 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x9223Fd95...D4705f633 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0x976F93c5...A680aF48C |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xa503A048...3f99e045d |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xAbC35E91...6732dE8D1 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xb0a73BA9...5b375e379 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xBBDc0D0b...1bcBad838 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xbbe91b7A...C864aE82f |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xbeff7634...2116d00B9 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xd1E913F8...3f4003829 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xd52b8A0B...475122F83 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xD633F730...749eCDD2f |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xE1816196...589454861 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
| 0xe5C99b74...2f793a599 |
2.859278008594551774 Eth
Nonce: 30045
|
2.859019041245440399 Eth
Nonce: 30046
| 0.000258967349111375 | ||
| 0xfec7F4B7...44741cB5a |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
|
Execution Trace
GasToken2.mint( value=25 )
-
0x816cdddee23c98c0bee4aff715079f0bdb6a1a60.756eb3f8( ) -
0x63530e07de5d8500532f7d66be7a14683974fa77.756eb3f8( ) -
0x4db86a2a81cafd2e873ac6310c2375b623403378.756eb3f8( ) -
0x725122b48f885da098fb6f3355ea3a94756226f9.756eb3f8( ) -
0xabc35e917a0e2b9b6cd544ec112dad56732de8d1.756eb3f8( ) -
0xbbdc0d0b46eeeac86d7684d356970981bcbad838.756eb3f8( ) -
0xbbe91b7a414215226afe256c1857238c864ae82f.756eb3f8( ) -
0xd633f7303e280d7878daad70b392b06749ecdd2f.756eb3f8( ) -
0x5d4bcff03b7c974b02ae5e2caf67d6c15f7d11dd.756eb3f8( ) -
0x976f93c55a30693c0a92db0cfb6f003a680af48c.756eb3f8( ) -
0xbeff763415e19dddec3fd9e116591ea2116d00b9.756eb3f8( ) -
0x9223fd951ca4e98b550b03d04d6fd89d4705f633.756eb3f8( ) -
0x2afb80ab794840ad30ccd8ddab5dfb8f8f93ae2c.756eb3f8( ) -
0x3ef5102f8d4de92eb69e88c5bddb27447e72ff02.756eb3f8( ) -
0x7d5bc78b5cfbb73d404c375e2010c9b76f550b51.756eb3f8( ) -
0xa503a048e6be916b6fcf2579fbeb0333f99e045d.756eb3f8( ) -
0xe1816196cb4f045a8b163e93d79f0a5589454861.756eb3f8( ) -
0x209437057ba087083969d7c18c6d25e5879e79f5.756eb3f8( ) -
0x790e514b33ea29f94dc8ac75434ec5cde4c243c9.756eb3f8( ) -
0xb0a73ba9bc760a79ecf1721ce4fbe565b375e379.756eb3f8( ) -
0xd1e913f8861549b1d8f390373fa34a53f4003829.756eb3f8( ) -
0xfec7f4b7d1bd0990562eed052f7b13644741cb5a.756eb3f8( ) -
0x08f03d12db3493607d496b320e1aaf040a042764.756eb3f8( ) -
0xd52b8a0b9fa404d43cb0f3bab9c5005475122f83.756eb3f8( ) -
0x4562f1a4f9bfa81dca32958fc9e1b29e992c4bcb.756eb3f8( )
mint[GasToken2 (ln:219)]
makeChild[GasToken2 (ln:221)]
pragma solidity ^0.4.10;
contract GasToken2 {
//////////////////////////////////////////////////////////////////////////
// RLP.sol
// Due to some unexplained bug, we get a slightly different bytecode if
// we use an import, and are then unable to verify the code in Etherscan
//////////////////////////////////////////////////////////////////////////
uint256 constant ADDRESS_BYTES = 20;
uint256 constant MAX_SINGLE_BYTE = 128;
uint256 constant MAX_NONCE = 256**9 - 1;
// count number of bytes required to represent an unsigned integer
function count_bytes(uint256 n) constant internal returns (uint256 c) {
uint i = 0;
uint mask = 1;
while (n >= mask) {
i += 1;
mask *= 256;
}
return i;
}
function mk_contract_address(address a, uint256 n) constant internal returns (address rlp) {
/*
* make sure the RLP encoding fits in one word:
* total_length 1 byte
* address_length 1 byte
* address 20 bytes
* nonce_length 1 byte (or 0)
* nonce 1-9 bytes
* ==========
* 24-32 bytes
*/
require(n <= MAX_NONCE);
// number of bytes required to write down the nonce
uint256 nonce_bytes;
// length in bytes of the RLP encoding of the nonce
uint256 nonce_rlp_len;
if (0 < n && n < MAX_SINGLE_BYTE) {
// nonce fits in a single byte
// RLP(nonce) = nonce
nonce_bytes = 1;
nonce_rlp_len = 1;
} else {
// RLP(nonce) = [num_bytes_in_nonce nonce]
nonce_bytes = count_bytes(n);
nonce_rlp_len = nonce_bytes + 1;
}
// [address_length(1) address(20) nonce_length(0 or 1) nonce(1-9)]
uint256 tot_bytes = 1 + ADDRESS_BYTES + nonce_rlp_len;
// concatenate all parts of the RLP encoding in the leading bytes of
// one 32-byte word
uint256 word = ((192 + tot_bytes) * 256**31) +
((128 + ADDRESS_BYTES) * 256**30) +
(uint256(a) * 256**10);
if (0 < n && n < MAX_SINGLE_BYTE) {
word += n * 256**9;
} else {
word += (128 + nonce_bytes) * 256**9;
word += n * 256**(9 - nonce_bytes);
}
uint256 hash;
assembly {
let mem_start := mload(0x40) // get a pointer to free memory
mstore(0x40, add(mem_start, 0x20)) // update the pointer
mstore(mem_start, word) // store the rlp encoding
hash := sha3(mem_start,
add(tot_bytes, 1)) // hash the rlp encoding
}
// interpret hash as address (20 least significant bytes)
return address(hash);
}
//////////////////////////////////////////////////////////////////////////
// Generic ERC20
//////////////////////////////////////////////////////////////////////////
// owner -> amount
mapping(address => uint256) s_balances;
// owner -> spender -> max amount
mapping(address => mapping(address => uint256)) s_allowances;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// Spec: Get the account balance of another account with address `owner`
function balanceOf(address owner) public constant returns (uint256 balance) {
return s_balances[owner];
}
function internalTransfer(address from, address to, uint256 value) internal returns (bool success) {
if (value <= s_balances[from]) {
s_balances[from] -= value;
s_balances[to] += value;
Transfer(from, to, value);
return true;
} else {
return false;
}
}
// Spec: Send `value` amount of tokens to address `to`
function transfer(address to, uint256 value) public returns (bool success) {
address from = msg.sender;
return internalTransfer(from, to, value);
}
// Spec: Send `value` amount of tokens from address `from` to address `to`
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
address spender = msg.sender;
if(value <= s_allowances[from][spender] && internalTransfer(from, to, value)) {
s_allowances[from][spender] -= value;
return true;
} else {
return false;
}
}
// Spec: Allow `spender` to withdraw from your account, multiple times, up
// to the `value` amount. If this function is called again it overwrites the
// current allowance with `value`.
function approve(address spender, uint256 value) public returns (bool success) {
address owner = msg.sender;
if (value != 0 && s_allowances[owner][spender] != 0) {
return false;
}
s_allowances[owner][spender] = value;
Approval(owner, spender, value);
return true;
}
// Spec: Returns the `amount` which `spender` is still allowed to withdraw
// from `owner`.
// What if the allowance is higher than the balance of the `owner`?
// Callers should be careful to use min(allowance, balanceOf) to make sure
// that the allowance is actually present in the account!
function allowance(address owner, address spender) public constant returns (uint256 remaining) {
return s_allowances[owner][spender];
}
//////////////////////////////////////////////////////////////////////////
// GasToken specifics
//////////////////////////////////////////////////////////////////////////
uint8 constant public decimals = 2;
string constant public name = "Gastoken.io";
string constant public symbol = "GST2";
// We build a queue of nonces at which child contracts are stored. s_head is
// the nonce at the head of the queue, s_tail is the nonce behind the tail
// of the queue. The queue grows at the head and shrinks from the tail.
// Note that when and only when a contract CREATEs another contract, the
// creating contract's nonce is incremented.
// The first child contract is created with nonce == 1, the second child
// contract is created with nonce == 2, and so on...
// For example, if there are child contracts at nonces [2,3,4],
// then s_head == 4 and s_tail == 1. If there are no child contracts,
// s_head == s_tail.
uint256 s_head;
uint256 s_tail;
// totalSupply gives the number of tokens currently in existence
// Each token corresponds to one child contract that can be SELFDESTRUCTed
// for a gas refund.
function totalSupply() public constant returns (uint256 supply) {
return s_head - s_tail;
}
// Creates a child contract that can only be destroyed by this contract.
function makeChild() internal returns (address addr) {
assembly {
// EVM assembler of runtime portion of child contract:
// ;; Pseudocode: if (msg.sender != 0x0000000000b3f879cb30fe243b4dfee438691c04) { throw; }
// ;; suicide(msg.sender)
// PUSH15 0xb3f879cb30fe243b4dfee438691c04 ;; hardcoded address of this contract
// CALLER
// XOR
// PC
// JUMPI
// CALLER
// SELFDESTRUCT
// Or in binary: 6eb3f879cb30fe243b4dfee438691c043318585733ff
// Since the binary is so short (22 bytes), we can get away
// with a very simple initcode:
// PUSH22 0x6eb3f879cb30fe243b4dfee438691c043318585733ff
// PUSH1 0
// MSTORE ;; at this point, memory locations mem[10] through
// ;; mem[31] contain the runtime portion of the child
// ;; contract. all that's left to do is to RETURN this
// ;; chunk of memory.
// PUSH1 22 ;; length
// PUSH1 10 ;; offset
// RETURN
// Or in binary: 756eb3f879cb30fe243b4dfee438691c043318585733ff6000526016600af3
// Almost done! All we have to do is put this short (31 bytes) blob into
// memory and call CREATE with the appropriate offsets.
let solidity_free_mem_ptr := mload(0x40)
mstore(solidity_free_mem_ptr, 0x00756eb3f879cb30fe243b4dfee438691c043318585733ff6000526016600af3)
addr := create(0, add(solidity_free_mem_ptr, 1), 31)
}
}
// Mints `value` new sub-tokens (e.g. cents, pennies, ...) by creating `value`
// new child contracts. The minted tokens are owned by the caller of this
// function.
function mint(uint256 value) public {
for (uint256 i = 0; i < value; i++) {
makeChild();
}
s_head += value;
s_balances[msg.sender] += value;
}
// Destroys `value` child contracts and updates s_tail.
//
// This function is affected by an issue in solc: https://github.com/ethereum/solidity/issues/2999
// The `mk_contract_address(this, i).call();` doesn't forward all available gas, but only GAS - 25710.
// As a result, when this line is executed with e.g. 30000 gas, the callee will have less than 5000 gas
// available and its SELFDESTRUCT operation will fail leading to no gas refund occurring.
// The remaining ~29000 gas left after the call is enough to update s_tail and the caller's balance.
// Hence tokens will have been destroyed without a commensurate gas refund.
// Fortunately, there is a simple workaround:
// Whenever you call free, freeUpTo, freeFrom, or freeUpToFrom, ensure that you pass at least
// 25710 + `value` * (1148 + 5722 + 150) gas. (It won't all be used)
function destroyChildren(uint256 value) internal {
uint256 tail = s_tail;
// tail points to slot behind the last contract in the queue
for (uint256 i = tail + 1; i <= tail + value; i++) {
mk_contract_address(this, i).call();
}
s_tail = tail + value;
}
// Frees `value` sub-tokens (e.g. cents, pennies, ...) belonging to the
// caller of this function by destroying `value` child contracts, which
// will trigger a partial gas refund.
// You should ensure that you pass at least 25710 + `value` * (1148 + 5722 + 150) gas
// when calling this function. For details, see the comment above `destroyChilden`.
function free(uint256 value) public returns (bool success) {
uint256 from_balance = s_balances[msg.sender];
if (value > from_balance) {
return false;
}
destroyChildren(value);
s_balances[msg.sender] = from_balance - value;
return true;
}
// Frees up to `value` sub-tokens. Returns how many tokens were freed.
// Otherwise, identical to free.
// You should ensure that you pass at least 25710 + `value` * (1148 + 5722 + 150) gas
// when calling this function. For details, see the comment above `destroyChilden`.
function freeUpTo(uint256 value) public returns (uint256 freed) {
uint256 from_balance = s_balances[msg.sender];
if (value > from_balance) {
value = from_balance;
}
destroyChildren(value);
s_balances[msg.sender] = from_balance - value;
return value;
}
// Frees `value` sub-tokens owned by address `from`. Requires that `msg.sender`
// has been approved by `from`.
// You should ensure that you pass at least 25710 + `value` * (1148 + 5722 + 150) gas
// when calling this function. For details, see the comment above `destroyChilden`.
function freeFrom(address from, uint256 value) public returns (bool success) {
address spender = msg.sender;
uint256 from_balance = s_balances[from];
if (value > from_balance) {
return false;
}
mapping(address => uint256) from_allowances = s_allowances[from];
uint256 spender_allowance = from_allowances[spender];
if (value > spender_allowance) {
return false;
}
destroyChildren(value);
s_balances[from] = from_balance - value;
from_allowances[spender] = spender_allowance - value;
return true;
}
// Frees up to `value` sub-tokens owned by address `from`. Returns how many tokens were freed.
// Otherwise, identical to `freeFrom`.
// You should ensure that you pass at least 25710 + `value` * (1148 + 5722 + 150) gas
// when calling this function. For details, see the comment above `destroyChilden`.
function freeFromUpTo(address from, uint256 value) public returns (uint256 freed) {
address spender = msg.sender;
uint256 from_balance = s_balances[from];
if (value > from_balance) {
value = from_balance;
}
mapping(address => uint256) from_allowances = s_allowances[from];
uint256 spender_allowance = from_allowances[spender];
if (value > spender_allowance) {
value = spender_allowance;
}
destroyChildren(value);
s_balances[from] = from_balance - value;
from_allowances[spender] = spender_allowance - value;
return value;
}
}