Skip to content

Instantly share code, notes, and snippets.

View gentlyawesome's full-sized avatar
🏠
Working from home

Arc Angelo Ibalio gentlyawesome

🏠
Working from home
  • Philippines
View GitHub Profile
const crypto = require('crypto');
// Block Header
const version = 1;
const previousBlockHash = 'ABC123';
const merkleRoot = 'XYZ789';
const timestamp = 1642931200;
let nonce = 0;
// Difficulty Target
const crypto = require('crypto');
function calculateMerkleRoot(transactions) {
if (transactions.length === 0) {
return null;
}
// Create a copy of the transactions array
let hashes = [...transactions];
Root
|
-----------------------------------
| |
0x123 0x456
| |
------------------- -------------------
| | | |
"balance" "nonce" "storage" "code"
| | | |
const CryptoJS = require('crypto-js');
// Create an array of data items
const data = ['data1', 'data2', 'data3', 'data4'];
// Function to generate Merkle tree
function generateMerkleTree(data) {
if (data.length === 0) return [];
if (data.length === 1) {
pragma solidity ^0.8.0;
contract MyContract {
// State variables
uint public myVariable;
// Events
event MyEvent(uint indexed value);
// Constructor
pragma solidity ^0.8.0;
contract Proxy {
address private _implementation;
event Upgraded(address indexed implementation);
constructor(address implementation_) {
_implementation = implementation_;
}
@gentlyawesome
gentlyawesome / .deps...npm...hardhat...console.sol
Created July 6, 2023 00:36
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >= 0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
function _sendLogPayload(bytes memory payload) private view {
uint256 payloadLength = payload.length;
address consoleAddress = CONSOLE_ADDRESS;
assembly {
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.19;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.19;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.19;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to