{"id":19895240,"url":"https://github.com/rubilmax/viem-tracer","last_synced_at":"2025-05-02T20:30:50.653Z","repository":{"id":259193602,"uuid":"876658325","full_name":"Rubilmax/viem-tracer","owner":"Rubilmax","description":"Debug transactions via traces by automatically decoding them with the help of OpenChain!","archived":false,"fork":false,"pushed_at":"2025-04-10T15:50:02.000Z","size":160,"stargazers_count":20,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T16:56:46.127Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rubilmax.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":"2024-10-22T10:48:15.000Z","updated_at":"2025-04-10T15:50:05.000Z","dependencies_parsed_at":"2024-11-12T18:41:28.237Z","dependency_job_id":"4c27d3c5-156b-47f1-9f59-7015d9b607c6","html_url":"https://github.com/Rubilmax/viem-tracer","commit_stats":null,"previous_names":["rubilmax/viem-tracer"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubilmax%2Fviem-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubilmax%2Fviem-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubilmax%2Fviem-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rubilmax%2Fviem-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rubilmax","download_url":"https://codeload.github.com/Rubilmax/viem-tracer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252103996,"owners_count":21695398,"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-12T18:36:02.162Z","updated_at":"2025-05-02T20:30:50.097Z","avatar_url":"https://github.com/Rubilmax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# viem-tracer\n\n[![npm package][npm-img]][npm-url]\n[![Build Status][build-img]][build-url]\n[![Downloads][downloads-img]][downloads-url]\n[![Issues][issues-img]][issues-url]\n[![Commitizen Friendly][commitizen-img]][commitizen-url]\n[![Semantic Release][semantic-release-img]][semantic-release-url]\n\nDebug transactions via traces by automatically decoding them with the help of [openchain.xyz](https://openchain.xyz/)!\n\n- Automatically append traces to error messages of failed `eth_estimateGas` and `eth_sendTransaction` RPC requests.\n- Add support for [`debug_traceCall`](https://www.quicknode.com/docs/ethereum/debug_traceCall) to a Viem client with correct types!\n\n## Installation\n\n```bash\nnpm install viem-tracer\n```\n\n```bash\nyarn add viem-tracer\n```\n\n## Usage\n\n```typescript\nimport { createTestClient, http } from 'viem';\nimport { foundry } from 'viem/chains';\nimport { traceActions, traced } from 'viem-tracer';\n\nconst client = createTestClient({\n  mode: \"anvil\",\n  chain: foundry,\n  transport: traced( // Automatically trace failed transactions (or programmatically)\n    http(),\n    { all: false, next: false, failed: true } // Optional, default tracer config\n  ),\n}).extend(traceActions); // Extend client with the `client.traceCall` action\n\n// Returns the call trace as formatted by the requested tracer.\nawait client.traceCall({\n   account: \"0xA0Cf798816D4b9b9866b5330EEa46a18382f251e\",\n   to: \"0x70997970c51812dc3a010c7d01b50e0d17dc79c8\",\n   value: parseEther(\"1\"),\n   // tracer: \"prestateTracer\", // Defaults to \"callTracer\".\n});\n\n// Failing `eth_estimateGas` and `eth_sendTransaction` RPC requests will automatically append the transaction traces to the error:\nawait client.writeContract({\n   abi: erc20Abi,\n   address: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n   functionName: \"transfer\",\n   args: [\"0xA0Cf798816D4b9b9866b5330EEa46a18382f251e\", 100_000000n],\n});\n\n// 0 ↳ FROM 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\n// 0 ↳ CALL (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48).transfer(0xf39F...0xf3, 100000000) -\u003e ERC20: transfer amount exceeds balance\n//   1 ↳ DELEGATECALL (0x43506849D7C04F9138D1A2050bbF3A0c054402dd).transfer(0xf39F...0xf3, 100000000) -\u003e ERC20: transfer amount exceeds balance\n\nclient.transport.tracer.all = true; // If you want to trace all submitted transactions, failing or not.\nclient.transport.tracer.next = true; // If you want to trace the next submitted transaction.\nclient.transport.tracer.next = false; // If you DON'T want to trace the next submitted transaction.\nclient.transport.tracer.failed = false; // If you don't want to append traces to failed transactions.\n\n```\n\n\u003e [!NOTE]  \n\u003e You can disable colors via the `colors` package:\n\u003e ```typescript\n\u003e import { disable } from \"colors\";\n\u003e\n\u003e disable();\n\u003e ```\n\n\n[build-img]: https://github.com/rubilmax/viem-tracer/actions/workflows/release.yml/badge.svg\n[build-url]: https://github.com/rubilmax/viem-tracer/actions/workflows/release.yml\n[downloads-img]: https://img.shields.io/npm/dt/viem-tracer\n[downloads-url]: https://www.npmtrends.com/viem-tracer\n[npm-img]: https://img.shields.io/npm/v/viem-tracer\n[npm-url]: https://www.npmjs.com/package/viem-tracer\n[issues-img]: https://img.shields.io/github/issues/rubilmax/viem-tracer\n[issues-url]: https://github.com/rubilmax/viem-tracer/issues\n[codecov-img]: https://codecov.io/gh/rubilmax/viem-tracer/branch/main/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/rubilmax/viem-tracer\n[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\n[commitizen-img]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\n[commitizen-url]: http://commitizen.github.io/cz-cli/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubilmax%2Fviem-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubilmax%2Fviem-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubilmax%2Fviem-tracer/lists"}