Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/8 #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Pr/8 #24

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions contract/GST2_ETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,39 @@ contract GasToken2 is Rlp {
// 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)
// We can use Solidity's scratch space located at [0..64).
mstore(0, 0x756eb3f879cb30fe243b4dfee438691c043318585733ff6000526016600af300)
addr := create(0, 0, 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();
assembly {
mstore(0, 0x756eb3f879cb30fe243b4dfee438691c043318585733ff6000526016600af300)
for {let i := shr(value, 5)} i {i := sub(i, 1)} {
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
pop(create(0, 0, 31)) pop(create(0, 0, 31))
}
for {let i := and(value, 0x1F)} i {i := sub(i, 1)} {
pop(create(0, 0, 31))
}
}
s_head += value;
s_balances[msg.sender] += value;
Expand Down