{"id":13792223,"url":"https://github.com/f-o-a-m/purescript-web3","last_synced_at":"2025-10-22T21:51:24.645Z","repository":{"id":40670335,"uuid":"106305741","full_name":"f-o-a-m/purescript-web3","owner":"f-o-a-m","description":"a purescript library for the web3 api","archived":false,"fork":false,"pushed_at":"2025-01-02T20:07:58.000Z","size":926,"stargazers_count":127,"open_issues_count":0,"forks_count":22,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-09-29T01:07:59.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/f-o-a-m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-09T16:08:32.000Z","updated_at":"2025-08-20T13:19:45.000Z","dependencies_parsed_at":"2024-04-21T17:14:50.614Z","dependency_job_id":"ca0ab5b9-3568-48ae-850c-49c3953d8ae2","html_url":"https://github.com/f-o-a-m/purescript-web3","commit_stats":{"total_commits":359,"total_committers":13,"mean_commits":"27.615384615384617","dds":0.4428969359331476,"last_synced_commit":"2dd330debc19f7675554ca1315e8fa06ef8e8f30"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"purl":"pkg:github/f-o-a-m/purescript-web3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f-o-a-m%2Fpurescript-web3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f-o-a-m%2Fpurescript-web3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f-o-a-m%2Fpurescript-web3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f-o-a-m%2Fpurescript-web3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f-o-a-m","download_url":"https://codeload.github.com/f-o-a-m/purescript-web3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f-o-a-m%2Fpurescript-web3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280520818,"owners_count":26344438,"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","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-03T22:01:09.779Z","updated_at":"2025-10-22T21:51:24.607Z","avatar_url":"https://github.com/f-o-a-m.png","language":"PureScript","funding_links":[],"categories":["Roadmap","PureScript","Dapps development"],"sub_categories":["APIs / subproviders"],"readme":"# purescript-web3\n\u003cimg src=https://github.com/f-o-a-m/purescript-web3/blob/master/purescript-web3-logo.png width=\"75\"\u003e\n\n\n# A Purescript Client for the Web3 API\n\n`purescript-web3` is a library for interacting with an ethereum node in purescript.\n\nUsing [purescript-web3-generator](https://github.com/f-o-a-m/purescript-web3-generator) or [chanterelle](https://github.com/f-o-a-m/chanterelle) it is also possible (and recommended) to generate a library from a set of smart contract abis which is capable of templating transactions and event filters/watchers. The README has instructions for getting started.\n\nTo see an example project, it is recommended to look at the [tests repository](https://github.com/f-o-a-m/purescript-web3-tests) (which uses Chanterelle)\n\n## Build Instructions\n```\n\u003e npm install\n\u003e npm run build\n\u003e docker run -d -p 8545:8545 -e ACCOUNTS_TO_CREATE=10 foamspace/cliquebait:v1.9.12\n\u003e npm run test\n```\n\n## Documentation\n\nModule documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-web3).\n\n## Examples\n\nSuppose we have the following solidity smart contract:\n\n```solidity\ncontract TupleStorage {\n    \n    uint x;\n    uint y;\n    \n    event TupleSet(uint newX, uint newY);\n    \n    function setTuple(uint _x, uint _y) public {\n        x = _x;\n        y = _y;\n        TupleSet(_x, _y);\n    }\n    \n}\n```\n\nIf we used [purescript-web3-generator](https://github.com/f-o-a-m/purescript-web3-generator), we are given a function with the following signature:\n\n```purescript\nsetTuple :: forall e.\n            TransactionOptions NoPay \n         -\u003e {_x :: UIntN 256, _y :: UIntN 256} \n         -\u003e Web3 HexString \n```\n\nIt's pretty clear what this function is doing, but let's look at the `TransactionOptions`. This record keeps track of, for example, who is the transaction from, what contract address is it going to, is there ether being sent, etc. In this case, the function is not \"payable\", so this is indicated in the type of the `TransactionOptions`. It is set using lenses like:\n\n```purescript\nsetTupleOpts :: TransactionOptions NoPay\nsetTupleOpts = defaultTransactionOptions\n             # _from ?~ myAddress\n             # _to ?~ tupleStorageAddress\n```\nNow for the `TupleSet` event. In order to start an event watcher, we need to establish the `Filter`, which specifies things like the range of blocks we are interested in, and how to find that particular contract and topic. Again, if you're using web3-generator, things are a lot simpler:\n\n```purescript\ntupleFilter :: Filter TupleSet\ntupleFilter = eventFilter (Proxy :: Proxy TupleSet) tupleStorageAddress \n           # _fromBlock .~ BN 100\n```\n\nWe also need to pass a callback to the event watcher that performs some action and decides whether or not to unregister the filter. For example, we could set up an event monitor starting from block 100 and continuing until the two coordinates that are set are equal:\n\n```purescript\nevent tupleFilter $ \\(TupleSet {newX,newY} -\u003e do\n  log $ \"Received New Tuple : \" \u003c\u003e show (Tuple newX newY) \n  if newX == newY\n    then pure TerminateEvent\n    else do\n      _ \u003c- performAction newX newY\n      pure ContinueEvent\n```\n\n## Resources\n \n - [web3 api spec](https://github.com/ethereum/execution-apis)\n - [solidity ABI spec](https://docs.soliditylang.org/en/latest/abi-spec.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff-o-a-m%2Fpurescript-web3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff-o-a-m%2Fpurescript-web3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff-o-a-m%2Fpurescript-web3/lists"}