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.

This article covers ERC4519, a standard for representing physical assets as NFTs.

The following proposal is translated, summarized, and supplemented with the help of ChatGPT.

Overview

This EIP standardizes an interface for non-fungible tokens (NFTs) that represent physical assets, such as IoT devices.

A non-fungible token is a token that cannot be exchanged on a like-for-like basis with another token.

An NFT is associated with a physical asset, and the authenticity of that association can be verified. For example, you can verify that an NFT representing an IoT device actually corresponds to that device.

IoT.png

The NFT includes the Ethereum address of its corresponding physical asset. This allows the physical asset to sign messages and transactions on Ethereum. In other words, the NFT associated with an IoT device can control the operations that the device performs on Ethereum.

IoTNft.png

The existing NFT standard, EIP721, focuses on tracking ownership rather than tracking the rights to use smart assets such as physical devices. EIP721 also cannot track the Ethereum addresses of physical assets.

A physical asset's Ethereum address is an address that associates a physical item, such as an IoT device, product, machine, or vehicle, with a digital account on the Ethereum blockchain. For example, an IoT device associated with a particular Ethereum address can use it to interact with the Ethereum network, exchange messages, and sign transactions. This enables secure communication and management between the physical asset and the Ethereum network.

This new EIP makes it possible to manage IoT devices and other physical assets securely and traceably.

trait.png

Motivation

This standard was developed because EIP721 tracks ownership rather than usage rights and does not track the Ethereum addresses of physical assets. Smart assets such as IoT devices are becoming increasingly popular. These NFTs enable secure, traceable management of physical assets, such as IoT devices and tangible products, their owners, and their users.

Specifically, the NFT contains information corresponding to a physical asset, including its Ethereum address and other important data. This provides the following benefits.

  1. Verifying the authenticity of physical assets Because NFTs are linked to physical assets, they can help prevent counterfeiting and unauthorized manipulation. The NFT is intended to provide assurance that it corresponds to a genuine physical asset.

  2. Improved security Physical assets are associated with Ethereum addresses. They can therefore communicate and transact securely on the Ethereum network. This helps protect physical assets from malicious operations.

  3. Tracking owners and users An NFT representing a physical asset can track the relationship between its owner and its users. This makes it possible to identify who owns the physical asset and who uses it.

  4. Permission management NFTs can make the management of physical assets more efficient. Verifying the association between a physical asset and its NFT helps establish whether owners and users have the required permissions.

Specification

NFT properties linking physical assets and users

The specification describes two Ethereum address attributes in the NFT: addressAsset and addressUser.

  1. addressAsset The Ethereum address of the physical asset, such as an IoT device or a tangible product. It identifies the physical asset associated with the NFT.

  2. addressUser The Ethereum address of the user who holds or uses the NFT. This address identifies the user authorized to use the physical asset.

The attributes are optional; both are not required. At least one must be included in the NFT. For example, use addressAsset to associate a physical asset directly with an Ethereum address. When a particular user holds the NFT, addressUser can be used.

If only the addressUser attribute is used, two states are considered.

  1. Unassigned (notAssigned) When a token is created, transferred from one owner to another, or unassigned from a user, it enters the unassigned state. This indicates that no user has been assigned to the physical asset.

  2. Assigned to a user (userAssigned) When the token is assigned to a valid user, it enters the user-assigned state. This indicates that the physical asset is held or used by a particular user.

The specification defines the relationship between a physical asset and its associated user, enabling secure and traceable management.

Assignment

Figure1.jpg Source: https://eips.ethereum.org/EIPS/eip-4519

Owner authentication and engagement for physical assets

If addressAsset is defined but addressUser is not, the NFT has two states. These states distinguish a token awaiting owner authentication from one for which authentication has succeeded.

The following flowchart illustrates the two states. When the token is created or transferred to a new owner, it enters the waitingForOwner state (awaiting owner authentication). In this state, the token awaits mutual authentication between the asset and the owner. The owner's relationship with the asset has not yet been verified, so authentication is still required.

If owner authentication succeeds, the token moves to engagedWithOwner (engaged with the owner). This indicates that the owner and asset have been linked and secure interaction has been established.

The specification thus distinguishes the state in which the physical asset awaits owner authentication from the state in which it is engaged with the authenticated owner. This enables secure interaction between the physical asset and its owner, as well as management based on the token's state.

