{"id":23300303,"url":"https://github.com/district0x/cljs-web3","last_synced_at":"2025-12-12T01:38:43.602Z","repository":{"id":61593629,"uuid":"69758953","full_name":"district0x/cljs-web3","owner":"district0x","description":"Clojurescript API for Ethereum Web3 API","archived":false,"fork":false,"pushed_at":"2018-03-30T22:02:52.000Z","size":71,"stargazers_count":111,"open_issues_count":7,"forks_count":18,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-30T08:57:47.249Z","etag":null,"topics":["cljs-web3","clojurescript","ethereum","web3","wrapper-library"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/district0x.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-01T19:29:34.000Z","updated_at":"2025-06-09T07:44:18.000Z","dependencies_parsed_at":"2022-10-19T15:30:40.679Z","dependency_job_id":null,"html_url":"https://github.com/district0x/cljs-web3","commit_stats":null,"previous_names":["madvas/cljs-web3"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/district0x/cljs-web3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district0x%2Fcljs-web3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district0x%2Fcljs-web3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district0x%2Fcljs-web3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district0x%2Fcljs-web3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/district0x","download_url":"https://codeload.github.com/district0x/cljs-web3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district0x%2Fcljs-web3/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263949408,"owners_count":23534324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cljs-web3","clojurescript","ethereum","web3","wrapper-library"],"created_at":"2024-12-20T09:12:55.010Z","updated_at":"2025-12-12T01:38:38.549Z","avatar_url":"https://github.com/district0x.png","language":"Clojure","readme":"# Cljs Web3\n\nClojureScript API for [Ethereum](https://ethereum.org/) blockchain [Web3 API](https://github.com/ethereum/wiki/wiki/JavaScript-API)\n\n## See also\n* [How to create decentralised apps with Clojurescript re-frame and Ethereum](https://medium.com/@matus.lestan/how-to-create-decentralised-apps-with-clojurescript-re-frame-and-ethereum-81de24d72ff5#.kul24x62l)\n* [re-frame-web3-fx](https://github.com/district0x/re-frame-web3-fx)\n\n## Installation\n```clojure\n;; Add to dependencies\n[cljs-web3 \"0.19.0-0-11\"]\n```\n```clojure\n(ns my.app\n  (:require [cljsjs.web3] ; You only need this, if you don't use MetaMask extension or Mist browser\n            [cljs-web3.bzz :as web3-bzz]\n            [cljs-web3.core :as web3]\n            [cljs-web3.db :as web3-db]\n            [cljs-web3.eth :as web3-eth]\n            [cljs-web3.evm :as web3-evm]\n            [cljs-web3.net :as web3-net]\n            [cljs-web3.personal :as web3-personal]\n            [cljs-web3.settings :as web3-settings]\n            [cljs-web3.shh :as web3-shh]))\n```\n\n## Usage\nSo basically, stick with the Web3 API [docs](https://github.com/ethereum/wiki/wiki/JavaScript-API), all methods there have their kebab-cased version in this library. Also, return values and responses in callbacks are automatically kebab-cased and keywordized. Instead of calling method of the web3 object, you pass it as a first argument. For example:\n```javascript\nweb3.eth.accounts\nweb3.version.api\nweb3.eth.defaultAccount\nweb3.isConnected()\nweb3.net.peerCount\nweb3.net.getPeerCount(function(error, result){ ... })\n```\nbecomes\n```clojure\n(web3-eth/accounts web3)\n(web3/version-api web3)\n(web3-eth/default-account web3)\n(web3/connected? web3)\n(web3-net/peer-count web3)\n(web3-net/peer-count web3 (fn [error result]))\n```\n\nSome functions in `cljs-web3.core` don't really need a web3 instance, even though they're called as object methods in Web3 docs. To make our lives easier, in ClojureScript, you can just call it without a web3 instance. For example:\n```\n(web3/sha3 \"1\")\n=\u003e 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6\n(web3/to-hex \"A\")\n=\u003e 0x41\n(web3/to-wei 1 :ether)\n=\u003e \"1000000000000000000\"\n```\n#### Extra functions for a better life\nThese are a few extra functions, which you won't find in the Web3 API:\n```clojure\n;; Create web3 instance from injected web3 (Mist / Metamask)\n(web3/web3)\n\n;; Create web3 instance from HTTP provider\n(web3/create-web3 \"http://localhost:8545/\")\n\n;; Deploy new contract\n(web3-eth/contract-new web3 abi\n  {:data bin\n   :gas gas-limit\n   :from (first (web3-eth/accounts w3))}\n  (fn [err res]))\n\n;; Create contract instance from already deployed contract\n(web3-eth/contract-at web3 abi address)\n\n;; This way you can call any contract method\n(web3-eth/contract-call ContractInstance :multiply 5)\n\n;; Gets binary data of a contract method call\n(web3-eth/contract-get-data ContractInstance :multiply 5)\n\n;; This library contains the special namespace cljs-web3.evm for controlling a testrpc server\n;; See https://github.com/ethereumjs/testrpc for more info\n(web3-evm/increase-time! web3 [1000] callback)\n(web3-evm/mine! web3 callback)\n(web3-evm/revert! web3 [0x01] callback)\n(web3-evm/snapshot! web3 callback)\n```\n\n#### cljs.core.async integration\nThere's an alternative async namespace for each original namespace, which provides an async alternative instead of the callback approach. For example:\n```clojure\n(ns test\n  (:require\n    [cljs-web3.async.eth :as web3-eth-async]\n    [cljs.core.async :refer [\u003c! \u003e! chan]]\n    [clojure.string :as string])\n  (:require-macros [cljs.core.async.macros :refer [go]]))\n\n(go\n  (\u003c! (web3-eth-async/accounts web3))\n  ;; returns [nil [\"0x56727ca3132d00307051a4fa6c6a2c3f07cb3f91\"]]\n\n  ;; Alternatively, you can always pass a core.async channel as a first argument. The response will be put onto this channel\n  ;; For example, if you pass a channel with a transducer:\n  (\u003c! (web3-eth-async/accounts\n            (chan 1 (comp (map second)\n                          (map (partial map string/upper-case))))\n            web3))\n  ;; returns (\"0X56727CA3132D00307051A4FA6C6A2C3F07CB3F91\")\n\n  )\n```\n\n\n#### Code is documentation\nDon't hesitate to open lib files or test files of this library to see how to use it. It's not bloated with implementation, so it's easy to read.\n\nDocstrings for the methods and namespaces are adjusted to ClojureScript from the [web3.js documentation](https://github.com/ethereum/wiki/wiki/JavaScript-API#web3netlistening)\n## DAPPS using cljs-web3\n* [emojillionaire](https://github.com/madvas/emojillionaire)\n* [ethlance](https://github.com/madvas/ethlance)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistrict0x%2Fcljs-web3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistrict0x%2Fcljs-web3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistrict0x%2Fcljs-web3/lists"}