{"eip":5169,"title":"Client Script URI for Token Contracts","description":"Add a scriptURI to point to an executable script associated with the functionality of the token.","authors":["James (@JamesSmartCell)","Weiwu (@weiwu-zhang)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2022-05-03","requires":[20,165,721,777,1155],"discussionsTo":"https://ethereum-magicians.org/t/eip-5169-client-script-uri-for-token-contracts/9674","repo":"ERCs","label":"ERC-5169","officialUrl":"https://eips.ethereum.org/EIPS/eip-5169","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5169.md","url":"https://eips.huatuo.xyz/eip-5169/","tldr":{"en":"Lets a token contract publish, via scriptURI(), where to fetch its official client-side script, so wallets can load trusted token-specific functionality straight from the contract.","ja":"トークンコントラクトが scriptURI() を通じて公式クライアントサイドスクリプトの取得先を公開できるようにし、ウォレットがトークン固有の信頼できる機能をコントラクトから直接読み込めるようにします。","ko":"토큰 컨트랙트가 scriptURI()를 통해 공식 클라이언트 측 스크립트를 어디서 가져올지 공개하게 해, 지갑이 토큰별 신뢰할 수 있는 기능을 컨트랙트에서 곧바로 불러올 수 있게 합니다.","zh":"让代币合约通过 scriptURI() 公布其官方客户端脚本的获取位置，使钱包可以直接从合约加载可信的、代币专属的功能。"},"tags":["token","nft","wallet","scripts","metadata","tokenscript"],"explainers":{"en":{"lang":"en","tldr":"Lets a token contract publish, via scriptURI(), where to fetch its official client-side script, so wallets can load trusted token-specific functionality straight from the contract.","tags":["token","nft","wallet","scripts","metadata","tokenscript"],"related":[20,721,1155,777,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5169/","markdown":"## What problem does it solve?\n\nMany tokens do more than sit in a wallet: an NFT might open an office door, a ticket might need check-in, a contract might have a `mint` function that wallets don't show. Projects deliver this through client scripts or mini dApps. The question is how a wallet or user knows which script is the **official** one for a token, since a fake script could build malicious transactions.\n\nERC-5169 anchors the answer in the token contract itself: call `scriptURI()` and you get the locations of the script the contract's owner endorses.\n\n## How it works\n\n```solidity\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n```\n\n- `scriptURI()` returns an **array** of URIs (any RFC 3986 URI: IPFS, a GitHub gist, cloud storage…), so the same script can be mirrored across centralised and decentralised hosts.\n- The contract keeps an `owner`, set to the deployer; only that owner may call `setScriptURI`.\n- Every update emits `ScriptUpdate`, so wallets can refresh a cached script.\n- The format of the script is not fixed. Examples include a \"TokenScript\", a cut-down single-token dApp, or a hardware-wallet extension.\n- **Integrity is the client's job:** anyone using the script must check it is at an immutable location, that the URI contains the script's hash, or that it carries a signature per the authors' companion \"Authenticity for Client Script\" proposal.\n\nStoring the script off-chain avoids heavy storage fees and avoids frequent use of the admin key for every script tweak.\n\n## Sample code\n\nContract side (OpenZeppelin v5 `Ownable`):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n\ncontract ScriptedToken is IERC5169, Ownable {\n    string[] private _scriptURI;\n\n    constructor() Ownable(msg.sender) {}\n\n    function scriptURI() external view returns (string[] memory) {\n        return _scriptURI;\n    }\n\n    function setScriptURI(string[] memory newScriptURI) external onlyOwner {\n        _scriptURI = newScriptURI;\n        emit ScriptUpdate(newScriptURI);\n    }\n}\n```\n\nWallet side (ethers v6), reading the list before fetching and verifying a script:\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst token = new Contract(tokenAddress,\n  [\"function scriptURI() view returns (string[])\"], provider);\nconst uris: string[] = await token.scriptURI();\n// e.g. [\"ipfs://\u003ccid\u003e\", \"https://example.com/token.tsml\"]\n// Prefer content-addressed URIs; otherwise verify a hash or signature before running.\n```\n\n## Things to know\n\n- **Status: Final.**\n- `scriptURI` tells you what the *contract owner* endorses, not that the script is safe. A compromised owner key can point every wallet at a malicious script, so treat updates with the same care as a contract upgrade.\n- An `https://` URI alone gives no integrity guarantee; content-addressed storage (IPFS CID) or a signature check is needed before executing anything.\n- If the script calls external server APIs, this standard says nothing about trusting those servers.\n- It works alongside [ERC-20](/eip-20/), [ERC-721](/eip-721/), [ERC-777](/eip-777/) and [ERC-1155](/eip-1155/) tokens without changing their behaviour.\n"},"ja":{"lang":"ja","tldr":"トークンコントラクトが scriptURI() を通じて公式クライアントサイドスクリプトの取得先を公開できるようにし、ウォレットがトークン固有の信頼できる機能をコントラクトから直接読み込めるようにします。","tags":["token","nft","wallet","scripts","metadata","tokenscript"],"related":[20,721,1155,777,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5169/","markdown":"## 何を解決するのか\n\n多くのトークンは、ウォレットに置かれているだけではありません。NFT がオフィスのドアを開けたり、チケットにチェックインが必要だったり、ウォレットが表示しない `mint` 関数をコントラクトが持っていたりします。プロジェクトはこれをクライアントスクリプトやミニ dApp で提供します。問題は、偽のスクリプトが悪意あるトランザクションを組み立てる可能性があるため、ウォレットやユーザーがどのスクリプトがそのトークンの**公式**のものかをどう知るかです。\n\nERC-5169 は、その答えをトークンコントラクト自体に置きます。`scriptURI()` を呼ぶと、コントラクトの所有者が承認したスクリプトの場所が得られます。\n\n## 仕組み\n\n```solidity\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n```\n\n- `scriptURI()` は URI の**配列**を返します（RFC 3986 の任意の URI: IPFS、GitHub gist、クラウドストレージなど）。そのため、同じスクリプトを中央集権型と分散型のホストにまたがってミラーできます。\n- コントラクトは `owner` を保持し、デプロイした人が設定されます。`setScriptURI` を呼べるのはその owner だけです。\n- 更新のたびに `ScriptUpdate` が発行されるため、ウォレットはキャッシュしたスクリプトを更新できます。\n- スクリプトの形式は固定されていません。たとえば「TokenScript」、単一トークン向けに切り詰めた dApp、ハードウェアウォレットの拡張などがあります。\n- **完全性の検証はクライアントの役割です。** スクリプトを使う人は、それが不変の場所にあること、URI にスクリプトのハッシュが含まれていること、または作者らの関連提案「Authenticity for Client Script」に従った署名が付いていることを確認しなければなりません。\n\nスクリプトをオフチェーンに置くことで、高額なストレージ料金を避けられ、スクリプトを微調整するたびに管理者キーを頻繁に使うことも避けられます。\n\n## サンプルコード\n\nコントラクト側（OpenZeppelin v5 の `Ownable`）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n\ncontract ScriptedToken is IERC5169, Ownable {\n    string[] private _scriptURI;\n\n    constructor() Ownable(msg.sender) {}\n\n    function scriptURI() external view returns (string[] memory) {\n        return _scriptURI;\n    }\n\n    function setScriptURI(string[] memory newScriptURI) external onlyOwner {\n        _scriptURI = newScriptURI;\n        emit ScriptUpdate(newScriptURI);\n    }\n}\n```\n\nウォレット側（ethers v6）。スクリプトを取得して検証する前にリストを読み取ります。\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst token = new Contract(tokenAddress,\n  [\"function scriptURI() view returns (string[])\"], provider);\nconst uris: string[] = await token.scriptURI();\n// e.g. [\"ipfs://\u003ccid\u003e\", \"https://example.com/token.tsml\"]\n// Prefer content-addressed URIs; otherwise verify a hash or signature before running.\n```\n\n## 知っておくべきこと\n\n- **ステータス: Final。**\n- `scriptURI` が示すのは*コントラクトの所有者*が承認しているものであり、スクリプトが安全であることではありません。所有者のキーが侵害されると、すべてのウォレットを悪意あるスクリプトに向けられてしまうため、更新にはコントラクトのアップグレードと同じ注意を払ってください。\n- `https://` の URI だけでは完全性は保証されません。何かを実行する前に、コンテンツアドレス型のストレージ（IPFS の CID）や署名の検証が必要です。\n- スクリプトが外部サーバーの API を呼ぶ場合、それらのサーバーを信頼できるかどうかについて、この標準は何も述べていません。\n- [ERC-20](/eip-20/)、[ERC-721](/eip-721/)、[ERC-777](/eip-777/)、[ERC-1155](/eip-1155/) のトークンと併用でき、それらの動作は変わりません。\n"},"ko":{"lang":"ko","tldr":"토큰 컨트랙트가 scriptURI()를 통해 공식 클라이언트 측 스크립트를 어디서 가져올지 공개하게 해, 지갑이 토큰별 신뢰할 수 있는 기능을 컨트랙트에서 곧바로 불러올 수 있게 합니다.","tags":["token","nft","wallet","scripts","metadata","tokenscript"],"related":[20,721,1155,777,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5169/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 토큰은 지갑에 가만히 있는 것 이상의 일을 합니다. NFT가 사무실 문을 열어 주기도 하고, 티켓에 체크인이 필요하기도 하며, 컨트랙트에 지갑이 보여주지 않는 `mint` 함수가 있기도 합니다. 프로젝트들은 이를 클라이언트 스크립트나 미니 dApp으로 제공합니다. 문제는 가짜 스크립트가 악성 트랜잭션을 만들 수 있으므로, 지갑이나 사용자가 어떤 스크립트가 토큰의 **공식** 스크립트인지 어떻게 아느냐입니다.\n\nERC-5169는 그 답을 토큰 컨트랙트 자체에 둡니다. `scriptURI()`를 호출하면 컨트랙트 소유자가 보증하는 스크립트의 위치를 얻을 수 있습니다.\n\n## 어떻게 동작하나요?\n\n```solidity\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n```\n\n- `scriptURI()`는 URI의 **배열**을 반환합니다(RFC 3986 URI면 무엇이든 가능: IPFS, GitHub gist, 클라우드 스토리지 등). 따라서 같은 스크립트를 중앙화된 호스트와 탈중앙화된 호스트에 걸쳐 미러링할 수 있습니다.\n- 컨트랙트는 배포자로 설정되는 `owner`를 유지하며, 그 owner만 `setScriptURI`를 호출할 수 있습니다.\n- 업데이트할 때마다 `ScriptUpdate`가 발생하므로 지갑이 캐시된 스크립트를 갱신할 수 있습니다.\n- 스크립트 형식은 고정되어 있지 않습니다. 예로는 \"TokenScript\", 단일 토큰용으로 축소한 dApp, 하드웨어 지갑 확장 등이 있습니다.\n- **무결성 확인은 클라이언트의 몫입니다.** 스크립트를 쓰는 사람은 그것이 변경 불가능한 위치에 있는지, URI에 스크립트의 해시가 들어 있는지, 또는 저자들의 관련 제안 \"Authenticity for Client Script\"에 따른 서명이 붙어 있는지 확인해야 합니다.\n\n스크립트를 오프체인에 저장하면 큰 스토리지 비용을 피할 수 있고, 스크립트를 조금 고칠 때마다 관리자 키를 자주 쓰는 일도 피할 수 있습니다.\n\n## 샘플 코드\n\n컨트랙트 측(OpenZeppelin v5 `Ownable`):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n\ncontract ScriptedToken is IERC5169, Ownable {\n    string[] private _scriptURI;\n\n    constructor() Ownable(msg.sender) {}\n\n    function scriptURI() external view returns (string[] memory) {\n        return _scriptURI;\n    }\n\n    function setScriptURI(string[] memory newScriptURI) external onlyOwner {\n        _scriptURI = newScriptURI;\n        emit ScriptUpdate(newScriptURI);\n    }\n}\n```\n\n지갑 측(ethers v6). 스크립트를 가져와 검증하기 전에 목록을 읽습니다.\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst token = new Contract(tokenAddress,\n  [\"function scriptURI() view returns (string[])\"], provider);\nconst uris: string[] = await token.scriptURI();\n// e.g. [\"ipfs://\u003ccid\u003e\", \"https://example.com/token.tsml\"]\n// Prefer content-addressed URIs; otherwise verify a hash or signature before running.\n```\n\n## 알아둘 점\n\n- **상태: Final.**\n- `scriptURI`는 *컨트랙트 소유자*가 무엇을 보증하는지 알려줄 뿐, 스크립트가 안전하다는 뜻은 아닙니다. 소유자 키가 탈취되면 모든 지갑이 악성 스크립트를 가리키게 할 수 있으므로, 업데이트도 컨트랙트 업그레이드와 같은 주의로 다루세요.\n- `https://` URI만으로는 무결성이 보장되지 않습니다. 무엇이든 실행하기 전에 콘텐츠 주소 기반 스토리지(IPFS CID)나 서명 검증이 필요합니다.\n- 스크립트가 외부 서버 API를 호출하는 경우, 그 서버를 신뢰할 수 있는지에 대해 이 표준은 아무 말도 하지 않습니다.\n- [ERC-20](/eip-20/), [ERC-721](/eip-721/), [ERC-777](/eip-777/), [ERC-1155](/eip-1155/) 토큰과 함께 동작하며 그 동작을 바꾸지 않습니다.\n"},"zh":{"lang":"zh","tldr":"让代币合约通过 scriptURI() 公布其官方客户端脚本的获取位置，使钱包可以直接从合约加载可信的、代币专属的功能。","tags":["token","nft","wallet","scripts","metadata","tokenscript"],"related":[20,721,1155,777,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5169/","markdown":"## 它解决什么问题？\n\n许多代币不只是躺在钱包里：NFT 可能会打开一扇办公室的门，门票可能需要签到，合约可能有钱包不会显示的 `mint` 函数。项目通过客户端脚本或迷你 dApp 来提供这些功能。问题在于，钱包或用户如何知道哪个脚本才是某个代币的**官方**脚本，因为假脚本可能构造恶意交易。\n\nERC-5169 把答案锚定在代币合约本身：调用 `scriptURI()`，就能得到合约所有者认可的脚本所在位置。\n\n## 它如何运作\n\n```solidity\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n```\n\n- `scriptURI()` 返回一个 URI **数组**（任何 RFC 3986 URI：IPFS、GitHub gist、云存储……），因此同一个脚本可以同时镜像到中心化和去中心化的托管位置。\n- 合约保存一个 `owner`，设置为部署者；只有该 owner 可以调用 `setScriptURI`。\n- 每次更新都会触发 `ScriptUpdate`，因此钱包可以刷新缓存的脚本。\n- 脚本的格式没有固定。例如有\"TokenScript\"、针对单一代币精简的 dApp，或硬件钱包扩展。\n- **完整性由客户端负责：** 任何使用该脚本的人都必须检查它位于不可变的位置、URI 中包含脚本的哈希，或者它带有符合作者配套提案\"Authenticity for Client Script\"的签名。\n\n把脚本存放在链下，可以避免高昂的存储费用，也避免每次调整脚本都频繁使用管理员密钥。\n\n## 示例代码\n\n合约侧（OpenZeppelin v5 `Ownable`）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IERC5169 {\n    event ScriptUpdate(string[] newScriptURI);\n    function scriptURI() external view returns (string[] memory);\n    function setScriptURI(string[] memory newScriptURI) external;\n}\n\ncontract ScriptedToken is IERC5169, Ownable {\n    string[] private _scriptURI;\n\n    constructor() Ownable(msg.sender) {}\n\n    function scriptURI() external view returns (string[] memory) {\n        return _scriptURI;\n    }\n\n    function setScriptURI(string[] memory newScriptURI) external onlyOwner {\n        _scriptURI = newScriptURI;\n        emit ScriptUpdate(newScriptURI);\n    }\n}\n```\n\n钱包侧（ethers v6），在获取并验证脚本之前先读取列表：\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst token = new Contract(tokenAddress,\n  [\"function scriptURI() view returns (string[])\"], provider);\nconst uris: string[] = await token.scriptURI();\n// e.g. [\"ipfs://\u003ccid\u003e\", \"https://example.com/token.tsml\"]\n// Prefer content-addressed URIs; otherwise verify a hash or signature before running.\n```\n\n## 需要注意\n\n- **状态：Final。**\n- `scriptURI` 告诉你的是*合约所有者*认可什么，而不是脚本是否安全。所有者密钥一旦被攻破，就可以让所有钱包指向恶意脚本，因此对待更新要像对待合约升级一样谨慎。\n- 仅有 `https://` URI 不提供任何完整性保证；在执行任何内容之前，需要内容寻址存储（IPFS CID）或签名校验。\n- 如果脚本调用外部服务器 API，本标准对是否应信任这些服务器没有任何规定。\n- 它可以与 [ERC-20](/eip-20/)、[ERC-721](/eip-721/)、[ERC-777](/eip-777/) 和 [ERC-1155](/eip-1155/) 代币配合使用，而不改变它们的行为。\n"}}}
