Skip to content

Instantly share code, notes, and snippets.

View Dan-Nolan's full-sized avatar
🏗️
Building!

Dan Nolan Dan-Nolan

🏗️
Building!
View GitHub Profile
@Dan-Nolan
Dan-Nolan / AaveEscrow.sol
Last active December 6, 2022 12:34
AaveEscrow.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// buyer - puts the funds in the account
// arbiter - ability to move the funds
// recipient - receiver of the funds
// ERC20s common standard for tokens
interface IWethGateway {
// https://goerli.etherscan.io/address/0xa423c1448d195d9cf2e06d343e30b35f501159ed
contract First {
event Winner(address);
function test() external {
emit Winner(msg.sender);
}
}
// https://goerli.etherscan.io/address/0x9a9a776bc00eb386fb56bb3a57e6b78595d93bf3
@Dan-Nolan
Dan-Nolan / Simple.sol
Created November 8, 2022 21:55
First Test
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract HelloWorld {
bool public success;
function doTheMath(uint _x, uint _y) external {
require(_x + _y == 42);
require(_x > 0 && _y > 0);
success = true;
@Dan-Nolan
Dan-Nolan / index.js
Created October 8, 2021 18:30
Elliptic Key Utils
const EC = require('elliptic').ec;
const ec = new EC('secp256k1');
// private/public key pair generation
const key = ec.genKeyPair();
// to public key hex string (04...)
const hexPublicKey = key.getPublic().encode('hex');
// from hex string back to the elliptic key object (this key can verify)
@Dan-Nolan
Dan-Nolan / synonyms.js
Created July 24, 2020 14:34
Array Method Synonyms
// For learning purposes only!
// Don't pollute the Array prototype in an application
// map synonym
Array.prototype.transform = function(callback) {
const newArr = [];
for(let i = 0; i < this.length; i++) {
newArr.push(callback(this[i]));
}
return newArr;
@Dan-Nolan
Dan-Nolan / MerkleTree.js
Created July 9, 2020 20:22
MerkleTree.js
class MerkleTree {
constructor(leaves, concat) {
this.leaves = leaves;
this.concat = concat;
}
getProof(index, leaves = this.leaves, proof = []) {
if (leaves.length === 1) {
return proof;
}
let newLayer = [];
const SHA256 = require('crypto-js/sha256');
const TARGET_DIFFICULTY = BigInt(0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
const MAX_TRANSACTIONS = 10;
const mempool = [];
const blocks = [];
function addTransaction(transaction) {
mempool.push(transaction);
}
@Dan-Nolan
Dan-Nolan / testConstant.js
Created May 20, 2020 14:34
Kovan Constant
const ethers = require('ethers');
const provider = ethers.getDefaultProvider('kovan');
const CONTACT_ADDR = "0xae4b4bda19d53178ebbad7737ba34beaa0107c18";
const ABI = [
{
"constant": true,
"inputs": [],
"name": "activeLength",
"outputs": [
@Dan-Nolan
Dan-Nolan / block.json
Last active February 20, 2020 16:51
Ethereum Block 46147
{
"difficulty": "0x153886c1bbd",
"extraData": "0x657468706f6f6c2e6f7267",
"gasLimit": "0x520b",
"gasUsed": "0x5208",
"hash": "0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0xe6a7a1d47ff21b6321162aea7c6cb457d5476bca",
"mixHash": "0xb48c515a9dde8d346c3337ea520aa995a4738bb595495506125449c1149d6cf4",
"nonce": "0xba4f8ecd18aab215",
@Dan-Nolan
Dan-Nolan / Verify.js
Created September 6, 2019 00:59
Verify.js
function verifyProof(proof, node, root, concat) {
for(let i = 0; i < proof.length; i++) {
let { left, data } = proof[i];
if(left) {
node = concat(data, node);
}
else {
node = concat(node, data);
}
}