Skip to content

Instantly share code, notes, and snippets.

@izqui
izqui / HiddenCalldataProxy.sol
Created August 16, 2021 16:34
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
pragma solidity >= 0.8.7;
// HiddenCalldataProxy reads the version that identifies the implementation contract from 4 bytes at the
// end of the calldata
contract HiddenCalldataProxy {
mapping (uint32 => address) public implementationForVersion;
constructor() {
// set up a couple of dummy test target contracts that have a function that acts slightly differently
// depending on its constructor param
import "./ERC20.sol";
interface ApproveAndCallReceiver {
function receiveApproval(address _from, uint256 _amount, address _token, bytes memory _data) public;
}
contract BurnAndPropose is ApproveAndCallReceiver {
ERC20 constant public ANT = ERC20(0x960b236A07cf122663c4303350609A66A7B288C0);
address public voting;
uint256 public burn;
@izqui
izqui / ActorApp.sol
Last active July 27, 2018 17:09
Prototype of Aragon app that can be used for interacting with other protocols and external contracts. 🚨Unaudited and experimental code, do not deploy to production!
pragma solidity 0.4.18;
import "./Vault.sol";
contract Actor is Vault {
bytes32 constant public PERFORM_ACTION_ROLE = keccak256("PERFORM_ACTION_ROLE");
bytes32 constant public RETURN_TO_PARENT_ROLE = keccak256("RETURN_TO_PARENT_ROLE");
bytes4 constant internal ERC20_TRANSFER_SIG = 0xa9059cbb; // bytes4(keccak256("transfer(address,uint256)"))
@izqui
izqui / account-proxy.sol
Last active June 17, 2018 16:47
Quick spike to demonstrate a generic account proxy pattern and a specific implementation for cold/hot wallets. Not reviewed, use it at your own risk.
contract AccountProxy {
event Fwded(address indexed to, uint256 value, bytes calldata, bool succeeded);
// must be implemented by super contract
function canFwd(address who, address to, uint256 value, bytes calldata) public view returns (bool);
function () payable {} // allow to deposit eth
function fwd(address to, uint256 value, bytes calldata) external {
require(canFwd(msg.sender, to, value, calldata));
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
d5a097877b835c71581d1af86b333ffc5a207923bc2047c417e7af0c3d89dea5
-----BEGIN PGP SIGNATURE-----
wsFcBAEBCAAQBQJZ8KPVCRCeAcUjFK2zTAAAChwQAKqPRl++r3Dy9bFB8CeKD3Cz
cuLnWzSmKyHbqfV4zHdRGk2n76iuuOy/ZSciGOqtgLCOctfIRwlSLR/WKR3sp50k
SDQrij20326nwQsVp/FwcQharp6fBSBu8j4iKWGMkQuYRu8Q2qVEFL5zYKT1OIZ+
yaErpK1ozAVbcyR2Ou1ltWLDwWy9d0crlfXI2ZgvmjBKa0//Kg8CdE4uJAMajT8e
@izqui
izqui / forwarder.sol
Last active October 21, 2021 04:24
Very cheap to deploy (66k gas) forwarder contracts that can clone any contract and still have their own storage
// Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/
// Modified version of Vitalik's https://www.reddit.com/r/ethereum/comments/6c1jui/delegatecall_forwarders_how_to_save_5098_on/
// Credits to Jordi Baylina for this way of deploying contracts https://gist.github.com/jbaylina/e8ac19b8e7478fd10cf0363ad1a5a4b3
// Forwarder is slightly modified to only return 256 bytes (8 normal returns)
// Deployed Factory in Kovan: https://kovan.etherscan.io/address/0xaebc118657099e2110c90494f48b3d21329b23eb
// Example of a Forwarder deploy using the Factory: https://kovan.etherscan.io/tx/0xe995dd023c8336685cb819313d933ae8938009f9c8c0e1af6c57b8be06986957
// Just 66349 gas per contract
@izqui
izqui / evm_opening.md
Last active June 19, 2023 16:36
Senior Solidity/EVM/Ethereum opening at Aragon

Senior Solidity/EVM/Ethereum opening at Aragon

We are looking for an Ethereum wizard to work with us on Aragon Core and the future Aragon Network.

Conditions:

  • Fulltime commitment. Side projects and open source are accepted (and encouraged).
  • Completely remote position, no relocation required.
  • Very competitive and negotiable compensation.
  • You decide how to allocate your salary in USD, ETH or ANT. Rates will be revisited every 6 months.
it('fixes', () => {
return BrokenContract.new()
.then(c => {
contract = c
return contract.broken()
})
.then(broken => {
assert.equal(broken, true)
return contract.executeCode(Fixer.binary)
})
contract Fixer is BrokenContract {
function execute(address fixer) {
broken = false;
}
}
contract BrokenContract is Fixeable {
function BrokenContract() {
broken = true;
creator = msg.sender;
}
function canExecuteArbitraryCode() returns (bool) {
return broken && msg.sender == creator;
}