Skip to content

Instantly share code, notes, and snippets.

View CJ42's full-sized avatar

Jean Cvllr CJ42

View GitHub Profile
@CJ42
CJ42 / devdoc.json
Created June 23, 2019 20:31
JSON Dev-Doc Napstec Solidity
{
"author" : "Jean Cavallera",
"details" : "All function calls are currently implemented without side effects",
"methods" :
{
"calculateHypothenuse(uint256,uint256)" :
{
"details" : "Not working as it returns integers and not float",
"params" :
{
@CJ42
CJ42 / .deps...npm...@openzeppelin...contracts...utils...cryptography...ECDSA.sol
Created August 27, 2021 10:53
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.4+commit.c7e474f2.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
@CJ42
CJ42 / Ethereum-Yellow-Paper-Symbols.md
Last active March 16, 2023 15:54
Ethereum Yellow Paper - Symbols Summary

Summary of the symbols in the Ethereum Yellow Paper.

Can be used as a reference and support for building and Ethereum client.

General

Symbol Symbol name (in Math or plain english) Meaning in the yellow paper
mu Machine state
sigma World State
@CJ42
CJ42 / Sablier.sol
Created April 12, 2022 05:13
Brief example from Sablier protocol to show one line if statements in Solidity
pragma solidity =0.5.17;
// import statements ...
/**
* @title Sablier
* @author Sablier
* @notice Money streaming.
*/
contract Sablier is ISablier, ReentrancyGuard, CarefulMath {
@CJ42
CJ42 / Sablier.sol
Created April 12, 2022 06:13
Example from Sablier to explain external calls with if statements
pragma solidity =0.5.17;
// import statements (omitted for brievity) ...
/**
* @title Sablier
* @author Sablier
* @notice Money streaming.
*/
contract Sablier is ISablier, ReentrancyGuard, CarefulMath {
@CJ42
CJ42 / Sablier.sol
Created April 12, 2022 06:15
Practical Example from Sablier to explain return inside if statement
pragma solidity =0.5.17;
// import statements (omitted for brievity) ...
/**
* @title Sablier
* @author Sablier
* @notice Money streaming.
*/
contract Sablier is ISablier, ReentrancyGuard, CarefulMath {
@CJ42
CJ42 / LSP6KeyManagerCore.sol
Last active April 27, 2022 23:44
code from the KeyManager contract from LUKSO to explain omitting parentheses in if statements
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.6;
// imports and errors declarations omitted for brievity ...
/**
* @title Core implementation of a contract acting as a controller of an ERC725 Account, using permissions stored in the ERC725Y storage
* @author Fabian Vogelsteller, Jean Cavallera
* @dev all the permissions can be set on the ERC725 Account using `setData(...)` with the keys constants below
*/
@CJ42
CJ42 / Votes.sol
Created April 12, 2022 22:18
Bad example of loops in storage
pragma solidity ^0.8.0;
/// THIS IS STILL A NEGATIVE EXAMPLE! DO NOT USE!
contract Voting {
mapping(address => uint) voteWeight;
address[] yesVotes;
uint requiredWeight;
@CJ42
CJ42 / HexString.sol
Created April 14, 2022 19:43
function `toString` as an example of how `while` loops are used in Solidity
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.7.6;
/// @title HexStrings
/// Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/8dd744fc1843d285c38e54e9d439dea7f6b93495/contracts/utils/Strings.sol
library HexStrings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/// @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
@CJ42
CJ42 / Bytes-Uint-equivalence.md
Last active December 1, 2022 12:00
Solidity Table that summarizes the equivalent number of bits / bytes to convert between signed / unsigned integer (`intN` / `uintN`) and `bytesN`

 bytesN / uintM table equivalence for Solidity

uintM bytesN
uint8 bytes1
uint16 bytes2
uint24 bytes3
uint32 bytes4
uint40 bytes5
uint48 bytes6