Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-4883 Composable SVG NFT #4888

Merged
merged 19 commits into from
Aug 6, 2022
Merged
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions EIPS/eip-4883.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
eip: 4883
title: Composable SVG NFT
description: Compose an SVG NFT by concatenating the SVG with the rendered SVG of another NFT.
author: Andrew B Coathup (@abcoathup), Alex (@AlexPartyPanda), Damian Martinelli (@damianmarti), blockdev (@0xbok), Austin Griffith (@austintgriffith)
discussions-to: https://ethereum-magicians.org/t/eip-4883-composable-svg-nft/8765
status: Draft
type: Standards Track
category: ERC
created: 2022-03-08
requires: 165, 721
---

## Abstract

Compose an SVG (Scalable Vector Graphics) NFT by concatenating the SVG with the SVG of another NFT rendered as a string for a specific token ID.
abcoathup marked this conversation as resolved.
Show resolved Hide resolved

## Motivation

On-chain SVG NFTs allow for NFTs to be entirely on-chain by returning artwork as SVG in a data URI of the `tokenUri` function. Composability allows on-chain SVG NFTs to be crafted. e.g. adding glasses & hat NFTs to a profile pic NFT or a fish NFT to a fish tank NFT.

## Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

```solidity
/// @title EIP-4883 Non-Fungible Token Standard
/// @dev See https://eips.ethereum.org/EIPS/eip-4883
abcoathup marked this conversation as resolved.
Show resolved Hide resolved
interface IERC4883 is IERC165 {
function renderTokenById(uint256 id) external view returns (string memory);
}
```

`renderTokenById` must return the SVG body for the specified token `id` and must either be an empty string or valid SVG element(s).

If the caller of the render function composes an SVG NFT they must have rights to use the SVG body in a composable SVG. The token holder could optionally hold both the SVG and rendered SVG NFTs or the token holder could hold the SVG NFT, and the SVG NFT could hold the rendered SVG NFT.

## Rationale

SVG elements can be string concatenated to compose an SVG.
abcoathup marked this conversation as resolved.
Show resolved Hide resolved

### Ordering of concatenation

SVG uses a "painters model" of rendering.

**Scalable Vector Graphics (SVG) 1.1 (Second Edition)**, section: **3.3 Rendering Order**
>Elements in an SVG document fragment have an implicit drawing order, with the first elements in the SVG document fragment getting "painted" first. Subsequent elements are painted on top of previously painted elements.

abcoathup marked this conversation as resolved.
Show resolved Hide resolved
The ordering of the SVG concatenation determines the drawing order rather than any concept of a z-index.

This EIP only specifies the rendering of the rendered SVG NFT and does not require any specific ordering when composing. This allows the SVG NFT to use a rendered SVG NFT as a foreground or a background as required.

### Alternatives to concatenation

SVG specifies a `link` tag. Linking could allow for complex SVGs to be composed but would require creating a URI format and then getting ecosystem adoption. As string concatenation of SVG's is already supported, the simpler approach of concatenation is used.
abcoathup marked this conversation as resolved.
Show resolved Hide resolved

### Sizing

This EIP doesn't specify any requirements on the size of the rendered SVG. Any scaling based on sizing can be performed by the SVG NFT as required.

### Render function name

The render function is named `renderTokenById` as this function name was first used by Loogies and allows existing deployed NFTs to be compatible with this EIP.

## Backwards Compatibility
This EIP has no backwards compatibility concerns


## Security Considerations

- SVG uses a "painters model" of rendering. A rendered SVG body could be added and completely obscure the existing SVG NFT artwork.
- SVG is XML and can contain malicious content, and while it won't impact the contract, it could impact the use of the SVG.

## Copyright
Copyright and related rights waived via [CC0](../LICENSE.md).