ERC-4519 · Final · ERC · 2021-12-03
ERC-4519: Non-Fungible Tokens Tied to Physical Assets
An ERC-721 extension for NFTs bound to physical devices: the device has its own Ethereum address, and owners and users mutually authenticate with it on-chain before they can control it.
What problem does it solve?
An ERC-721 token records who owns something, but nothing more. For a physical, connected asset such as an IoT device, that is not enough:
- Ownership and use are different. You may want to lend a device to someone without giving them ownership.
- The device itself has no on-chain identity, so there is no way to prove the NFT is really tied to that specific piece of hardware.
- When ownership changes, the device needs a secure way to learn who its new owner is and set up an encrypted channel with them.
ERC-4519 extends ERC-721 so the physical asset has its own Ethereum address, can sign transactions, and follows an operating mode dictated by its token.
How it works
Each token can carry two optional addresses: addressAsset (the device) and addressUser (whoever is currently allowed to use it). At least one should be set. The token moves through states:
- With only a user:
notAssigned→userAssigned. - With an asset:
waitingForOwner→engagedWithOwner, then optionallywaitingForUser→engagedWithUser.
Mutual authentication uses an elliptic-curve Diffie–Hellman exchange on secp256k1:
- The owner generates a fresh key pair and computes a shared key
K_Ofrom the asset's public key. - The owner calls
startOwnerEngagement, storing their public key (dataEngagement) andhash(K_O)on-chain. - The device reads that public key, computes the same shared key from its side, and calls
ownerEngagement(hash(K_A)). - If the hashes match, the token becomes
engagedWithOwnerand emitsOwnerEngaged. Both sides now share a session key for encrypted off-chain communication.
The same flow applies to a user via setUser, startUserEngagement and userEngagement.
A timeout mechanism keeps the tie fresh: the device periodically calls updateTimestamp(), and anyone can call checkTimeout(tokenId) to emit a TimeoutAlarm if it has gone quiet. The ERC-165 interface ID is 0x8a68abe3.
Sample code
Key parts of the interface:
interface IERC4519 /* is IERC721 */ {
event UserAssigned(uint256 indexed tokenId, address indexed _addressUser);
event OwnerEngaged(uint256 indexed tokenId);
event UserEngaged(uint256 indexed tokenId);
event TimeoutAlarm(uint256 indexed tokenId);
function setUser(uint256 _tokenId, address _addressUser) external payable;
function startOwnerEngagement(uint256 _tokenId, uint256 _dataEngagement, uint256 _hashK_OA) external payable;
function ownerEngagement(uint256 _hashK_A) external payable; // called by the asset
function startUserEngagement(uint256 _tokenId, uint256 _dataEngagement, uint256 _hashK_UA) external payable;
function userEngagement(uint256 _hashK_A) external payable; // called by the asset
function checkTimeout(uint256 _tokenId) external returns (bool);
function setTimeout(uint256 _tokenId, uint256 _timeout) external; // seconds
function updateTimestamp() external; // called by the asset
function tokenFromBCA(address _addressAsset) external view returns (uint256);
function userOf(uint256 _tokenId) external view returns (address);
}
Note that ownerEngagement, userEngagement and updateTimestamp take no token ID: the contract identifies the token from msg.sender, which must be the asset's own address.
Things to know
- Status: Final.
- Security rests on the device's private key staying secret. The spec recommends the key be generated inside the device (for example from a Physical Unclonable Function) and that only the manufacturer mints the matching token.
- Key exchange happens partly off-chain between person and device; the contract only checks that both sides derived the same secret hash.
- If you only need a simple, time-limited "user" role without device authentication, ERC-4907 is far lighter.