Skip to content

Latest commit

 

History

History
42 lines (35 loc) · 644 Bytes

README.md

File metadata and controls

42 lines (35 loc) · 644 Bytes

MiniMiner

Data

%{
  "data" => [],
  "nonce" => 45
}

Get hash (bitstring and string)

hash = map |> Jason.encode!() |> (&(:crypto.hash(:sha256, &1))).()
string_hash = hash |> Base.encode16 |> String.downcase

Pattern match

<<0::size(difficulty), _::bits>> = bitstring_hash

Synchronous request to get the problem

{:ok, {{version, status_code, msg}, headers, body}} =
  :httpc.request(:get, {'https://hackattic.com/challenges/mini_miner/problem?access_token=xxx', []}, [], [])

Install

mix deps.get

Run

TOKEN=xxx WORKERS=10 iex -S mix
iex> MiniMiner.run()

Test

mix test