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 explains ERC-4883, a proposal for creating new SVG NFTs by combining rendered SVG content from existing NFTs.
The following specification is the basis for this explanation.
ERC-4883 was in Draft status as of October 23, 2023, according to the original article.
For other ERC explanations, see the following page.
Overview
SVG stands for Scalable Vector Graphics. The composition process described here combines SVG data associated with two different NFT token IDs to generate new SVG content.
- Retrieve the SVG data for the first NFT.
- Retrieve the SVG data for the second NFT.
- Combine the SVG content through string concatenation.
- This produces a new representation of the combined content.
- Use the resulting artwork when creating a new NFT.
This process allows different NFTs to contribute artwork to a newly composed NFT.
Motivation
On-chain SVG NFTs can return SVG artwork directly as part of the token metadata representation, making fully on-chain NFTs possible.
Composability also allows on-chain SVG NFTs to be combined. For example, a profile-picture NFT could be combined with NFTs representing glasses or a hat, or an aquarium NFT could be combined with an NFT representing a fish.
Specification
/// @title EIP-4883 Non-Fungible Token Standard
interface IERC4883 is IERC165 {
function renderTokenById(uint256 id) external view returns (string memory);
}The renderTokenById function accepts a token ID and generates or retrieves the SVG content associated with that ID.
It returns either an empty string or valid SVG content.
Additional Considerations
SVG elements can be composed through string concatenation.
Composition Order
SVG uses a painter's model. Elements painted later appear on top of those painted earlier.
For the composition mechanism described in the proposal, the order of SVG elements determines their stacking order, rather than a separate z-index setting.
The order of elements in an SVG document determines which elements are painted first.
Alternatives to Concatenation
SVG can reference elements in another SVG document using the use element.
<svg width="100" height="100">
<use href="http://example.com/path/to/another.svg#elementID"/>
</svg>This example references an element with ID elementID in another SVG file, another.svg.
An approach based on external references would require an agreed URI format and adoption throughout the relevant ecosystem.
String concatenation offers a simpler mechanism for combining content without introducing such a reference format.
string memory svg1 = '<svg width="100" height="100"><circle cx="50" cy="50" r="40" /></svg>';
string memory svg2 = '<svg width="100" height="100"><rect x="10" y="10" width="30" height="30" /></svg>';
string memory combinedSVG = string(abi.encodePacked(svg1, svg2));In the original example, two SVG strings, svg1 and svg2, are concatenated into combinedSVG.
This example illustrates string concatenation only. Concatenating two complete SVG documents does not automatically produce a single valid SVG document; the elements must be composed within an appropriate SVG structure.
SVG Dimensions
The proposal does not prescribe dimensions for rendered SVG content. NFT creators can choose dimensions appropriate for their artwork.
Rendering Function Name
The name renderTokenById was first used by the Loogies project and was adopted to preserve compatibility with already deployed NFTs.
Backward Compatibility
The proposal identifies no particular backward-compatibility issues.
Security
Because SVG uses a painter's model, elements added later can completely obscure previously rendered content.
SVG is written in XML and can also contain malicious content.
Examples include malicious scripts or links.
Such content does not itself execute within the smart contract, but it can affect applications and websites that render the SVG.
Citation
Andrew B Coathup (@abcoathup), Alex (@AlexPartyPanda), Damian Martinelli (@damianmarti), blockdev (@0xbok), Austin Griffith (@austintgriffith), "ERC-4883: Composable SVG NFT [DRAFT]," Ethereum Improvement Proposals, no. 4883, March 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-4883.
Conclusion
ERC-4883 proposes a common rendering interface for composing SVG NFT artwork from token-specific SVG content.

