Skip to content

Instantly share code, notes, and snippets.

View serial-coder's full-sized avatar
🎯
Focusing

Phuwanai Thummavet serial-coder

🎯
Focusing
View GitHub Profile
@DMontgomery40
DMontgomery40 / CODEX.md
Last active June 30, 2026 08:31
Ralph audit loop: Codex CLI read-only code audit runner

Ralph Audit Agent Instructions (OpenAI Codex)


Safety Notice (Customize)

If this codebase is production, handles money, or touches sensitive data: treat this audit loop as a high-risk operation. Run with least privilege, avoid exporting long-lived credentials in your shell, and keep the agent in read-only mode.


@ripwu
ripwu / UnstructuredStorageProxy.png
Last active April 26, 2025 04:22
solution to the exercise
UnstructuredStorageProxy.png
@spalladino
spalladino / Loans.sol
Created March 20, 2021 16:57
Strawman for flashloans for flashbots
pragma solidity ^0.7.0;
// Each mining pool that intends to provide flash loans deploys a Loaner contract and transfers ETH to it
// When testing each bundle, the diff in balance in this contract is taking into account for calculating effective gas price
// The contract loans funds only on blocks mined by the miner and on zero-gasprice txs
contract Loaner {
address immutable owner;
constructor(address _owner) {
owner = _owner;
@alkavan
alkavan / hardhat-openzeppelin-project.md
Created December 12, 2020 10:37
Hardhat and OpenZeppelin project bootstrap for Ethereum contract development

Install Instructions

Install Hardhat

npm install --save-dev hardhat

Initiate a new Hardhat project (in empty directory)

npx hardhat
@spalladino
spalladino / falsehoods-that-ethereum-programmers-believe.md
Last active February 9, 2026 03:46
Falsehoods that Ethereum programmers believe

Falsehoods that Ethereum programmers believe

I recently stumbled upon Falsehoods programmers believe about time zones, which got a good laugh out of me. It reminded me of other great lists of falsehoods, such as about names or time, and made me look for an equivalent for Ethereum. Having found none, here is my humble contribution to this set.

About Gas

Calling estimateGas will return the gas required by my transaction

Calling estimateGas will return the gas that your transaction would require if it were mined now. The current state of the chain may be very different to the state in which your tx will get mined. So when your tx i

@spalladino
spalladino / revert.ts
Created September 11, 2020 22:38
Get the revert reason before sending an Ethereum transaction if the transaction would fail
export async function tryGetRevertReason(to: string, from: string, data: string): Promise<string | undefined> {
const provider = ethers.getDefaultProvider();
const tx = { to, from, data };
try {
await provider.estimateGas(tx);
} catch {
const value = await provider.call(tx);
return hexDataLength(value) % 32 === 4 && hexDataSlice(value, 0, 4) === '0x08c379a0'
? defaultAbiCoder.decode(['string'], hexDataSlice(value, 4))
: undefined;
@MrChico
MrChico / overflow_checking.smt2
Created September 2, 2020 13:19
cvc4 example
;; overflow checking words vs. checking explicit bounds
;; x * y / y == x <==>
;; x * y does not overflow
;; max value of (_ BitVec 256)
(define-fun pow256 () Int
115792089237316195423570985008687907853269984665640564039457584007913129639936)
;; x * y / y == x
@jcmartinezdev
jcmartinezdev / erc20-token-sample.sol
Last active June 8, 2026 10:44
Necessary code to generate an ERC20 Token
pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// Sample token contract
//
// Symbol : LCST
// Name : LCS Token
// Total supply : 100000
// Decimals : 2
// Owner Account : 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe
@mbwhite
mbwhite / endorsmentpolicy.pegjs
Created April 29, 2020 12:55
Hyperledger Fabric: Parsing the Endorsement Policies
// Grammar for parsing of the Fabric Endorsment Policies
//
// Defined in the documentation at
// https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax
// The expression will be an operator with arguments, each of the arguments can be an expression
// The OutOf operator is a bit different as that demands the first agument be a number
Expression
= op:Operator '(' _ args:Some_Expression_Args _ ')'
{
behaviour init of Token
interface constructor(string _symbol, string _name, string _version, uint _totalSupply)
creates Token
string name := _name
string symbol := _symbol
uint256 totalSupply := _totalSupply
mapping(address => uint) balanceOf := [CALLER := _totalSupply]
mapping(address=>mapping(address=>uint)) allowance := []