Engagement

Figure2.jpg Source: https://eips.ethereum.org/EIPS/eip-4519

State transitions involving both owners and users

When both addressAsset and addressUser are defined, the NFT state indicates whether the physical asset is engaged with its owner or user. The following states and transitions describe the lifecycle.

  • waitingForOwner (awaiting owner authentication) When the token is created or its owner changes, the token enters waitingForOwner. The token is still awaiting owner authentication, and mutual authentication between the physical asset and its owner is required.

  • engagedWithOwner (engaged with the owner) When the token is assigned to a valid owner, it moves to engagedWithOwner. The physical asset is associated with a valid owner, indicating successful mutual authentication with the owner.

  • waitingForUser (awaiting user authentication) When the physical asset is engaged with its owner (engagedWithOwner) or its user (engagedWithUser)) and a user has not yet been assigned, the token enters waitingForUser`. The physical asset is engaged with a valid owner and is waiting for the owner to assign a valid user.

  • engagedWithUser (engaged with the user) When the physical asset is assigned to a valid user, the token moves to engagedWithUser. The physical asset is associated with a valid user, who can use the asset.

These states clarify the relationships between a physical asset, its owner, and its user, enabling state-dependent management. The following flowchart visualizes these transitions. This enables secure interaction and orderly management among the physical asset, owner, and user.

Figure3.jpg Source: https://eips.ethereum.org/EIPS/eip-4519

NFT ownership transfer and mutual authentication

To transfer ownership of the NFT, the new owner must complete mutual authentication with the asset. The process involves off-chain interaction with the asset alongside on-chain interaction with the token. Ethereum addresses are used in this process. Similarly, a new user must mutually authenticate with the asset to complete the transfer of usage rights. This generates new cryptographic keys for secure communication between the asset and its owner and between the asset and its user. The asset's authenticity can therefore be tracked even when it is managed by a new owner or user.

When an NFT is created or ownership is transferred, the token enters waitingForOwner (awaiting owner authentication). The asset sets its operating mode to waitingForOwner (awaiting owner authentication). The new owner generates two keys using the elliptic curve secp256k1 and its generator point P. The pair consists of private key SKO_A and public key PKO_A. Here, PKO_A = SKO_A * P. To generate a shared key KO between the owner and asset, the owner uses the asset's public key PKA as follows.

KO = PKA * SKO_A

Using startOwnerEngagement, the owner stores PKO_A as dataEngagement and the hash of KO as hashK_OA. The owner sends a request engagement message to the asset, which computes the following.

KA = SKA * PKO_A

If KO and KA are computed correctly, they have the same value. This follows from the equality below.

KO = PKA * SKO_A = (SKA * P) * SKO_A = SKA * (SKO_A * P) = SKA * PKO_A

Using ownerEngagement, the asset submits the hash of KA. If the hash of KA matches hashK_OA, the token enters engagedWithOwner (engaged with the owner), and an OwnerEngaged event is emitted. When the asset receives this event, it switches its operating mode to engagedWithOwner (engaged with the owner). The asset can then be managed by its new owner, using the shared key to communicate securely.

The following figure illustrates the process. From this point, the asset is managed by its new owner, and secure interaction with the owner has been established.

Figure4.jpg Source: https://eips.ethereum.org/EIPS/eip-4519

Transfer process when the NFT is in waitingForUser

This process applies when the asset checks Ethereum and finds the NFT in waitingForUser. First, the asset switches its operating mode to waitingForUser. Mutual authentication with the new user then begins, much like the process for a new owner.

The user sends a transaction invoking startUserEngagement. This function stores the user's generated public key PKU_A as the NFT's dataEngagement attribute and the hash of the shared key KU = PKA * SKU_A as hashK_UA. The information required for mutual authentication between the asset and user is thereby recorded in the NFT.

The user then sends request engagement. The asset receives it and calculates KA = SKA * PKU_A. KA is the shared key obtained by multiplying the user's public key PKU_A by the asset's private key SKA.

If the process is performed correctly, the shared keys KU and KA have the same value. This follows from the equality below.

KU = PKA * SKU_A = (SKA * P) * SKU_A = SKA * (SKU_A * P) = SKA * PKU_A

The asset then submits the hash of KA to the NFT using userEngagement. If it matches the NFT's stored hashK_UA, the token enters engagedWithUser and a UserEngaged event is emitted. Upon receiving the event, the asset switches its operating mode to engagedWithUser. The asset is then managed by its new user and can communicate securely using the shared key.

The following figure illustrates the process. From this point, the asset is managed by its new user, and secure interaction with the user has been established.

Figure5.jpg Source: https://eips.ethereum.org/EIPS/eip-4519

Establishing shared secret keys is essential for secure communication involving the NFT. For this purpose, the NFT includes three attributes.

  • hashK_OA This attribute defines the hash of the secret key shared between the asset and its owner. It is used to establish a common secret key between them.

  • hashK_UA This attribute defines the hash of the secret key shared between the asset and its user. It is used to establish a common secret key between them.

  • dataEngagement This attribute defines public data required to establish the shared key. It includes the information required for the asset, owner, and user to generate their shared keys.

These attributes enable the establishment of shared secret keys for secure communication between the asset and its owner and between the asset and its user. Owners and users can mutually authenticate and communicate securely using the correct shared secret keys, enabling trustworthy communication between the asset and the parties involved.

A shared secret key is a cryptographic key used to share secret information between two communicating parties. It is random data generated using a particular cryptographic algorithm and kept secret between the communicating parties.

Shared secret keys are commonly used in cryptographic schemes known as symmetric-key cryptography. By sharing the same secret key, the parties can encrypt and decrypt messages. The sender encrypts the message with the shared secret key, and the recipient decrypts it using the same key.

Since the shared secret key must remain secret between the parties, its confidentiality and security are essential. Improper key management or sharing can allow third parties to gain unauthorized access or intercept messages. Secure communication therefore requires a trustworthy key exchange mechanism and proper cryptographic key management.

Interface

javascript
pragma solidity ^0.8.0;
interface EIP-4519 NFT is EIP721/*,EIP165*/{
    event UserAssigned(uint256 indexed tokenId, address indexed _addressUser);
    
    event UserEngaged(uint256 indexed tokenId);
    
    event OwnerEngaged(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; 
 
    function startUserEngagement(uint256 _tokenId, uint256 _dataEngagement, uint256 _hashK_UA) external payable;
    
    function userEngagement(uint256 _hashK_A) external payable; 
 
    function checkTimeout(uint256 _tokenId) external returns (bool);
    
    function setTimeout(uint256 _tokenId, uint256 _timeout) external; 
    
    function updateTimestamp() external; 
    
    function tokenFromBCA(address _addressAsset) external view returns (uint256);

    function ownerOfFromBCA(address _addressAsset) external view returns (address);

    function userOf(uint256 _tokenId) external view returns (address);
    
    function userOfFromBCA(address _addressAsset) external view returns (address);
    
    function userBalanceOf(address _addressUser) external view returns (uint256);
    
    function userBalanceOfAnOwner(address _addressUser, address _addressOwner) external view returns (uint256);

UserAssigned

Event emitted when the NFT's utility is assigned to a new user.

Assigning the utility of an NFT to a user means associating it with a particular user who can use the NFT to access specific features or services. For example, if the NFT grants access rights or special benefits, its owner can assign those rights to a particular user so that the user can enjoy them.

  • tokenId
    • NFT token ID.
  • _addressUser
    • Address of the new user.

UserEngaged

Event emitted when mutual authentication between the user and asset succeeds.

  • tokenId
    • NFT token ID.

OwnerEngaged

Event emitted when mutual authentication between the owner and asset succeeds.

  • tokenId
    • NFT token ID.

TimeoutAlarm

Event indicating that the timeout has elapsed. It is emitted when the NFT's timestamp has not been updated within the timeout period.

setUser

Function that assigns the utility of an NFT to a new user.

  • _tokenId
    • NFT token ID.
  • _addressUser
    • Address of the new user.

When addressAsset is defined The NFT must be in engagedWithOwner, waitingForUser, or engagedWithUser. The function changes the state of the NFT identified by _tokenId to waitingForUser.

When addressAsset is not defined The function sets the state of the NFT identified by _tokenId to userAssigned.

In both cases The function sets addressUser to _addressUser.

startOwnerEngagement

Function that initiates mutual authentication between the owner and the asset.

  • _tokenId
    • NFT token ID.
  • _dataEngagement
    • Public data proposed by the owner for shared key agreement.
  • _hashK_OA
    • Hash of the secret key proposed by the owner to share with the asset.

The owner proposes public data and the hash of a shared secret to the asset. This initiates agreement on a secure communication channel between the owner and the asset. The function alone does not complete mutual authentication; another function completes the process later.

When addressAsset is defined The NFT must be in waitingForOwner. The supplied values for _dataEngagement and _hashK_OA are stored for the NFT identified by _tokenId. The NFT state remains unchanged.

ownerEngagement

Function that completes mutual authentication between the owner and the asset. By calling this function, the asset completes mutual authentication with the owner. Agreement is established and the NFT enters engagedWithOwner only if the hash provided by the asset matches the hash held by the owner. This establishes a secure communication channel between the owner and asset.

  • _hashK_A
    • Hash of the secret generated by the asset to share with the owner.

This function can only be executed when the NFT is in waitingForOwner and dataEngagement is nonzero.

The function compares the stored NFT parameter hashK_OA with the supplied _hashK_A.

If hashK_OA and _hashK_A match, the following operations occur.

  1. The NFT enters engagedWithOwner.
  2. dataEngagement is set to 0.
  3. An OwnerEngaged event is emitted.

startUserEngagement

Function that initiates mutual authentication between the user and the asset. The user proposes public data and a hash of a secret, which are stored as NFT parameters. The asset subsequently uses the proposed data to complete mutual authentication. If the asset produces a matching hash of the proposed secret, agreement is established and the NFT enters engagedWithUser. This establishes a secure communication channel between the user and the asset.

  • _tokenId
    • NFT token ID.
  • _dataEngagement
    • Public data proposed by the owner for shared key agreement.
  • _hashK_UA
    • Hash of the secret key proposed by the user to share with the asset.

The user can execute this function only when the NFT is in waitingForUser and both addressAsset and addressUser are defined.

The function leaves the NFT state unchanged and stores the following information as NFT parameters.

  • _dataEngagement
    • Stores the public data proposed by the user.
  • _hashK_UA
    • Stores the hash of the secret proposed by the user.

userEngagement

Function that completes mutual authentication between the user and the asset. The asset compares the hash of the secret provided by the user with the secret hash stored in the NFT. If the hashes match, agreement is established and the NFT enters engagedWithUser. This establishes a secure communication channel between the user and the asset.

  • _hashK_A
    • Hash of the secret generated by the asset to share with the user.

The asset can execute this function only when the NFT is in waitingForUser and dataEngagement is nonzero.

It compares the NFT's stored hashK_UA with the supplied _hashK_A.

If hashK_UA and _hashK_A match, mutual authentication succeeds and the NFT enters engagedWithUser. The function sets dataEngagement to 0. Finally, a UserEngaged event is emitted.

checkTimeout

Function that checks whether an NFT has timed out. Anyone can check whether a particular NFT has timed out. Applications and smart contracts can use this function to take appropriate action when an NFT times out.

A timeout occurs after a specified period has elapsed. In ERC4519, deadlines for NFT management are used to strengthen security and access control. A timeout occurs when a certain period has elapsed after the NFT enters a particular state without the required operation or event occurring. For example, an NFT might time out when mutual authentication with a new user has begun but no response is received within the specified period.

  • _tokenId
    • NFT token ID.

The function checks whether the NFT has timed out. If a timeout has occurred, the function returns true. Otherwise, it returns false.

The NFT's timestamp is used to determine whether a timeout has occurred. The timeout period is assumed to be defined in the contract.

If a timeout occurs, the function emits a TimeoutAlarm event. This event notifies external entities that a timeout has occurred.

setTimeout

Function that sets the NFT's timeout. Before the call, the NFT must be in engagedWithOwner, waitingForUser, or engagedWithUser. The NFT timeout is an important feature for strengthening security and access control. For example, if a user with specific permissions does not perform an operation within a certain period, revoking those permissions can help prevent unauthorized access or operations.

  • _tokenId
    • NFT token ID.
  • _timeout
    • Desired timeout value.

The NFT owner can set the timeout period for a particular NFT. Once a timeout is configured, the NFT's state or access rights may change after a specified period elapses following its entry into a particular state. For example, it can be programmed to time out if a specified operation does not occur within a certain period.

updateTimestamp

Function that allows an asset associated with an NFT to update its own timestamp.

The timestamp represents the time when the NFT was last updated. The NFT has a timeout mechanism that triggers an alarm after a specified period. By calling this function, the asset updates its own timestamp. This resets the timeout alarm and allows the asset to remain active.

However, only the asset itself (such as a digital asset) can call this function. Other owners or users are not authorized to execute it. The asset can update its timestamp appropriately to prevent unnecessary timeout alarms.

tokenFromBCA

Function that takes a particular asset address and retrieves the tokenId of the NFT associated with that asset.

  • _addressAsset
    • Ethereum address of a particular asset.

ownerOfFromBCA

Function that takes the Ethereum address of a particular asset and retrieves the address of the owner of its associated NFT.

  • _addressAsset
    • Ethereum address of a particular asset.

userOf

Function that takes a particular token ID (tokenId) and retrieves the Ethereum address of the user associated with that NFT.

  • _tokenId
    • NFT token ID.

userOfFromBCA

Function that takes the Ethereum address _addressAsset of an asset and retrieves the Ethereum address of the user (owner or user) of the associated NFT.

  • _addressAsset
    • Ethereum address of a particular asset.

userBalanceOf

Function that takes a user's Ethereum address and returns the number of NFTs held by that user.

  • _addressUser
    • Ethereum address of a particular user.

userBalanceOfAnOwner

Function that takes the Ethereum addresses of a particular user and owner and returns the number of NFTs that the owner holds for that user.

  • _addressUser
    • Ethereum address of a particular user.
  • _addressOwner
    • Ethereum address of a particular owner.

Additional notes

Authentication

This EIP proposes using smart contracts to verify mutual authentication. Smart contracts provide a reliable mechanism that does not require trust in an intermediary.

Timeout

This EIP proposes including a timestamp attribute to record on Ethereum when the physical asset last checked its association with the token, and a timeout attribute to record the maximum delay allowed before the physical asset must prove that association again. These attributes can prevent malicious owners or users from using the asset indefinitely.

When the asset calls updateTimestamp, the smart contract accesses block.timestamp, which represents the current block's timestamp in seconds since the Unix epoch. The timeout must therefore be specified in seconds.

Based on EIP721

EIP721 is the most widely used NFT standard. This EIP extends EIP721 to maintain backward compatibility.

Backward compatibility

This standard extends EIP721. It is fully compatible with the commonly used optional extensions mentioned in EIP721 (IERC721Metadata and IERC721Enumerable).

Reference implementation

The first version appeared in a paper published in MDPI's Sensors journal as part of the Special Issue Security, Trust and Privacy in New Computing Environments. The paper was written by the same authors as this EIP.

The implementation uses the following code.

I have also collected the code here.

Security considerations

This EIP proposes a system for creating generic NFTs linked to physical assets. It provides a general perspective on improvements to existing EIP721 NFTs, including mechanisms for managing users without affecting ownership. A physical asset should be capable of generating its own Ethereum address in a completely random manner, so that only the asset itself knows the secret from which that address is generated. This helps avoid identity theft and prove that the asset is genuine. To ensure this, the specification recommends restricting the ability to create the token associated with an asset to the asset manufacturer. For IoT devices, the device firmware must not be able to share or change the secret. Rather than storing the secret, the asset should reconstruct it from non-confidential information such as helper data associated with Physical Unclonable Functions (PUFs). Although the proposal describes a secure elliptic-curve key exchange protocol, the token can coexist with other types of key exchange.

Discussion

I see ERC4519 as an attempt to manage real-world objects on a blockchain. It made me think of using NFC tags, as Azuki and other companies have done.

It seems like a difficult standard for an individual developer to implement, so it may not be particularly easy to experiment with. I find the mechanism itself interesting, though. Features such as authentication by the recipient before receiving an asset and the use of time limits could inspire applications to other standards or new ideas based on this proposal.

The technical difficulty is considerable, and I do not fully understand the authentication mechanism myself. Understanding that part is essential to using the standard properly, so anyone interested may want to read the specification in depth.

References

Javier Arcenegui (@Hardblock-IMSE-CNM), Rosario Arjona (@RosarioArjona), Roberto Román roman@imse-cnm.csic.es, Iluminada Baturone (@lumi2018), "ERC-4519: Non-Fungible Tokens Tied to Physical Assets," Ethereum Improvement Proposals, no. 4519, December 2021. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-4519.

Conclusion

This article covered ERC4519, a standard for representing physical assets as NFTs. I hope it was useful.