Skip to content

Instantly share code, notes, and snippets.

View PeterBorah's full-sized avatar

Peter Borah PeterBorah

View GitHub Profile
FemtoStorage.slotFor("balances").and(userAddress).increment(); // Increases value by 1
FemtoStorage.slotFor("balances").and(userAddress).increaseBy(42); // Increases value by 42
FemtoStorage.slotFor("balances").and(userAddress).decreaseBy(42); // Decreases value by 42
@PeterBorah
PeterBorah / ListExample.sol
Created February 7, 2017 03:10
Example of a list in FemtoStorage
FemtoStorage.slotFor("someList").push(anAddress);
FemtoStorage.slotFor("someList").length(); // 1
FemtoStorage.slotFor("someList").index(0).getAddress(); // anAddress
pragma solidity ^0.4.7;
import "./Resolver.sol";
contract EtherRouter {
Resolver resolver;
function EtherRouter(Resolver _resolver) {
resolver = _resolver;
}
import "./Resolver.sol";
contract EtherRouter {
Resolver resolver;
address creator;
function EtherRouter(Resolver _resolver) {
resolver = _resolver;
creator = msg.sender;
}
calldatacopy(mload(0x40), 0, calldatasize)
delegatecall(gas, destination, mload(0x40), calldatasize, mload(0x40), outsize)
return(mload(0x40), outsize)
calldatacopy(mload(0x40), 0, calldatasize)
delegatecall(gas, destination, mload(0x40), calldatasize, mload(0x40), outsize)
contract EtherRouter {
function() {
// Look up the latest version of the code, and delegatecall
}
}
contract EtherRouter {
function() {
// Look up the latest version of the contract, and then delegatecall.
}
}
import "BrokenToken.sol";
contract Bounty {
// This bounty will pay out if you can cause BrokenToken's balance
// to be lower than its totalSupply, which would mean that it doesn't
// have sufficient ether for everyone to withdraw.
uint public totalBounty;
bool public claimed;
mapping(address => address) public owners;
contract TokenWithInvariants {
mapping(address => uint) public balanceOf;
uint public totalSupply;
modifier checkInvariants {
_
if (this.balance < totalSupply) throw;
}
function deposit(uint amount) checkInvariants {