Skip to content

Instantly share code, notes, and snippets.

View t4sk's full-sized avatar
🏠
Working from home

t4sk

🏠
Working from home
View GitHub Profile
@t4sk
t4sk / a-usage.md
Last active December 19, 2023 18:17
gen_tcp and GenServer example in Elixir (1.5.2)

gen_tcp and GenServer example in Elixir (1.5.2)

Usage

server.ex

Server.start
@t4sk
t4sk / wif.md
Last active August 1, 2023 20:15
How to convert private key to WIF

How to convert private key to WIF

0. Overview

WIF = base58check encode ([version byte][private key][checksum])

version byte = 80 for mainnet, ef for testnet and regtest

checksum = first 4 bytes of double SHA256 of private key
@t4sk
t4sk / hash160.md
Last active June 26, 2023 20:20
How to compute OP_HASH160 of public key

How to compute OP_HASH160 of public key

OP_HASH160 of public key = RIPEMD160(SHA256(ECDSA_publicKey))

1. Generate address

> getnewaddress
mpLwhoaRWxfgdQAz8JnnH7NUuhS157DM61

2. Get public key

@t4sk
t4sk / pubkey.md
Created January 3, 2017 22:22
How to get Public Key of a Bitcoin Address

How to get Public Key of a Bitcoin Address

Generate bitcoin address

> getnewaddress
mkAhnkryoSs3dLWeBhbhJsw5d1LMs3B3Lt

Get public key

> validateaddress mkAhnkryoSs3dLWeBhbhJsw5d1LMs3B3Lt

@t4sk
t4sk / address.md
Created January 13, 2017 23:50
How to create bitcoin address

How to create bitcoin address

0. Overview

Address = base58 encode ([version byte][public key hash][checksum])

version byte = 00 (for P2PKH on mainnet)

public key hash = RIPEMD160(SHA256(public key))
@t4sk
t4sk / script-p2pkh.md
Last active March 29, 2022 17:02
How to create scriptPubKey for P2PKH

How to create scriptPubKey for P2PKH

1. Get public key hash

Get the public key hash by computing OP_HASH160 of public key

In this example:

  • public key: 033e8c5dcb8e35670de496b57c1fa4366800ce3be5fded9b8800759881bc8da2e5
  • public key hash: 60d47ac02b129c08f94232ea506d1826424fe7be
@t4sk
t4sk / meaning-of-life.js
Created February 11, 2022 12:56
meaning of life
const Web3 = require("web3");
const assert = require("assert");
const web3 = new Web3();
const email = "email@email.com";
const COLORS = [
"red",
"blue",
"yellow",

Keybase proof

I hereby claim:

  • I am t4sk on github.
  • I am tsknk (https://keybase.io/tsknk) on keybase.
  • I have a public key ASDyZ1hblodO_TVvXYnHmPsWLpqRbYlgG6xzpy0Br_8m7Qo

To claim this, I am signing this object:

@t4sk
t4sk / segwit-regtest.md
Created December 29, 2016 21:51
How to activate segwit on regtest

How to activate segwit on regtest

Start bitcoind

> bitcoind -regtest -daemon

Generate block chain

> bitcoin-cli -regtest generate 432
@t4sk
t4sk / Wei.sol
Created March 12, 2019 04:59
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.5.3+commit.10d17f24.js&optimize=false&gist=
pragma solidity ^0.5.3;
contract Wei {
uint public oneEther = 1 ether;
function test() public pure {
assert(1 ether == 1e18 wei);
assert(1 wei == 1);
}
}