ERC-5719 · Stagnant · ERC · 2022-09-26
ERC-5719: Signature replacement interface
Lets a smart contract wallet publish a URI where clients can fetch a fresh replacement for a signature that has become invalid after the wallet's signers or code changed.
What problem does it solve?
An EOA signature is valid forever. A smart contract wallet signature, checked through ERC-1271 isValidSignature, is not: it can go stale when the wallet removes a signer, adds signers to a Merkle tree, makes signatures expire, or upgrades to a new implementation with a different signature format.
That breaks protocols that hold signatures for a long time, such as an exchange with an off-chain order book that settles a signed order days later. By then the wallet owner may not be around to sign again. ERC-5719 lets the signature be replaced non-interactively.
How it works
The wallet implements one view function:
function getAlternativeSignature(bytes32 _digest) external view returns (string);
It returns a URI pointing to a JSON object with two fields: signature (the replacement) and blockHash (a block on which that signature should be valid). A URI is used so the source can be a live server that re-encodes Merkle proofs, or an IPFS directory of precomputed alternatives.
A client holding a signature follows this loop:
- Check it with ERC-1271. If valid, use it as-is.
- Otherwise call
getAlternativeSignature(digest). - If the call fails, returns nothing, or the URI content is invalid, the signature is invalid.
- Check the new signature with ERC-1271. If valid, use it as a drop-in replacement.
- If not, go back to step 2. If the URI returns the same signature again, give up.
Clients must enforce their own retry limit.
Sample code
Client-side replacement loop (ethers v6):
import { Contract, JsonRpcProvider } from "ethers";
const MAGIC = "0x1626ba7e"; // ERC-1271 isValidSignature selector / magic value
const abi = [
"function isValidSignature(bytes32,bytes) view returns (bytes4)",
"function getAlternativeSignature(bytes32) view returns (string)",
];
async function resolveSignature(wallet: string, digest: string, sig: string, maxTries = 3) {
const w = new Contract(wallet, abi, new JsonRpcProvider(process.env.RPC_URL));
const ok = async (s: string) => (await w.isValidSignature(digest, s).catch(() => "0x")) === MAGIC;
if (await ok(sig)) return sig;
for (let i = 0; i < maxTries; i++) {
const uri: string = await w.getAlternativeSignature(digest).catch(() => "");
if (!uri) break;
const alt = (await (await fetch(uri)).json())?.signature;
if (!alt || alt === sig) break;
if (await ok(alt)) return alt;
sig = alt;
}
throw new Error("signature invalid");
}
Things to know
- Status is Stagnant: there has been no recent activity and it is not a widely adopted standard.
- Wallets that don't implement the function are unaffected; clients simply drop their stale signatures at step 3.
- Some applications treat signatures as secrets. Publishing alternative signatures at a URI could leak them, so this pattern is not suitable for those cases.
- The off-chain source is trusted only for availability: every returned signature is still verified on-chain via ERC-1271.