Skip to content

Instantly share code, notes, and snippets.

View alisinabh's full-sized avatar

Alisina Bahadori alisinabh

View GitHub Profile
@alisinabh
alisinabh / eip1559-decode-and-recover.livemd
Created April 8, 2024 23:53
EIP1559 Decode and recover public key using Elixir Ethers

Recover EIP1559 pub-key

Mix.install([:ethers, :ex_secp256k1])

Transaction payload

@alisinabh
alisinabh / ethereum_transaction_revocer.livemd
Created March 13, 2024 01:47
Recover Ethereum legacy transaction public key in Elixir

Recover Ethereum transaction public key

Mix.install([:ethers, :ex_secp256k1])

Procedure for legacy transactions

@alisinabh
alisinabh / load_nft_data_elixir.livemd
Created February 6, 2024 05:10
Load NFT Data using Elixir Ethers

Fetch NFT Metadata

Mix.install([
  :ethers,
  :kino,
  :req
])
@alisinabh
alisinabh / ethers_uniswap.livemd
Created January 23, 2024 18:38
Elixir Ethers and Uniswap

Uniswap ❤️ Elixir

Mix.install([
  {:ethers, "~> 0.2.2"},
  {:uniswap, github: "alisinabh/elixir_uniswap"},
  :ex_secp256k1,
  # For Images
@alisinabh
alisinabh / dynamic_alias.ex
Last active June 15, 2022 18:59
Dynamically alias modules at compile time in Elixir with mox
defmodule DynamicAlias do
@moduledoc """
Helper macro to call the alias dynamically. This will allow developers to
stub the testing environment with a mock or use different modules with
different configuration without the need to use a runtime impl function.
Please note that this only works in compile time. Do not provide any runtime
specific configuration here.
"""
@alisinabh
alisinabh / build-metamask-with-typed-data.md
Last active January 17, 2022 13:38
Metamask EIP712 Trezor

Manually build metamask to claim your $LOOKS

This document will help you to build and install metamask with ability to sign typed data using trezor model T devices. (Model one does not support this yet). Please only follow this guide if you have enough technical knowledge. NEVER install anything from any other source rather than the official chrome and firefox marketplaces or metamask original website.

NOTE Do NOT install any binaries from third parties who claim they have a build version of this guide. If you want it you should build it yourself to be 100% sure that it is not tampered with. This solution is only a last resort, If you can wait a few more days I would stongly suggest to wait for an official release.

const { ethers } = require("ethers");
const sigUtil = require('@metamask/eth-sig-util');
// The wallet to sign with
const hdWallet = ethers.utils.HDNode.fromMnemonic('all all all all all all all all all all all all').derivePath(ethers.utils.defaultPath)
const privateKey = Buffer.from(hdWallet.privateKey.substr(2), 'hex')
msgParams = {
domain: {
// Defining the chain aka Rinkeby testnet or Ethereum Main Net
@alisinabh
alisinabh / BasicERC20.sol
Created December 3, 2020 23:01 — forked from giladHaimov/BasicERC20.sol
Basic ERC20 implementation
pragma solidity ^0.4.19;
contract ERC20Basic {
string public constant name = "ERC20Basic";
string public constant symbol = "BSC";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
@alisinabh
alisinabh / Dockerfile
Created August 12, 2019 01:25
Stolon postgis postgresql
# Source image of stolon to add postgis to
FROM sorintlab/stolon:v0.13.0-pg10
# Since we are using a pg10 image of stolon we will install postgresql-10-postgis-x.x
RUN apt-get update && apt-get install -y postgresql-10-postgis-2.4
@alisinabh
alisinabh / decrease-brightness.sh
Created April 21, 2017 22:00
X window selective brightness control - using Xrandr and awk
BRIGHTNESS=`xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1`
NEW_BRIGHTNESS=`awk '{print $1-$2}' <<<"$BRIGHTNESS 0.05"`
echo $NEW_BRIGHTNESS
xrandr --output DVI-I-1 --brightness $NEW_BRIGHTNESS
xrandr --output DVI-I-2 --brightness $NEW_BRIGHTNESS