Skip to content

Instantly share code, notes, and snippets.

View alexvandesande's full-sized avatar
🤖
Preventing human machine conflicts

Alex Van de Sande alexvandesande

🤖
Preventing human machine conflicts
View GitHub Profile
@alexvandesande
alexvandesande / Random generator
Last active December 23, 2022 09:10
A very simple random generator. A miner can influence the number by not publishing a block with an unwanted outcome, and forfeiting the 5 block reward.
contract random {
/* Generates a random number from 0 to 100 based on the last block hash */
function randomGen(uint seed) constant returns (uint randomNumber) {
return(uint(sha3(block.blockhash(block.number-1), seed ))%100);
}
/* generates a number from 0 to 2^n based on the last n blocks */
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
uint n = 0;
for (uint i = 0; i < size; i++){
@alexvandesande
alexvandesande / Proposal.js
Last active April 5, 2022 08:05
Proposal Framework for The DAO
/*
The contract is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The contract is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/*
# Time Locked Multisig
This is a different twist on the Congress DAO / Multisig. Instead of every action requiring the approval of an X number of members, instead any transactions can be initiated by a single member, but they all will require a minimum amount of delay before they can be executed, which varies according to the support that transaction has. The more approvals a proposal has, the sooner it can be executed. A member can vote against a transaction, which will mean that it will cancel one of the other approved signatures. In a 5 members DAO, each vote means the time to wait dimishes by 10x.
This means that if you don't have urgency, one or two signatures might be all you need to execute any transaction. But if a single key is compromised, other keys can delay that transaction for years, making sure that the main account is emptied out way before that.
Transaction delays:
@alexvandesande
alexvandesande / ethernalsale.js
Last active October 21, 2021 04:40
This is a first draft at what could be a continuous token sale. I just wrote it and haven't tested it but it shows the proof of concept: tokens are continuously generated in any curve desired and sold for the highest bidder. Since there's a maximum token sale speed, this guarantees that sales can't end too quickly. Since the sale always starts f…
pragma solidity ^0.4.2;
contract ethernalSale {
struct order {
uint amount;
address buyer;
}
mapping (uint => order) orderBook;
mapping (address => uint) balanceOf;
pragma solidity ^0.4.20;
contract MyToken {
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
/* Initializes contract with initial supply tokens to the creator of the contract */
function MyToken(
uint256 initialSupply
) public {
/*
Foundation Tip Contract
Address: 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359
Bitcoin Shapeshift Address: 1GyczDXWjFbmhx2Qau4ham3zJqNEP8UcEG (if transaction fails it is sent to 39BaMQCphFXyYAvcoGpeKtnptLJ9v6cdFY instead)
Interface: [{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"proposals","outputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"},{"name":"description","type":"string"},{"name":"votingDeadline","type":"uint256"},{"name":"executed","type":"bool"},{"name":"proposalPassed","type":"bool"},{"name":"numberOfVotes","type":"uint256"},{"name":"currentResult","type":"int256"},{"name":"proposalHash","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"proposalNumber","type":"uint256"},{"name":"transactionBytecode","type":"bytes"}],"name":"executeProposal","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"memberId","outputs":[{"name":"","type":"uint

Abstract

One of the biggest pain point for users in ethereum:

  • users don't want to think about ether
  • users don't want to think about backing up private keys or seed phrases
  • users need to set up 2 factor authentication to be secure
  • users want to be able to have a simple identifiable username
  • users want to be able to pay for transactions using what they already have on the system, be apple pay, xbox points or even a credit card
  • users want to use the same username accross multiple devices in a trustless manner
Address: 0xdbf03b407c01e7cd3cbea99509d93f8dddc8c6fb
ABI:
[ { "constant": true, "inputs": [ { "name": "", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "", "template": "elements_input_uint", "value": "" } ], "name": "proposals", "outputs": [ { "name": "recipient", "type": "address" }, { "name": "amount", "type": "uint256" }, { "name": "description", "type": "string" }, { "name": "votingDeadline", "type": "uint256" }, { "name": "executed", "type": "bool" }, { "name": "proposalPassed", "type": "bool" }, { "name": "numberOfVotes", "type": "uint256" }, { "name": "currentResult", "type": "int256" }, { "name": "proposalHash", "type": "bytes32" } ], "type": "function", "displayName": "proposals" }, { "constant": false, "inputs": [ { "name": "proposalNumber", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "proposal Number", "template": "elements_input_uint" }, { "name": "transactionBytecode", "type": "bytes", "typeShort": "bytes", "bits": "", "displayName": "tra
/*
One of the takeaways I had from the ENS workshop, is that if buying domains
from secundary services is easy and quick, it will take the pressure off the
main ENS system to be perfect. So since I didn’t see any decent reselling
contract I decided to try my luck on my own. It's not yet finalized but shows
some characteristics I want on the service.
## Both instant buy and actions
One of the feedbacks I had is that many domain owners do not know how to price