This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
// Block Header | |
const version = 1; | |
const previousBlockHash = 'ABC123'; | |
const merkleRoot = 'XYZ789'; | |
const timestamp = 1642931200; | |
let nonce = 0; | |
// Difficulty Target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
function calculateMerkleRoot(transactions) { | |
if (transactions.length === 0) { | |
return null; | |
} | |
// Create a copy of the transactions array | |
let hashes = [...transactions]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Root | |
| | |
----------------------------------- | |
| | | |
0x123 0x456 | |
| | | |
------------------- ------------------- | |
| | | | | |
"balance" "nonce" "storage" "code" | |
| | | | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract MyContract { | |
// State variables | |
uint public myVariable; | |
// Events | |
event MyEvent(uint indexed value); | |
// Constructor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
contract Proxy { | |
address private _implementation; | |
event Upgraded(address indexed implementation); | |
constructor(address implementation_) { | |
_implementation = implementation_; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |