Skip to content

Instantly share code, notes, and snippets.

@vieyang
vieyang / ProxyRouter.sol
Last active July 9, 2021 07:14
Proxy Router
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Impl {
event LogData(bytes lData);
function log() public {
@vieyang
vieyang / external_call.sol
Created August 11, 2020 07:11
Send value and data to an unknown address inside the contract
function external_call0(address destination, uint value, uint dataLength, bytes data) internal returns (bool) {
return (destination.call.value(tx.value)(tx.data))
}
function external_call1(address destination, uint value, uint dataLength, bytes data) internal returns (bool) {
bool result;
assembly {
let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
pragma solidity ^0.4.24;
/**
* Utility library of inline functions on addresses
*/
library Address {
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*/
/*
* References:
* 1. https://uploads-ssl.webflow.com/5ad71ffeb79acc67c8bcdaba/5ad8d1193a40977462982470_scalable-reward-distribution-paper.pdf
* 2. https://eips.ethereum.org/EIPS/eip-1973
*/
pragma solidity 0.4.24;
contract Test {
// using SafeMath for uint256;
test
@vieyang
vieyang / install-redis.sh
Created September 12, 2018 13:11 — forked from khelll/install-redis.sh
Installing Redis on Amazon Linux
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=3.2.0
echo "*****************************************"
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make"
@vieyang
vieyang / MySunshine
Created May 4, 2018 02:12
MySunshine
pragma solidity ^0.4.8;
contract ERC20Interface {
function totalSupply() public constant returns (uint256 supply);
function balance() public constant returns (uint256);
function balanceOf(address _owner) public constant returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
@vieyang
vieyang / test
Created October 28, 2016 09:19
test
test