Skip to content

Instantly share code, notes, and snippets.

View simondlr's full-sized avatar
Working on "This Artwork Is Always On Sale".

Simon de la Rouviere simondlr

Working on "This Artwork Is Always On Sale".
View GitHub Profile
simondlr / gist:48b77206b2483932f0f5
Last active June 30, 2021 02:01
Function hooks in Solidity
contract Function_hook_example {
function Function_hook_example() {
owner = msg.sender;
modifier isOwner {
if (msg.sender == owner) {
contract ETHUSDHandler {
function pay(string _cid,
address _oracle,
address _buyer, // this is for the case that someone else pays on your behalf
address[] _beneficiaries,
uint256[] _amounts,
address[] _notifiers) public payable {
require(_beneficiaries.length == _amounts.length);
pragma solidity 0.4.19;
import "./utils/strings.sol"; //
contract Registry {
using strings for *;
event LogPublish(address issuer, address subject, bytes32 action, bytes32 contentType, string cid);
function publish(address[] _subjects, bytes32[] _actions, bytes32[] _contentTypes, string _cids) public {
require(_subjects.length == _actions.length && _actions.length == _contentTypes.length);
simondlr / gist:45f0c8024a88d8dc54f8
Last active January 16, 2018 20:30
Standard Token Contract on Ethereum
//Most, basic default, standardised Token contract.
//Based on standardised APIs & slightly extended.
//adds AddressApproval & AddressApprovalOnce events
//approve & approveOnce works on premise that approved always takes precedence.
//adds unapprove to basic coin interface.
contract Coin {
function sendCoin(uint _value, address _to) returns (bool _success) {}
function sendCoinFrom(address _from, uint _value, address _to) returns (bool _success) {}
function coinBalance() constant returns (uint _r) {}
pragma solidity ^0.4.10;
import "./ETHUSDHandler.sol";
contract ETHUSDHandlerFactory {
mapping(address => address[]) public userToHandlers;
function createNewHandler (
address _beneficiary,
uint256 _initialPriceInUSD,
simondlr / gist:b08f32eeb8f9eec52ec4124d13c18242
Last active January 19, 2017 14:55
Barclays Prague Comms. Communicate here.
Barclays Prague Comms:
-> Paste address and other things in the comments.
simondlr / gist:cd13348d0f578e2f5cd49cb7f5501801
Created November 30, 2016 20:17
Testing throws in Solidity
pragma solidity ^0.4.4;
This is for testing if a transaction would throw.
Contract calls rethrow when it encounters errors.
Raw calls do not.
You wrap your contract you want to test in a ThrowProxy.
You prime it by calling the fallback function.
Then executing it.
simondlr / gist:f48c5f47d06a0d4662b999903826bebf
Last active November 25, 2016 12:40
Private Network Test
Simon's peer:
Simon's IP:
Do. admin.addPeer("enode://56d33cb7dcd7bcf147e18597ef6ea4270c2202bf3e63905ba9d95916c44ef0ac17a9dfae3afe2c38cb31967bbb813c48482e5294497ba6f7df20da09793ba49a@")
Create Genesis Block using "sh"
then run:
simondlr /
Created June 5, 2012 17:34
# Create your views here.
from django.http import HttpResponse
from app import tasks
def test_celery(request):
result = tasks.sleeptask.delay(10)
result_one = tasks.sleeptask.delay(10)
result_two = tasks.sleeptask.delay(10)
return HttpResponse(result.task_id)