Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-7738 proposes a way to register and retrieve executable script URIs onchain, independently of the contract itself.
This article translates, summarizes, and expands on the following proposal.
I also cover a range of EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
ERC-7738 defines a registry contract that lets users register and retrieve URIs (addresses from which resources can be obtained over the Internet) for executable scripts associated with arbitrary smart contract addresses.
The registry has the following characteristics.
First, it is designed as a global registry contract. In a multichain environment, a contract with identical code is deployed at exactly the same address on Ethereum, L2 networks, sidechains, and other chains. This is called a multichain singleton: a single logical instance at the same address on every chain.
Second, the registry maintains a mapping from contract addresses to lists of script URIs. Clients such as wallets, NFT viewers, and mini-DApps can query the registry using a token or contract address to discover where its associated scripts can be retrieved.
Script registration is not restricted to a particular administrator. The registry exposes a permissionless setter function that lets anyone register script URIs for arbitrary addresses. This makes it possible to add UI extensions or tool integrations without modifying the original contract.
In summary, ERC-7738 provides the following capabilities.
| Aspect | Description |
|---|---|
| Management | Script locations are managed centrally through a shared registry. |
| Target | Scripts can be associated with arbitrary smart contract addresses. |
| Retrieval | Wallets and DApps retrieve the URI, download the script, and execute it. |
| Deployment | A singleton is deployed at the same address across multiple chains. |
| Registration permissions | Anyone can register scripts in this permissionless design. |
This mechanism allows the behavior and presentation logic of tokens and NFTs to evolve independently of their onchain contracts.
Motivation
The motivation for ERC-7738 comes from limitations of ERC-5169, an existing standard for discovering the location of client-side scripts associated with smart contracts, such as JavaScript programs executed in wallets or user interfaces. It allows tokens and NFTs to have dedicated presentation and interaction logic.
For more on ERC-5169, see the following article.
[ERC5169] Securely connecting client scripts and NFTs
However, ERC-5169 has two important limitations.
First, the contract itself must implement the ERC-5169 interface (the definitions of functions callable from outside the contract). If this specification was not incorporated when the contract was deployed onchain, support cannot easily be added later. Unless the contract was designed to be upgradeable, adding script integration in the future becomes impossible.
Second, script management is distributed across individual contracts. Each contract maintains its own script locations, so wallets and viewers must handle individual contracts and chains separately.
ERC-7738 addresses these issues by providing a shared registry for script locations. This makes it possible to:
- Associate scripts without modifying existing contracts.
- Discover scripts using the same mechanism across chains.
- Distribute trusted scripts (
certified) separately from experimental scripts (prototype).
A prototype script is an experimental or early-stage program, while a certified script is intended for production use after auditing or verification.
Specification
Mandatory and recommended requirements
The ERC-7738 registry contract must exhibit the following behavior.
First, the contract must implement the IERC7738 interface so that wallets and DApps can retrieve script information in a consistent way.
Second, whenever a script is updated, the contract must emit a ScriptUpdate event. Wallets can use this event to update their cached scripts automatically.
There is also a recommendation about the ordering of values returned by scriptURI. Scripts registered by the target contract's ERC-173 owner() should appear first. Many wallets use the first URI returned, so this ordering is intended to prioritize scripts configured by the legitimate administrator.
Pagination is also recommended in case a large number of scripts are registered. Returning many URIs in a single call can create problems with gas costs and response sizes.
Interface definition
The following interface is defined by ERC-7738.
interface IERC7738 {
/// @dev This event emits when the scriptURI is updated,
/// so wallets implementing this interface can update a cached script
event ScriptUpdate(address indexed contractAddress, string[] newScriptURI);
/// @notice Get the scriptURI for the contract
/// @return The scriptURI
function scriptURI(address contractAddress) external view returns (string[] memory);
/// @notice Update the scriptURI
/// emits event ScriptUpdate(address indexed contractAddress, scriptURI memory newScriptURI);
function setScriptURI(address contractAddress, string[] memory scriptURIList) external;
}The ScriptUpdate event
ScriptUpdate is emitted when the script URIs associated with a contract address are updated. contractAddress contains the target contract address, and newScriptURI contains the array of newly configured script URIs.
Wallets and viewers can monitor this event to detect changes to cached script information. They can then update token presentation logic and executable interaction code automatically, providing a UI that reflects the latest behavior.
The scriptURI function
The scriptURI function retrieves the list of script URIs associated with a specified contract address. It returns an array of strings, allowing the locations of several scripts to be returned together.
A single token or NFT can thus be associated with several executable scripts for different purposes, such as presentation, interaction, and verification. Wallets and mini-DApps select the appropriate scripts from this array and execute them.
The setScriptURI function
The setScriptURI function registers or updates an array of script URIs for a specified contract address. Calling it must emit a ScriptUpdate event to announce the change onchain.
Because ERC-7738 is permissionless, anyone can call this function to register scripts, not just designated administrators. However, wallets are expected to select the scripts they actually use based on trust-aware ordering or selection rules, such as prioritizing entries registered by the ERC-173 owner(), rather than accepting every entry unconditionally.
For more on ERC-173, see the following article.
[ERC173] Controlling contract ownership
Rationale
There are two main reasons for the approach taken by ERC-7738.
First, scripts can be associated retroactively with existing contracts that do not implement ERC-5169. Registering a URI in an external registry, without changing the contract itself, lets wallets and DApps provide a dedicated UI or logic.
Second, the approach removes the need for a centralized server to manage script locations. Traditionally, information such as the URL of a token's UI would have to reside in a database administered by a specific company or operator. This creates several risks:
- Server tampering.
- Service outages.
- The managing organization becoming a de facto gatekeeper.
ERC-7738 stores script locations directly in an onchain registry contract. Scripts can therefore be discovered and distributed in a verifiable, tamper-resistant manner without relying on a particular organization.
As a result, tokens and NFTs can extend their behavior and presentation logic while retaining onchain reliability and decentralization.
Reference implementation
import "@openzeppelin/contracts/access/Ownable.sol";
contract DecentralisedRegistry is IERC7738 {
struct ScriptEntry {
mapping(address => string[]) scriptURIs;
address[] addrList;
}
mapping(address => ScriptEntry) private _scriptURIs;
function setScriptURI(
address contractAddress,
string[] memory scriptURIList
) public {
require (scriptURIList.length > 0, "> 0 entries required in scriptURIList");
bool isOwnerOrExistingEntry = Ownable(contractAddress).owner() == msg.sender
|| _scriptURIs[contractAddress].scriptURIs[msg.sender].length > 0;
_scriptURIs[contractAddress].scriptURIs[msg.sender] = scriptURIList;
if (!isOwnerOrExistingEntry) {
_scriptURIs[contractAddress].addrList.push(msg.sender);
}
emit ScriptUpdate(contractAddress, msg.sender, scriptURIList);
}
// Return the list of scriptURI for this contract.
// Order the return list so `Owner()` assigned scripts are first in the list
function scriptURI(
address contractAddress
) public view returns (string[] memory) {
//build scriptURI return list, owner first
address contractOwner = Ownable(contractAddress).owner();
address[] memory addrList = _scriptURIs[contractAddress].addrList;
uint256 i;
//now calculate list length
uint256 listLen = _scriptURIs[contractAddress].scriptURIs[contractOwner].length;
for (i = 0; i < addrList.length; i++) {
listLen += _scriptURIs[contractAddress].scriptURIs[addrList[i]].length;
}
string[] memory ownerScripts = new string[](listLen);
// Add owner scripts
uint256 scriptIndex = _addScriptURIs(contractOwner, contractAddress, ownerScripts, 0);
// Add remainder scripts
for (uint256 i = 0; i < addrList.length; i++) {
scriptIndex = _addScriptURIs(addrList[i], contractAddress, ownerScripts, scriptIndex);
}
return ownerScripts;
}
function _addScriptURIs(
address user,
address contractAddress,
string[] memory ownerScripts,
uint256 scriptIndex
) internal view returns (uint256) {
for (uint256 j = 0; j < _scriptURIs[contractAddress].scriptURIs[user].length; j++) {
string memory thisScriptURI = _scriptURIs[contractAddress].scriptURIs[user][j];
if (bytes(thisScriptURI).length > 0) {
ownerScripts[scriptIndex++] = thisScriptURI;
}
}
return scriptIndex;
}
}Security
Script authentication methods
When the target contract implements ERC-173 (Ownable)
If the target contract exposes the ERC-173 owner() function, authentication is relatively straightforward. After retrieving the script from the registry, verify that the signature attached to it corresponds to the address returned by owner(). If it matches, the script can be treated as authorized by the contract owner.
When using TokenScript, several authentication methods are proposed. All of them check whether the signature is valid.
| Method | What it does | Who performs it |
|---|---|---|
| TokenScript SDK | Uses TokenScript's signature verification logic to authenticate the script. | Wallet / DApp |
| TokenScript online verification service | Delegates verification to an external service. | Wallet / DApp |
| Extract and verify a signature from XML | Extracts the signature from XML, hashes the script, recovers the signer, and checks whether it matches owner(). |
Wallet / DApp |
The following diagram is retained from the Japanese original and contains Japanese labels.
sequenceDiagram participant R as ERC7738レジストリ participant W as ウォレット/DApp participant C as 対象コントラクト(ERC173) participant S as スクリプト(例: TokenScript) W->>R: scriptURI(contractAddress) R-->>W: URI配列 W->>S: URIからスクリプト取得 W->>S: XMLから署名を抽出 W->>S: スクリプト本体をkeccak256でハッシュ化 W->>S: ecrecoverで署名者アドレスを復元 W->>C: owner() C-->>W: オーナーアドレス W-->>W: 署名者 == owner() を確認
- keccak256 A hash function commonly used in Ethereum. It converts data into a fixed-length value.
- ecrecover A mechanism for recovering a signer's address from a signature and a message (a hash in this case).
When the target contract does not implement Ownable (ERC-173)
Authentication options are still available if the target contract has no owner() function.
Identify the deployment key (deployer) and compare it
A wallet or DApp can use a third-party API or a block explorer (a service for viewing transaction history, such as Etherscan) to identify the address that deployed the contract. It can then check whether the script signer matches that deployment address.
Here, the deployment key refers not to the private key itself, but to the address used for deployment (the public identity against which the signature is verified).
Embed a pre-authenticated keychain on the hosting side
A wallet or application maintains an internal list of trusted signer public keys (addresses) and determines whether the signer belongs to that list. An embedded keychain here means a list of trusted keys embedded in the application, not an operating system keychain.
Use governance tokens to form a script council that approves keys
Another proposal is to use governance tokens to establish a body (a script council) that approves script registration requests or key verification. The idea is to establish legitimacy through community or organizational decision-making if no owner() function exists.
Handling scripts that cannot meet authentication requirements
The proposal also describes what to do if the authentication methods above are unavailable or their requirements are not met. The approach differs by chain environment.
| Environment | General policy | Final decision |
|---|---|---|
| Mainnet (production) | Wallets should exercise caution when using scripts. | At the discretion of the application provider or user. |
| Testnet | Running scripts is considered acceptable. | At the discretion of the wallet provider. |
On mainnet, unauthenticated scripts should not be executed casually because they can cause real harm, such as asset losses or fraudulent prompts. Testnets, by contrast, are intended for testing and development, so some risk can be accepted to prioritize functional testing.
Citation
Victor Zhang (@zhangzhongnan928), James Brown (@JamesSmartCell), "ERC-7738: Permissionless Script Registry [DRAFT]," Ethereum Improvement Proposals, no. 7738, July 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7738.
Conclusion
This article covered ERC-7738, which proposes an onchain mechanism for registering and retrieving executable script URIs independently of the contract itself.
If you have questions, feel free to contact me via Twitter direct messages.
I also publish on other platforms:



