{"id":19764827,"url":"https://github.com/attestate/libharberger","last_synced_at":"2025-08-19T04:41:53.931Z","repository":{"id":137077651,"uuid":"454828269","full_name":"attestate/libharberger","owner":"attestate","description":"A dapptools/foundry-ready library for charging Harberger taxes on partial common non-fungible property.","archived":false,"fork":false,"pushed_at":"2022-11-17T20:38:12.000Z","size":6471,"stargazers_count":24,"open_issues_count":13,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T14:33:48.710Z","etag":null,"topics":["dapptools","ethereum","harberger-tax","pricing","solidity","web3"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/attestate.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,"zenodo":null}},"created_at":"2022-02-02T15:25:55.000Z","updated_at":"2024-06-03T09:31:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8ab6bb4-6b5d-4bbb-8933-11978549a06f","html_url":"https://github.com/attestate/libharberger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/attestate/libharberger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attestate%2Flibharberger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attestate%2Flibharberger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attestate%2Flibharberger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attestate%2Flibharberger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/attestate","download_url":"https://codeload.github.com/attestate/libharberger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attestate%2Flibharberger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261289418,"owners_count":23136070,"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":["dapptools","ethereum","harberger-tax","pricing","solidity","web3"],"created_at":"2024-11-12T04:15:28.178Z","updated_at":"2025-08-19T04:41:53.915Z","avatar_url":"https://github.com/attestate.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/assets/harbergerschema.jpg\" /\u003e\n\u003c/p\u003e\n\n### A dapptools/foundry-ready library for charging Harberger taxes on non-fungible property.\n\n#### [Installation](readme.md/#Installation) | [License](readme.md#License) | [Usage](readme.md#Usage)\n\n## Why use libharberger?\n\n- It has high test coverage and uses solmate's high-precision fixed-point\n  number arithmetic.\n- It implement's ERC721's Metadata interface extension but it's not an ERC721.\n  Wallets can hence still load any property like an ERC721 but detect that\n  transfers shall be disabled.\n- Implementing Harberger taxes as \"deprecating licenses,\" this library\n  structurally minimizes gas costs for sales.\n\n## Installation\n\nWith [dapptools](https://github.com/dapphub/dapptools):\n\n```bash\ndapp install attestate/libharberger\n```\n\nOr [foundry](https://github.com/gakonst/foundry):\n\n```\nforge install attestate/libharberger\n```\n\n## Usage\n\n```sol\npragma solidity ^0.8.6;\n\nimport {Harberger, Period, Perwei} from \"libharberger/Harberger.sol\";\n\nfunction tax() pure {\n  uint256 price = 1 ether;\n\n  Period period = Period(0, block.number);\n  Perwei taxRate = Perwei(1, 100) // == 0.01\n  uint256 nextPrice = Harberger.getNextPrice(taxRate, period, price);\n\n  //...\n}\n```\n\n## Caveats \u0026 Mechanic\n\nAn actual implementation of a Harberger tax would include charging a property\nowner a tax rate periodically e.g. every month. In, let's say, the traditional\nbanking system: that'd mean the property owner transfers the tax in a\ntransaction monthly. The spiritual predecessor of this library\n[bin-studio/harberger-ads-contracts](https://github.com/bin-studio/harberger-ads-contracts)\nindeed implemented a\n[`collectTaxes`](https://github.com/bin-studio/harberger-ads-contracts/blob/6f2d61e75afd2b3efb31e8e9e95395e93b11a80a/contracts/HarbergerAds.sol#L73)\nmethod that's supposed to be called periodically by the contract operator.\n\nHowever, as since then gas prices on Ethereum mainnet have increased\nsignificantly and as periodically calling functions seems wastful, we're\nimplementing the Harberger tax as a periodically reduced price value.\n\nSay you buy property X for price `p_x = 1 ether` at block `b_x`, where `x = 0`,\nthen for each block `b_x+1` we reduce `p_x+1` by the tax rate. If say the tax\nrate was `t = 0.01`, then property X price at block 1\n`b_1` is `p_1 = 1 ether - 1 ether * 0.01 = 0.99 ether` and at\n`b_2`, `p_2 = 0.99 ether - 0.99 ether * 0.01 = 0.9801 ether` and so on.\n\nWe decrease the price in that way until it reaches zero, for when a new buyer\ncan buy the property for free. By taxing this way, we don't need to\nperiodically call a `collectTaxes` method.\n\n## Changelog\n\n### 0.3.0\n\n- Rename `Percentage` struct to `Perwei`\n- Add further tests to confirm precision of up to 18 decimal points\n\nNOTE: We only noticed now that between 0.0.1 and 0.2.0, we've made a mistake in\nsemantic versioning as \"0.2.0\" should actually be \"0.1.0\". But we're deciding\nto stick with the mistake and we'll try to properly produce ascending numbers\nin the future.\n\n### 0.2.0\n\n- Simplify pricing mechanism\n\n### 0.0.1\n\n- Initial release\n\n## License\n\nSee LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattestate%2Flibharberger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fattestate%2Flibharberger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattestate%2Flibharberger/lists"}