Skip to content

Instantly share code, notes, and snippets.

@littleli
Created April 8, 2022 11:36
Show Gist options
  • Save littleli/197eca90ee602db20082ef539fb83d33 to your computer and use it in GitHub Desktop.
Save littleli/197eca90ee602db20082ef539fb83d33 to your computer and use it in GitHub Desktop.
Bitcoinjs-lib example
(ns example
(:require ["bitcoinjs-lib$default" :as btc]
["tiny-secp256k1" :as secp]
["ecpair$default" :as ecpair]
["axios$default" :as axios]
[promesa.core :as p]
[cljs-bean.core :refer [->clj]]))
(def ecpf (ecpair/ECPairFactory. secp))
(def keyPair (.makeRandom ecpf))
(def address (.-address (btc/payments.p2pkh #js {"pubkey" (.-publicKey keyPair)})))
(p/let [resp (axios/get (str "https://blockchain.info/rawaddr/" address))
resp (->clj resp :keywordize-keys true)]
(prn resp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment