Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-latest.js&optimize=undefined&gist=
// 21,030
contract Fallback {
uint deposits = 0;
}
// Transaction: 41,143
// Execution: 20,143
contract FallbackDeposit {
uint deposits = 0;
function() {
deposits++;
}
}
// Transaction: 21,071
// Execution: 71
contract FallbackConditionalFalse {
uint deposits = 0;
function() {
if(false) {
deposits++;
}
}
}
// Transaction: 41,163
// Execution: 20,163
contract FallbackConditionalTrue {
uint deposits = 0;
function() {
if(true) {
deposits++;
}
}
}
// Transaction cost: 41226 gas.
// Execution cost: 20226 gas
contract FallbackMultiAccount {
mapping (address => uint) balances;
function() {
balances[msg.sender] += msg.value;
}
}
// Transaction cost: 186937 gas.
// Execution cost: 165937 gas
contract FallbackStoreStruct {
struct Request {
uint a;
uint b;
uint c;
uint d;
uint e;
uint f;
uint g;
uint h;
}
uint min;
mapping (address => uint) balances;
mapping (address => Request) requests;
function() {
balances[msg.sender] += msg.value;
if(balances[msg.sender] >= min) {
requests[msg.sender] = Request(0, 1, 2, 3, 4, 5, 6, 7);
}
}
}
// Transaction cost: 61671 gas.
// Execution cost: 40671 gas.
contract FallbackStoreHash {
uint min;
mapping (address => uint) balances;
mapping (address => bytes16) requests;
function() {
balances[msg.sender] += msg.value;
if(balances[msg.sender] >= min) {
requests[msg.sender] = bytes16(12345);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.