Last active
November 18, 2022 19:31
-
-
Save Shungy/80ef3fd04ecba5a7565775f2ade6a7bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
// The Setup | |
// --------- | |
// Alice, Bob, and Mallory have a tea party | |
// Alice decided to give everyone tokens! | |
// Alice sets up a Proxy contract and a Token contract | |
// The tokens are shared between the three friends | |
// initialSupply is 30000000000000 | |
// But are they truly friends? Or ex-friends? | |
// What could go wrong?! | |
contract Proxy { | |
uint256 public initializer; | |
mapping(address => uint256) private _balances; | |
uint256 private _totalSupply; | |
string public name; | |
string public symbol; | |
address public immutable implementation; | |
constructor(address implementationaddr) { | |
implementation = implementationaddr; | |
} | |
fallback () external { | |
address impl = implementation; | |
assembly { | |
calldatacopy(0, 0, calldatasize()) | |
let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0) | |
returndatacopy(0, 0, returndatasize()) | |
switch result | |
case 0 { revert(0, returndatasize()) } | |
default { return(0, returndatasize()) } | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract Token { | |
uint256 public initializer; | |
mapping(address => uint256) private _balances; | |
uint256 private _totalSupply; | |
string public name; | |
string public symbol; | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
function initialize( | |
string memory _name, | |
string memory _symbol, | |
uint256 initialSupply, | |
address _bob, | |
address _mallory | |
) | |
public | |
{ | |
require(initializer == 0); | |
initializer += 1; | |
name = _name; | |
symbol = _symbol; | |
_mint(msg.sender, initialSupply/3); | |
_mint(_bob, initialSupply/3); | |
_mint(_mallory, initialSupply/3); | |
} | |
function balanceOf(address account) public view virtual returns (uint256) { | |
return _balances[account]; | |
} | |
function _mint(address account, uint256 amount) internal virtual { | |
// functions as it should | |
} | |
function transfer(address to, uint256 amount) public virtual returns (bool) { | |
// functions as it should | |
} | |
function burn(uint256 amount) public virtual { | |
// functions as it should | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment