{"id":20834010,"url":"https://github.com/trueblocks/trueblocks-unchained","last_synced_at":"2025-06-23T20:04:08.658Z","repository":{"id":84733146,"uuid":"501211199","full_name":"TrueBlocks/trueblocks-unchained","owner":"TrueBlocks","description":"The unchained index smart contract","archived":false,"fork":false,"pushed_at":"2023-03-12T13:11:19.000Z","size":7177,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T08:38:32.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/TrueBlocks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-06-08T10:55:11.000Z","updated_at":"2023-11-08T09:52:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"acc0468d-edce-4844-a0a7-febacaf18280","html_url":"https://github.com/TrueBlocks/trueblocks-unchained","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/TrueBlocks/trueblocks-unchained","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBlocks%2Ftrueblocks-unchained","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBlocks%2Ftrueblocks-unchained/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBlocks%2Ftrueblocks-unchained/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBlocks%2Ftrueblocks-unchained/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrueBlocks","download_url":"https://codeload.github.com/TrueBlocks/trueblocks-unchained/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBlocks%2Ftrueblocks-unchained/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261548714,"owners_count":23175490,"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-18T00:17:48.522Z","updated_at":"2025-06-23T20:04:08.635Z","avatar_url":"https://github.com/TrueBlocks.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Unchained Index\n\nThe UnchainedIndex is a smart contract that accomplishes a very simple task: it allows anyone to publish \na pointer to any data and records the address of that publisher.\n\nThat's all it does. That's it.\n\nWhile the previous sentence sounds sort of silly, behind it there's an interesting idea.\n\n## IPFS hashes are pointers into a world-wide shared global memory\n\nA pointer in a programming language is able to point to an arbitrarily large piece of memory. In the same\nway, an IPFS hash can be seen to do the same thing. Pointers can point to something as simple as an integer\nor something as complex as an multi-Gigabyte in-memory database. Pointers to Memory-mapped files can point\nto Terabytes of hard drive space.\n\nNo matter what the pointer points to, it's the same size. In the case of memory pointer, the pointer\nis a 64-bit unsigned integer. In the case of IPFS, the pointer is a 32-byte IPFS hash.\n\nThe UnchainedIndex, by providing a place to record the publication of pointers, can be seen as granting\naccess to a global memory space. Unlike a computer's memory or a database, however, the memory pointed\nto by an IPFS hash is immutable and repeatable. Furthermore, because we publish the IPFS to a smart\ncontract, the fact that we did so can never disappear. Once we publish, everyone can see the pointer\nfor the rest of time.\n\n## Unchained Index is permissionless and immutable\n\nWe've chosen to make Unchained Index permissionless, in the sense that anyone may read from it, but more importantly, anyone\nmay write to it. Each time someone calls `publishHash`, the contract records the sender's address. We call this address \nthe `publisher` address. Anyone may then later query for data produced by that `publisher`. The Unchained Index doesn't\ncare.\n\nThere is a Preferred publisher (called `owner`) which is the first deployer of the contract (us!). In this way, if a user wishes\nto retrieve data published by TrueBlocks, they may do so by querying the pointer provided by us. However, anyone else may also\npublish, and users who wish to may choose to query against that publisher. The Unchained Index doesn't care.\n\nIn this sense, the Unchained Index is a form of 'oracle by reputation'. If we can convince our users that the memory we\npoint to is better than anyone else's they will use it. If someone else comes along and convinces people to use thier\npointer to memory, Unchained Index doesn't care. It's not on the end user's decision, it's his/her responsibility.\n\nIf the \"US Academy of Accounting Professionals\" (a made-up organization) one day decides to publish an IPFS hash\npointing to the world's best Ethereum mainnet index, so be it. We can't (and don't want to) stop our users from\nswitching over. This is all by design. We're purposefully giving up our ability to capture our users.\n\nThe contract is also immutable (i.e. non-upgradable). This is also by design. We are also specifically relinquishing\nour ability to change the rules out from under our users. We're creating an immutable history to the data that's\nbeing produced by our system.\n\n## Pre-requisites for building\n\nYou must have `foundry` installed. [Follow these instructions](https://book.getfoundry.sh/getting-started/installation.html).\n\n## Building the Unchained Index\n\n```[bash]\ngit clone https://github.com/TrueBlocks/trueblocks-unchained\ncd trueblocks-unchained\nforge build\n```\n\n## Testing\n\n```[bash]\ncd trueblocks-unchained\nforge test\n```\n\n## Reading the IPFS hash of the manifest\n\n### Go code\n\n```[go]\n// Copyright 2021 The TrueBlocks Authors. All rights reserved.\n// Use of this source code is governed by a license that can\n// be found in the LICENSE file.\n\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config\"\n\t\"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpcClient\"\n\t\"github.com/ethereum/go-ethereum\"\n\t\"github.com/ethereum/go-ethereum/accounts/abi\"\n\t\"github.com/ethereum/go-ethereum/common\"\n)\n\nfunc main() {\n\t// We need an ABI for the Unchained Index\n\treader, err := os.Open(config.GetPathToRootConfig() + \"abis/known-000/unchainedV2.json\")\n\tif err != nil {\n\t\tfmt.Println(fmt.Errorf(\"while reading contract ABI: %w\", err))\n\t\treturn\n\t}\n\tdefer reader.Close()\n\ttheAbi, err := abi.JSON(reader)\n\tif err != nil {\n\t\tfmt.Println(fmt.Errorf(\"while parsing contract ABI: %w\", err))\n\t\treturn\n\t}\n\n\t// We need access to the Ethereum client\n\tethClient := rpcClient.GetClient(config.GetRpcProvider(\"mainnet\"))\n\tdefer ethClient.Close()\n\n\t// We need the address of the smart contract\n\taddress := common.HexToAddress(\"0x0c316b7042b419d07d343f2f4f5bd54ff731183d\")\n\n\t// And here we make the call\n\tresponse, err := ethClient.CallContract(\n\t\tcontext.Background(),\n\t\tethereum.CallMsg{\n\t\t\tTo:   \u0026address,\n\t\t\tData: rpcClient.DecodeHex(\"0x7087e4bd00000000000000000000000002f2b09b33fdbd406ead954a31f98bd29a2a3492000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000076d61696e6e657400000000000000000000000000000000000000000000000000\"),\n\t\t},\n\t\tnil,\n\t)\n\tif err != nil {\n\t\tfmt.Println(fmt.Errorf(\"while calling contract: %w\", err))\n\t\treturn\n\t}\n\n\t// Unpack the result...\n\tresult, err := theAbi.Unpack(\"manifestHashMap\", response)\n\tif err != nil {\n\t\tfmt.Println(fmt.Errorf(\"while unpacking value: %w\", err))\n\t\treturn\n\t}\n\n\t// And print it if we got anything\n\tif len(result) == 0 {\n\t\tfmt.Println(errors.New(\"contract returned empty data\"))\n\t} else {\n\t\tfmt.Println(result[0].(string))\n\t}\n}\n```\n\nIf you run this code with\n\n```\ngo run main.go\n```\n\nit prints\n\n```\nQmcBzCmvdcY5s3qt8fLz8hcYxS8QR2K7KoBuC2qi2NuaTx\n```\n\nYou may access the manifest with \n\n```[bash]\ncurl \"https://gateway.pinata.cloud/ipfs/QmcBzCmvdcY5s3qt8fLz8hcYxS8QR2K7KoBuC2qi2NuaTx\"\n```\n\n## Contributing\n\nWe love contributors. Please see information about our [work flow](https://github.com/TrueBlocks/trueblocks-core/blob/develop/docs/BRANCHING.md) before proceeding.\n\n1. Fork this repository into your own repo.\n2. Create a branch: `git checkout -b \u003cbranch_name\u003e`.\n3. Make changes to your local branch and commit them to your forked repo: `git commit -m '\u003ccommit_message\u003e'`\n4. Push back to the original branch: `git push origin TrueBlocks/trueblocks-core`\n5. Create the pull request.\n\n## Contact\n\nIf you have questions, comments, or complaints, please join the discussion on our discord server which is [linked from our website](https://trueblocks.io).\n\n## List of Contributors\n\nThanks to the following people who have contributed to this project:\n\n* [@tjayrush](https://github.com/tjayrush)\n* [@dszlachta](https://github.com/dszlachta)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrueblocks%2Ftrueblocks-unchained","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrueblocks%2Ftrueblocks-unchained","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrueblocks%2Ftrueblocks-unchained/lists"}