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 14 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
66 changes: 66 additions & 0 deletions EIPS/eip-4883.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
eip: 4883
title: Composable SVG NFT
description: Compose an onchain SVG NFT by combining the SVG body of other onchain SVG NFTs
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: 721
---

## Abstract
Compose an onchain SVG NFT by combining the SVG body of one or more onchain SVG NFTs. Render the SVG body as a string that can be concatenated.

## Motivation
Onchain SVG NFTs allow for NFTs to be entirely onchain by returning artwork as SVG in a data URI of the tokenUri function.
Composability allows onchain SVG NFTs to be crafted. e.g. adding glasses or hats to a profile pic 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.

Every ERC-4883 compliant contract must implement the `ERC4883` and `ERC165` interfaces, with `zIndex` being optional.
```solidity
/// @title ERC-4883 Non-Fungible Token Standard
/// @dev See https://eips.ethereum.org/EIPS/eip-721
interface IERC4883 is IERC165 {
function zIndex() external view returns (int256); // [OPTIONAL]

function width() external view returns (uint256); // [OPTIONAL]
function height() external view returns (uint256); // [OPTIONAL]

function renderTokenById(uint256 id) external view returns (string memory);
}
```

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 composer and composee NFTs or the token holder could hold the composer NFT, and the composer NFT could hold the composee NFT.

## Rationale

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.

### Render

Render must return either an empty string or valid SVG element(s).

### Z Index
SVG draws elements in the order that they appear, meaning the first element is drawn first, with the second element drawn on top of the first. SVG doesn't have the concept of a Z-index for ordering the layers of elements.

This EIP uses a Z Index so that an ERC4883 NFT can determine which order to add each SVG body. In the simplest example, whether the SVG body should be before or after the ERC4883 NFT SVG body.

## Backwards Compatibility

## Test Cases

## Reference Implementation

## Security Considerations
SVG uses a "painters model" of rendering. Which means a child SVG body could be added and completely obscure the existing SVG.

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).