Skip to content

Instantly share code, notes, and snippets.

@madis
Created April 17, 2023 13:40
Show Gist options
  • Select an option

  • Save madis/a4f5ea27fc34c8f9b2f4537e0cbb3af0 to your computer and use it in GitHub Desktop.

Select an option

Save madis/a4f5ea27fc34c8f9b2f4537e0cbb3af0 to your computer and use it in GitHub Desktop.

Revisions

  1. madis created this gist Apr 17, 2023.
    37 changes: 37 additions & 0 deletions first.cljs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    (ns first
    (:require
    ["@nomicfoundation/hardhat-chai-matchers/withArgs" :refer [anyValue]]
    ["@nomicfoundation/hardhat-network-helpers" :as hnh :refer [hh-time loadFixture]]
    ["ethers" :as ethers-js]))

    (def test-seed "easy leave proof verb wait patient fringe laptop intact opera slab shine")
    (defn ** [x n]
    (loop [acc 1 n n]
    (if (zero? n) acc
    (recur (* x acc) (dec n)))))

    (defn time-now []
    (.now js/Date))

    (def wallet (.-Wallet ethers-js))

    (defn generate-addresses
    ([seed-phrase] (generate-addresses seed-phrase 0))
    ([seed-phrase counter]
    (lazy-seq (cons
    (.-address (.fromMnemonic wallet seed-phrase (str "m/44'/60'/0'/0/" counter)))
    (generate-addresses seed-phrase (inc counter))))))

    (defn first-test []
    (let [one-year-in-secs (* 365 24 60 60)
    one-gwei (** 10 9)

    locked-amount one-gwei
    unlock-time (+ (time-now) one-year-in-secs)
    [owner other-account] (take 2 (generate-addresses test-seed))

    lock-contract ()
    ]
    (println "Addresses: " (take 10 (generate-addresses test-seed)))))

    (first-test)