Skip to content

Instantly share code, notes, and snippets.

{
"name": "Hashnote",
"description": "Regulated Institutional-Grade Gateway & Investments",
"ticker": "HASH",
"homepage": "https://www.hashnote.com"
}
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "Prometheus"
},
"enable": true,
const CPK = require('contract-proxy-kit');
const EthersAdapter = CPK.EthersAdapter;
const ethers = require('ethers');
const main = async function() {
const provider = ethers.getDefaultProvider('homestead');
const wallet = ethers.Wallet.createRandom().connect(provider);
const ethLibAdapter = new EthersAdapter({ ethers, signer: wallet});
const cpk = await CPK.default.create({ ethLibAdapter, isSafeApp: false})
@tzumby
tzumby / application.ex
Created January 31, 2019 19:39
Crypto Prices application
defmodule CryptoPrices.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = [
@tzumby
tzumby / bittrex.ex
Created January 31, 2019 19:37
Bittrex client
defmodule CryptoPrices.Aggregator.Bittrex do
@limit 10
@base "http://api.bittrex.com/api/v1.1/public/getorderbook"
def compute(pair, _opts) do
pair
|> fetch_json()
|> format_results()
end
@tzumby
tzumby / crypto_prices.ex
Last active February 6, 2019 02:00
Crypto Prices Module
defmodule CryptoPrices do
alias CryptoPrices.Aggregator
@clients [Aggregator.Bittrex, Aggregator.Poloniex, Aggregator.Kraken]
def compute(pair, opts \\ []) do
timeout = opts[:timeout] || 2_000
opts = Keyword.put_new(opts, :limit, 10)
clients = opts[:clients] || @clients
@tzumby
tzumby / orderbook.json
Created January 31, 2019 01:48
Bittrex Order Book
{
"success":true,
"message":"",
"result":{
"buy":[
{
"Quantity":17.21215708,
"Rate":0.03160399
},
{
@tzumby
tzumby / supervisor.ex
Last active January 31, 2019 01:52
Crypto Prices Blog Post
defmodule CryptoPrices.Aggregator.Supervisor do
alias CryptoPrices.Aggregator
use Supervisor
def start_link(opts) do
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
end
def init(opts) do
iex(14)> Ethereumex.HttpClient.eth_call(%{ data: "0x" <> data, to: "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07"})
{:ok, "0x00000000000000000000000000000000000000000000000005698eef06670000"}
{:ok, address } =
"0x456196dfa8eb4534669a01c5933c3bba2ba0d018"
|> String.slice(2..-1)
|> Base.decode16(case: :mixed)
data = ABI.encode("balanceOf(address)", [address])
|> Base.encode16(case: :lower)
# 70a08231000000000000000000000000456196dfa8eb4534669a01c5933c3bba2ba0d018