Skip to content

Instantly share code, notes, and snippets.

View k26dr's full-sized avatar

Kedar Iyer k26dr

View GitHub Profile
@k26dr
k26dr / thebook.sol
Created October 24, 2025 16:07
TheBook
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TheBook {
function book(string calldata name, string calldata text) external {}
}
kedar@kedar
@k26dr
k26dr / orderbook.sol
Last active July 1, 2025 08:30
OrderBook
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
@k26dr
k26dr / html_inbox_public.php
Last active April 3, 2025 20:03
Public HTML Inbox
<?php
if (isset($_POST["message"])) {
// inbox.html must have write permissions. if this part fails, run:
// $ chmod 666 inbox.html
file_put_contents("inbox.html", "[" . date(DATE_W3C) . "]: ", FILE_APPEND);
file_put_contents("inbox.html", $_POST["message"], FILE_APPEND);
file_put_contents("inbox.html", "\n\n<br><br>\n\n", FILE_APPEND);
@k26dr
k26dr / peerbet.sol
Last active February 23, 2025 14:52
PeerBet
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract PeerBet {
enum Side { PUSH, OVER, UNDER }
struct Bet {
uint counterStart;
uint counterEnd;
Side side;
@k26dr
k26dr / classic-books.txt
Created February 21, 2025 16:27
How to Upload Books to Ethereum L1
Calldata on Ethereum has gotten so cheap that you can upload entire books in text format directly to Layer 1.
I'll use Meditations by Marcus Aurelius as an example because it's short enough to upload easily.
This book is available for free, so the first thing I did is to download a TXT copy of the book from the internet.
$ wget http://classics.mit.edu/Antoninus/meditations.mb.txt
Ethereum has a limit on how much data you can upload in a single transaction,
so I use a bash script to split the file up into 1000 line segments.
@k26dr
k26dr / AtomicSwapETH.sol
Created November 16, 2024 16:35
Atomic Swap ETH
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract AtomicSwapETH {
// Hash Tracking for swaps
// The key for the mappings is the hash
struct HTLC {
address initiator;
address receiver;
address token;
@k26dr
k26dr / AtomicSwapERC20.sol
Last active November 16, 2024 16:33 — forked from taureau75/AtomicSwap.sol
ERC-20 Atomic Swap Contract
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract AtomicSwap {
// Hash Tracking for swaps
// The key for the mappings is the hash
struct HTLC {
address initiator;
@k26dr
k26dr / eosbethacked.cpp
Created October 15, 2018 07:58
Contract used to hack EOS Bet
#include <eosiolib/eosio.hpp>
#include <eosiolib/types.hpp>
extern "C" {
[[noreturn]] void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
require_recipient(N(eosbetdice11));
}
}
@k26dr
k26dr / sudo-validation.md
Last active September 24, 2018 12:45
Validate Sudo Multisig Proposals

Sudo Validation

Implementing sudo requires 15/21 BPs to approve two separate proposals. One to create the eosio.sudo account, another to deploy the eosio.sudo contract. The first transation has to be executed before the second can be proposed.

Create Sudo Account

You can review the first createsudo transaction with:

cleos multisig review libertyblock createsudo
@k26dr
k26dr / alternate-sudo.cpp
Last active July 9, 2018 15:40
Alternative eosio.sudo proposal
// Add arbitration to eosio.sudo multisig
{
"threshold": 2,
"accounts": [
{"permission": {"actor": "eosio.prods", "permission": "active"}, "weight": 1},
{"permission": {"actor": "eosio.ecaf", "permission": "active"}, "weight": 1},
]
}