{"id":20691960,"url":"https://github.com/ahmedali8/detect-evm-proxy","last_synced_at":"2025-04-02T12:28:58.749Z","repository":{"id":65124059,"uuid":"582282787","full_name":"ahmedali8/detect-evm-proxy","owner":"ahmedali8","description":"Detect proxy contracts and their target addresses using an EIP-1193 compatible JSON-RPC request function","archived":false,"fork":false,"pushed_at":"2022-12-26T14:02:11.000Z","size":99,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T17:47:37.301Z","etag":null,"topics":["data-science","ethereum","evm","gnosis","multisig","proxy"],"latest_commit_sha":null,"homepage":"","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/ahmedali8.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}},"created_at":"2022-12-26T10:24:38.000Z","updated_at":"2023-02-06T08:57:21.000Z","dependencies_parsed_at":"2023-01-05T08:23:41.324Z","dependency_job_id":null,"html_url":"https://github.com/ahmedali8/detect-evm-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedali8%2Fdetect-evm-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedali8%2Fdetect-evm-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedali8%2Fdetect-evm-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedali8%2Fdetect-evm-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmedali8","download_url":"https://codeload.github.com/ahmedali8/detect-evm-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246814556,"owners_count":20838285,"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":["data-science","ethereum","evm","gnosis","multisig","proxy"],"created_at":"2024-11-16T23:18:33.657Z","updated_at":"2025-04-02T12:28:58.726Z","avatar_url":"https://github.com/ahmedali8.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# detect-evm-proxy\n\nDetect proxy contracts and their target addresses using an\n[EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compatible JSON-RPC\n`request` function\n\nThis package offers a utility function for checking if a smart contract at a\ngiven address implements one of the known proxy patterns. It detects the\nfollowing kinds of proxies:\n\n- [EIP-1167](https://eips.ethereum.org/EIPS/eip-1167) Minimal Proxy Contract\n- [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967) Transparent Proxy Pattern\n- [EIP-897](https://eips.ethereum.org/EIPS/eip-897) Delegate Proxy Pattern\n- [EIP-1822](https://eips.ethereum.org/EIPS/eip-1822) Universal Upgradeable\n  Proxy Standard\n- OpenZeppelin Proxy Pattern\n- Gnosis Safe Proxy Contract\n\n## Installation\n\nThis module is distributed via npm. For adding it to your project, run:\n\n```\nnpm install --save detect-evm-proxy\n```\n\nTo install it using yarn, run:\n\n```\nyarn add detect-evm-proxy\n```\n\n## How to use\n\nThe function requires an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)\ncompatible `request` function that it uses to make JSON-RPC requests to run a\nset of checks against the given address. It returns a promise that resolves to\nthe proxy target address, i.e., the address of the contract implementing the\nlogic. The promise resolves to `null` if no proxy can be detected.\n\n### Ethers with an adapter function\n\nUsing Infura:\n\n```ts\nimport { InfuraProvider } from \"@ethersproject/providers\";\nimport detectProxyTarget from \"detect-evm-proxy\";\n\nconst infuraProvider = new InfuraProvider(1, process.env.INFURA_API_KEY);\nconst requestFunc = ({ method, params }) =\u003e infuraProvider.send(method, params);\n\nconst target = await detectProxyTarget(\n  \"0xA7AeFeaD2F25972D80516628417ac46b3F2604Af\",\n  requestFunc\n);\n\n// logs {contractAddress: \"0x4bd844F72A8edD323056130A86FC624D0dbcF5b0\", kind: \"EIP-1967 Transparent Proxy Pattern\"}\nconsole.log(target);\n```\n\nUsing ankr:\n\n```ts\nimport { JsonRpcProvider } from \"@ethersproject/providers\";\nimport detectProxyTarget from \"detect-evm-proxy\";\n\nconst jsonRpcProvider = new JsonRpcProvider(\"https://rpc.ankr.com/eth\");\nconst requestFunc: EIP1193ProviderRequestFunc = ({ method, params }) =\u003e\n  jsonRpcProvider.send(method, params);\n\nconst target = await detectProxyTarget(\n  \"0xA7AeFeaD2F25972D80516628417ac46b3F2604Af\",\n  requestFunc\n);\n\n// logs {contractAddress: \"0x4bd844F72A8edD323056130A86FC624D0dbcF5b0\", kind: \"EIP-1967 Transparent Proxy Pattern\"}\nconsole.log(target);\n```\n\n### Web3 with an EIP1193 provider\n\nWeb3.js doesn't have a way to export an EIP1193 provider, so you need to ensure\nthat the underlying provider you use is EIP1193 compatible. Most\nEthereum-supported browsers like MetaMask and TrustWallet have an\n[EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compliant provider.\nOtherwise, you can use providers like\n[eip1193-provider](https://www.npmjs.com/package/eip1193-provider).\n\n```ts\nimport detectProxyTarget from \"detect-evm-proxy\";\nimport Web3 from \"web3\";\n\nconst web3 = new Web3(Web3.givenProvider || \"ws://localhost:8545\");\n\nconst target = await detectProxyTarget(\n  \"0xA7AeFeaD2F25972D80516628417ac46b3F2604Af\",\n  web3.currentProvider.request\n);\n\n// logs {contractAddress: \"0x4bd844F72A8edD323056130A86FC624D0dbcF5b0\", kind: \"EIP-1967 Transparent Proxy Pattern\"}\nconsole.log(target);\n```\n\n## API\n\n```ts\n\ndetectProxyTarget(\n  address: string,\n  jsonRpcRequest: EIP1193ProviderRequestFunc,\n  blockTag?: BlockTag\n): Promise\u003cDetectProxyTarget | null\u003e\n\n// where\nDetectProxyTarget: {\n  contractAddress: string,\n  kind: ProxyKind, // ProxyKind: string\n}\n\n```\n\n**Arguments**\n\n- `address` (string): The address of the proxy contract\n- `jsonRpcRequest` (EIP1193ProviderRequestFunc): A JSON-RPC request function,\n  compatible with [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)\n  (`(method: string, params: any[]) =\u003e Promise\u003cany\u003e`)\n- `blockTag` (optional: BlockTag): `\"earliest\"`, `\"latest\"`, `\"pending\"` or hex\n  block number, default is `\"latest\"`\n\n**Returns**\n\nThe function returns a promise that will generally resolve to either\n`DetectProxyTarget`(the detected target contract address (checksummed) and its\nkind) or `null` if it couldn't detect one.\n\n## Note\n\nDirectly modified from\n[evm-proxy-detection](https://github.com/gnosis/evm-proxy-detection)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedali8%2Fdetect-evm-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmedali8%2Fdetect-evm-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedali8%2Fdetect-evm-proxy/lists"}