{"id":28610995,"url":"https://github.com/crytic/anchorx-ray","last_synced_at":"2025-06-11T23:11:26.170Z","repository":{"id":279984122,"uuid":"932308438","full_name":"crytic/anchorx-ray","owner":"crytic","description":"Node module for scanning and visualize Solana accounts","archived":false,"fork":false,"pushed_at":"2025-03-03T15:30:33.000Z","size":544,"stargazers_count":28,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T23:35:38.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crytic.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":"2025-02-13T17:49:34.000Z","updated_at":"2025-05-03T21:02:00.000Z","dependencies_parsed_at":"2025-02-28T20:38:59.543Z","dependency_job_id":"2d23844a-6b16-4767-ac95-80aff83e4c97","html_url":"https://github.com/crytic/anchorx-ray","commit_stats":null,"previous_names":["crytic/anchorx-ray"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/crytic/anchorx-ray","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crytic%2Fanchorx-ray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crytic%2Fanchorx-ray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crytic%2Fanchorx-ray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crytic%2Fanchorx-ray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crytic","download_url":"https://codeload.github.com/crytic/anchorx-ray/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crytic%2Fanchorx-ray/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259361132,"owners_count":22845836,"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":"2025-06-11T23:11:25.373Z","updated_at":"2025-06-11T23:11:26.156Z","avatar_url":"https://github.com/crytic.png","language":"HTML","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Solana Program Account Scanner\n\n## Overview\nThis script scans and extracts account information for Solana programs based on their Interface Definition Language (IDL) files. It uses the `@coral-xyz/anchor` and `@solana/web3.js` libraries to interact with the Solana blockchain, identify different types of accounts, and decode account data.\n\n## Features\n- Loads IDL files from `target/idl/`.\n- Scans all accounts associated with detected programs.\n- Identifies account types: Wallets, PDAs, Data Accounts, and Programs.\n- Decodes account data using the `BorshAccountsCoder`.\n- Saves all extracted information to `accounts.json`.\n- Display it\n\n![Example](example.png)\n\n## Prerequisites\nEnsure you have the following installed:\n- **Node.js** (\u003e=16.x recommended)\n- **Anchor** framework (for building Solana programs)\n- **Solana CLI** (for interacting with the blockchain)\n\n## Installation\n```sh\nnpm install anchorx-ray\n```\n\n## Configuration\nIf your test don't use the same rpc url, you can change in the .env file:\n```\nRPC_URL=\u003cYOUR_RPC\u003e\n```\nIf no RPC URL is provided, the script defaults to `http://127.0.0.1:8899` (local Solana test validator).\n\n## Usage\nRun the script in your Anchor project:\n```sh\nnpx anchorx-ray\n```\n\nThis will:\n1. Load all IDL files from `target/idl/`.\n2. Fetch programs owned by the accounts from the RPC.\n3. Identify and categorize these accounts using IDL and some other computations.\n4. Save the results in `accounts.json`.\n5. Open a visualization at http://localhost:3000/ in the browser.\n\n## Account Type Identification\nThe script categorizes accounts as:\n- **Program Account**: The executable program itself.\n- **Wallet**: A system account owned by the Solana System Program. (normally it will not happen for the moment since only accounts owned by the program are taken from the RPC)\n- **PDA (Program Derived Address)**: A non-executable program-owned address.\n- **Data Account**: A regular program-owned account storing data.\n- **Other**: Any account that doesn’t fit the above categories.\n\n## Output Format\nThe output is saved in `accounts.json` and contains details like:\n```json\n[\n  {\n    \"name\": \"example_program\",\n    \"address\": \"ABC123...\",\n    \"owner\": \"11111111111111111111111111111111\",\n    \"lamports\": 1000000,\n    \"executable\": true,\n    \"dataSize\": 0,\n    \"accountType\": \"Program\",\n    \"decodedData\": null\n  }\n]\n```\n\nAnd it will open a diagram showing all accounts used in the tests (program + accounts owned by the program)\n\n## Troubleshooting\n- **No IDL files found**: Ensure you have built your Anchor program using `anchor build`.\n- **Failed to fetch accounts**: Check your RPC URL and network connection.\n- **Only one program is shown in the diagram**: Ensure you have run tests.\n\n## For developers\nIf you want to update a part of the script, \n1. Clone the repo\n```sh\ngh repo clone crytic/anchorx-ray\n```\n2. Install dependencies\n```sh\nnpm install\n```\n3. Do your modifications\n4. Then\n```sh\nnpm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrytic%2Fanchorx-ray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrytic%2Fanchorx-ray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrytic%2Fanchorx-ray/lists"}