{"id":18556767,"url":"https://github.com/urbit/azimuth-hs","last_synced_at":"2025-04-10T01:31:35.293Z","repository":{"id":62435589,"uuid":"278413255","full_name":"urbit/azimuth-hs","owner":"urbit","description":"Haskell bindings for Azimuth (https://github.com/urbit/azimuth)","archived":false,"fork":false,"pushed_at":"2020-08-18T11:01:36.000Z","size":129,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T14:21:26.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2020-07-09T16:15:29.000Z","updated_at":"2021-03-19T22:30:36.000Z","dependencies_parsed_at":"2022-11-01T21:02:43.690Z","dependency_job_id":null,"html_url":"https://github.com/urbit/azimuth-hs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fazimuth-hs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fazimuth-hs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fazimuth-hs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fazimuth-hs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbit","download_url":"https://codeload.github.com/urbit/azimuth-hs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248140380,"owners_count":21054290,"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":[],"created_at":"2024-11-06T21:33:13.477Z","updated_at":"2025-04-10T01:31:30.282Z","avatar_url":"https://github.com/urbit.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# azimuth-hs\n\n[![Hackage Version](https://img.shields.io/hackage/v/azimuth-hs.svg)](http://hackage.haskell.org/package/azimuth-hs)\n[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)\n\nInteract with [Azimuth](https://github.com/urbit/azimuth-solidity) from\nHaskell.\n\n## Basic Usage\n\nYou can get started by pulling in `Urbit.Azimuth` (probably qualified):\n\n```\nimport qualified Urbit.Azimuth as A\n```\n\nFriendly wrappers for the Azimuth and Ecliptic contracts can be found in\n`Urbit.Azimuth.Azimuth` and `Urbit.Azimuth.Ecliptic`.  They'll both be pulled\nin via `import Urbit.Azimuth`.\n\nIf you want to work with the raw hs-web3 functions generated from the contract\nABIs, you can import `Urbit.Azimuth.Azimuth.Internal` or\n`Urbit.Azimuth.Ecliptic.Internal` directly.\n\nTo use the various functions provided, you'll generally want to:\n\n* define a web3 endpoint (probably via\n  [hs-web3](https://github.com/airalab/hs-web3)'s `defaultSettings` function,\n  re-exported here),\n\n* provide a `Contracts` object (this can be procured via `getContracts` for\n  mainnet),\n\n* provide an account, and then,\n\n* use `runAzimuth` to call the desired contract function with the necessary\n  information.\n\nBy 'provide an account', I mean you'll typically need to pass a private key.\nBut if you're just reading from the chain, you can typically use the endpoint's\ndefault account, specified via unit (i.e. `()`).\n\nCheck out the [quickstart section](#quickstart) below to see an examples of all\nthe above.\n\n## Quickstart\n\nThis example uses an [Infura](https://infura.io/) endpoint as a provider for\nweb3:\n\n```\n{-# LANGUAGE NumericUnderscores #-}\n{-# LANGUAGE OverloadedStrings #-}\n\nimport qualified Urbit.Azimuth as A\nimport qualified Urbit.Ob as Ob\n\n-- A test endpoint definition.  You'll want to set up your own to do anything\n-- interesting.\ninfura :: String\ninfura = \"MY_INFURA_ENDPOINT\"\n\n-- A simple example of setting up an endpoint, fetching the Azimuth contracts,\n-- getting a private key from a BIP39 mnemonic and HD path, and fetching the\n-- public information for a few ships.\n\nmain :: IO ()\nmain = do\n  endpoint  \u003c- A.defaultSettings infura\n\n  -- fetch the mainnet contract addresses\n  contracts \u003c- A.runWeb3 endpoint A.getContracts\n\n  let zod = Ob.patp 0\n      nec = Ob.patp 1\n      bud = Ob.patp 2\n\n  -- fetch ~zod's public info, using endpoint's default account ()\n  zodInfo \u003c- A.runWeb3 endpoint $\n    A.runAzimuth contracts () $\n      A.getPoint zod\n\n  print zodInfo\n\n  -- to use a nontrivial account:\n\n  -- take a test BIP39 mnemonic\n  let mnem = \"benefit crew supreme gesture quantum \"\n          \u003c\u003e \"web media hazard theory mercy wing kitten\"\n\n  -- a standard HD path\n  let hdpath  = \"m/44'/60'/0'/0/0\" :: A.DerivPath\n\n  -- and the ethereum mainnet chain ID\n  let chainId = 1\n\n  -- and then use them to derive a suitable private key\n  let account = case A.toPrivateKey mnem mempty hdpath chainId of\n        Left _    -\u003e error \"bogus creds\"\n        Right acc -\u003e acc\n\n  -- fetch ~nec's public info, using this private key to auth\n  necInfo \u003c- A.runWeb3 endpoint $\n    A.runAzimuth contracts account $\n      A.getPoint zod\n\n  print necInfo\n\n  -- you can also set the gas price, etc. as follows\n  let params = A.defaultTxnParams { A.txnGasPrice = Just 100_000_000_000 }\n\n  -- (see Urbit.Azimuth.Transaction for details on those)\n\n  -- use runAzimuth' (notice the apostrophe) to supply those parameters\n  budInfo \u003c- A.runWeb3 endpoint $\n    A.runAzimuth' contracts params account $\n      A.getPoint bud\n\n  print budInfo\n```\n\n## Building\n\nNote that depending on your system and GHC installation, a few transitive\ndependencies may prove tricky to build.  In particular, if you've installed GHC\nwith [Nix](https://nixos.org/nix), you may need to build from within a Nix\nshell with [zlib-dev](https://www.zlib.net/),\n[libsecp256k1](https://github.com/bitcoin-core/secp256k1), and\n[pkg-config](https://en.wikipedia.org/wiki/Pkg-config) present.\n\nA suitable [Nix](https://nixos.org/) shell is provided in `shell.nix`, so you\ncan get a repl via:\n\n```\n~/src/azimuth-hs$ nix-shell\n[nix-shell:~/src/azimuth-hs]$ cabal new-repl\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbit%2Fazimuth-hs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbit%2Fazimuth-hs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbit%2Fazimuth-hs/lists"}