mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 12:51:01 +00:00
Emerge Yul recompiler (#1)
Provide a modified (and incomplete) version of ZKSync zksolc that can compile the most basic contracts
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
contract Computation {
|
||||
function triangle_number(int64 n) public pure returns (int64 sum) {
|
||||
unchecked {
|
||||
for (int64 x = 1; x <= n; x++) {
|
||||
sum += x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function odd_product(int32 n) public pure returns (int64) {
|
||||
unchecked {
|
||||
int64 prod = 1;
|
||||
for (int32 x = 1; x <= n; x++) {
|
||||
prod *= 2 * int64(x) - 1;
|
||||
}
|
||||
return prod;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.0/contracts/token/ERC20/IERC20.sol
|
||||
interface IERC20 {
|
||||
function totalSupply() external view returns (uint);
|
||||
|
||||
function balanceOf(address account) external view returns (uint);
|
||||
|
||||
function transfer(address recipient, uint amount) external returns (bool);
|
||||
|
||||
function allowance(address owner, address spender) external view returns (uint);
|
||||
|
||||
function approve(address spender, uint amount) external returns (bool);
|
||||
|
||||
function transferFrom(
|
||||
address sender,
|
||||
address recipient,
|
||||
uint amount
|
||||
) external returns (bool);
|
||||
|
||||
event Transfer(address indexed from, address indexed to, uint value);
|
||||
event Approval(address indexed owner, address indexed spender, uint value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
contract ERC20 is IERC20 {
|
||||
uint public totalSupply;
|
||||
mapping(address => uint) public balanceOf;
|
||||
mapping(address => mapping(address => uint)) public allowance;
|
||||
string public name = "Solidity by Example";
|
||||
string public symbol = "SOLBYEX";
|
||||
uint8 public decimals = 18;
|
||||
|
||||
function transfer(address recipient, uint amount) external returns (bool) {
|
||||
balanceOf[msg.sender] -= amount;
|
||||
balanceOf[recipient] += amount;
|
||||
emit Transfer(msg.sender, recipient, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
function approve(address spender, uint amount) external returns (bool) {
|
||||
allowance[msg.sender][spender] = amount;
|
||||
emit Approval(msg.sender, spender, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
function transferFrom(
|
||||
address sender,
|
||||
address recipient,
|
||||
uint amount
|
||||
) external returns (bool) {
|
||||
allowance[sender][msg.sender] -= amount;
|
||||
balanceOf[sender] -= amount;
|
||||
balanceOf[recipient] += amount;
|
||||
emit Transfer(sender, recipient, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
function mint(uint amount) external {
|
||||
balanceOf[msg.sender] += amount;
|
||||
totalSupply += amount;
|
||||
emit Transfer(address(0), msg.sender, amount);
|
||||
}
|
||||
|
||||
function burn(uint amount) external {
|
||||
balanceOf[msg.sender] -= amount;
|
||||
totalSupply -= amount;
|
||||
emit Transfer(msg.sender, address(0), amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
contract Flipper {
|
||||
bool coin;
|
||||
|
||||
function flip() public payable {
|
||||
coin = !coin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user