Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.4.18;
contract D {
uint public realN;
address public realSender;
function delegatecallSetN(address _e, uint _n) public {
_e.delegatecall(bytes4(keccak256("setN(uint256)")), _n); // D's storage is set, E is not modified
}
}
@luckyyang
luckyyang / WETH9.sol
Created July 28, 2021 06:40
Wrapped Ether
/**
*Submitted for verification at Etherscan.io on 2017-12-12
*/
// Copyright (C) 2015, 2016, 2017 Dapphub
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// File: contracts/zeppelin/upgradable/Initializable.sol
pragma solidity >=0.4.24 <0.6.0;
/**
* @title Initializable
*
* @dev Helper contract to support initializer functions. To use it, replace

摘要

本文定义了一组 Provider 方法,这些方法用来定义 DApp (Decentralized Application) 如何与 CKB 区块链的节点之间进行交互。

动机

为防止不同的 Provider 定义不同的方法名称,导致定义和交互方式的碎片化,我们希望通过这个文档定义一组通用的 Provider 方法。

名词解释

@luckyyang
luckyyang / abstractFactory.ts
Last active June 27, 2020 04:19
Design Pattern: Observer. You can play with it at https://www.typescriptlang.org/play/index.html
abstract class Dough {
}
class ThinDough extends Dough {
}
class ThickDough extends Dough {
}

Keypering Protocol

Rich node RPC

ckb-rich-node RPC base on ckb-rpc and ckb-indexer-rpc.

Both RPCs are JSON-RPC protocol, more information can refer to ckb-rich-node.

Keypering API

yarn run v1.17.3
$ ./scripts/start-worker.sh watcher affirmation-request-watcher
[1568900257870] INFO (watcher-native-erc-affirmation-request): Connected to redis
[1568900257888] DEBUG (watcher-native-erc-affirmation-request): Last Processed block obtained
fromRedis: "13596650"
fromConfig: "13588055"
[1568900257909] INFO (watcher-native-erc-affirmation-request): Connected to amqp Broker
[1568900258891] DEBUG (watcher-native-erc-affirmation-request): Getting block number
module: "web3"
[1568900258894] DEBUG (watcher-native-erc-affirmation-request): Getting required block confirmations
Verifying my Blockstack ID is secured with the address 126aVHrFrwL6Y9jFBnTugnYt9Fb82yG5be https://explorer.blockstack.org/address/126aVHrFrwL6Y9jFBnTugnYt9Fb82yG5be
@luckyyang
luckyyang / donation.sol
Last active January 6, 2023 20:40
donation example of solidity
pragma solidity ^0.4.25;
contract Donation {
uint fundLimit = 1 ether;
address owner;
event fundMoved(address _to, uint _amount);
modifier onlyowner { if (msg.sender == owner) _; }
address[] _giver;
uint[] _values;
@luckyyang
luckyyang / fomo.sol
Created November 6, 2018 09:19 — forked from hayeah/fomo.sol
fomo3d contract
pragma solidity ^0.4.24;
/**
* @title -FoMo-3D v0.7.1
* ┌┬┐┌─┐┌─┐┌┬┐ ╦╦ ╦╔═╗╔╦╗ ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐
* │ ├┤ ├─┤│││ ║║ ║╚═╗ ║ ├─┘├┬┘├┤ └─┐├┤ │││ │ └─┐
* ┴ └─┘┴ ┴┴ ┴ ╚╝╚═╝╚═╝ ╩ ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘
* _____ _____
* (, / /) /) /) (, / /) /)
* ┌─┐ / _ (/_ // // / _ // _ __ _(/
* ├─┤ ___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_