Skip to content

Instantly share code, notes, and snippets.

View alexanderattar's full-sized avatar
💭
⚡️

Alexander alexanderattar

💭
⚡️
View GitHub Profile
@alexanderattar
alexanderattar / wallet.js
Last active December 17, 2021 23:52 — forked from pedrouid/wallet.js
Example with ethers.js (Ethereum Wallet)
const ethers = require('ethers')
const standardPath = "m/44'/60'/0'/0";
const activeIndex = 0;
function generatePath(index) {
const path = `${standardPath}/${index}`;
return path;
}
@alexanderattar
alexanderattar / ShiftBytes.sol
Created November 24, 2021 20:22
Shift bytes with Solidity
contract ShiftBytes {
function replaceBytesAtIndex(
bytes32 original,
uint256 position,
bytes1 toInsert
) public pure returns (bytes32) {
bytes1 maskBytes = 0xff;
bytes32 mask = bytes32(maskBytes) >> ((position * 1) * 8);
return (~mask & original) | (bytes32(toInsert) >> ((position * 1) * 8));
}
@alexanderattar
alexanderattar / solidity-default-visibility.md
Created October 7, 2021 17:32
Solidity Expression Default Visibility and Applicable Modifiers
Expression Default Visibility Applicable Visibility
function public public / internal / private / external
constructor public public / internal / private / external
variable internal public / internal / private
event Not applicable This is always public
@alexanderattar
alexanderattar / .prettierrc
Last active October 7, 2021 01:32
Default VS Code Prettier Settings with overrides for Solidity
{
"prettier.arrowParens": "always",
"prettier.bracketSpacing": true,
"prettier.configPath": "",
"prettier.disableLanguages": [],
"prettier.documentSelectors": [],
"prettier.embeddedLanguageFormatting": "auto",
"prettier.enable": true,
"prettier.enableDebugLogs": false,
"prettier.endOfLine": "lf",
const fs = require('fs');
const { exec } = require("child_process");
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
const contracts = {
"AddressManager": {
"address": "0x1De8CFD4C1A486200286073aE91DE6e8099519f1",
"params": []
},
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
@alexanderattar
alexanderattar / json-parsing.go
Created February 20, 2020 22:16 — forked from tomnomnom/json-parsing.go
Parsing arbitrary JSON with go
package main
import (
"log"
"fmt"
"encoding/json"
)
func main() {
b := []byte(`{"name": "tom", "favNum": 6, "interests": ["knives", "computers"], "usernames": {"github": "TomNomNom", "twitter": "@TomNomNom"}}`)
@alexanderattar
alexanderattar / redis_cheatsheet.bash
Created August 27, 2019 20:32 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@alexanderattar
alexanderattar / signTypedData.js.md
Last active July 22, 2019 21:38 — forked from backus/signTypedData.js.md
How signTypedData works

I couldn't find a good explanation of each step of signTypedData EIP with examples of inputs and outputs at each step. I wanted this so I could keep track.

Say this is our private key

const privKey = new Buffer(
  "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
  "hex"
);
let fs = require("fs");
let Web3 = require('web3'); // https://www.npmjs.com/package/web3
// Create a web3 connection to a running geth node over JSON-RPC running at
// http://localhost:8545
// For geth VPS server + SSH tunneling see
// https://gist.github.com/miohtama/ce612b35415e74268ff243af645048f4
let web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));