• Stars
    star
    169
  • Rank 223,478 (Top 5 %)
  • Language
    Solidity
  • License
    BSD 3-Clause "New...
  • Created about 6 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ERC721x is an extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible.

ERC721x — A Smarter Token for the Future of Crypto Collectibles

ERC721x is an extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible.

Quick Links:


The ERC721x Interface:

contract ERC721X {
  function implementsERC721X() public pure returns (bool);
  function ownerOf(uint256 _tokenId) public view returns (address _owner);
  function balanceOf(address owner) public view returns (uint256);
  function balanceOf(address owner, uint256 tokenId) public view returns (uint256);
  function tokensOwned(address owner) public view returns (uint256[], uint256[]);

  function transfer(address to, uint256 tokenId, uint256 quantity) public;
  function transferFrom(address from, address to, uint256 tokenId, uint256 quantity) public;

  // Fungible Safe Transfer From
  function safeTransferFrom(address from, address to, uint256 tokenId, uint256 _amount) public;
  function safeTransferFrom(address from, address to, uint256 tokenId, uint256 _amount, bytes data) public;

  // Batch Safe Transfer From
  function safeBatchTransferFrom(address _from, address _to, uint256[] tokenIds, uint256[] _amounts, bytes _data) public;

  function name() external view returns (string);
  function symbol() external view returns (string);

  // Required Events
  event TransferWithQuantity(address indexed from, address indexed to, uint256 indexed tokenId, uint256 quantity);
  event TransferToken(address indexed from, address indexed to, uint256 indexed tokenId, uint256 quantity);
  event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
  event BatchTransfer(address indexed from, address indexed to, uint256[] tokenTypes, uint256[] amounts);
}

Quick Start:

yarn add erc721x
npm install erc721x

To run the tests in this repo, simply clone it and run truffle test


Background

Here at Loom Network, we’ve been working on Zombie Battleground, a 100% on-chain collectible card game that’s targeted at the mainstream audience. Recently, we finished a Kickstarter campaign, and as part of the early backer packages, we will be delivering almost 2 million cards to these backers. We started with a normal ERC721 smart contract, but quickly realized that we needed some adjustments to make it mainstream-friendly. Here are the criteria we’re working with:

Transfers should cost very little gas, even if the player is transferring a large quantity of items. For example, someone might want to transfer a few hundred very cheap cards that are worth little individually, but quite valuable in bulk. One contract should contain multiple “classes” of items. For example, under the broad category of Zombie Battleground cards, we want to have 100 different kinds of cards, each having many copies. Compatibility with marketplaces, wallets, and existing infrastructure (e.g. Etherscan). Wallet and marketplace makers provide a valuable service to the community, and it makes sense to leverage their existing work.

The Current Landscape

ERC # Cheap Bulk Transfers Multiple Classes of NFT/FT Works as a Collectible Wallet/Marketplace Compatibility
ERC721 NO NO YES YES
ERC20 YES NO NO YES
ERC1155 YES YES YES NO
ERC1178 YES YES NO NO

We are not the first ones to need something like this, and there have been a few brilliant proposals on github. But every single instance sacrifices compatibility with existing wallets and marketplaces by creating an entirely new specification. While we wholeheartedly support new breakthroughs, it seemed to us that the more pragmatic path — the one we can use NOW instead of months later — would be to extend ERC721 somehow, rather than abandoning it altogether.

Our Approach: Extending ERC721 with ERC1178 Out of all the existing solutions to this problem, the one that best suited our needs was ERC1178 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1178.md).

It is extremely easy to read and understand because of its similarity to ERC20 — easy enough that any curious user can audit the smart contract and see what the developer put in it. (If they need a little help, doing a lesson on CryptoZombies.io should be enough 😉) It has very little bloat — just the bare minimum to implement the necessary features. The fewer things added, the better the chances are that it’s secure, because it deviates less from battle-tested code. It’s really useful for things beyond just games — for example, creating a token that can represent preferred, common, or restricted shares of a company.

image copied on 2018-09-07 at 19 14 21 pm

Using ERC1178 as the base, we added a very thin optional layer of features to support crypto-collectibles, then wrapped everything with an ERC721 compatibility layer.

Real World Usage

ERC721x is immediately usable with any ERC721-compatible wallet, marketplace, or service. For example, you can browse for a card in Trust Wallet and easily transfer it to your friend. That person can check the status of the transfer on Etherscan, and then resell it by sending it to OpenSea or Rarebits.

Then, on a service that supports the enhanced features, such as cheap batch transfers, you get all the improved benefits, without the end user needing to know about any of the details. For example, on the Loom Trading Post, you can send hundreds of cards for the price of sending one, and you can enjoy transactions that are completely free by storing the cards on PlasmaChain 😎

Conclusion

Beyond the technical bits that make up blockchains, the spirit of blockchain tech is equally (if not more) important. Services should be interoperable, open, and compatible. It doesn’t matter if you add a million features when the end user has no wallet that can open them and no service like Etherscan that can view them.

At the same time, any improvements made to a technology should aim to be as seamless as possible. We can see a wonderful example of this with our USB devices. There’s absolutely no need for us to stop and think, “Is this USB 1.0, 2.0, or 3.0?” We are spared from this mental overhead because, even if not all the new features are supported, we will still be able to use the device the exact same way.

It’s these two principles that led us to create the new ERC721x, specifically for crypto-collectibles — and it’s completely open source.

More Repositories

1

plasma-cash

Plasma Cash Contract & Client. ERC721, ERC20, and ETH compatible
JavaScript
271
star
2

zombie-char-component

Zombie character preview
Vue
242
star
3

loom-js

JS library for building browser apps & NodeJS services that interact with Loom DAppChains
TypeScript
207
star
4

go-loom

Go package for building plugins and Go Smart Contracts for Loom DAppChains
Go
190
star
5

loomchain

Loom DAppChain Engine
Go
166
star
6

solidityx-js

SolidtyX is an opinionated version of Solidity.
JavaScript
124
star
7

unity-sdk

Loom DAppChain SDK for Unity3d
C#
121
star
8

truffle-dappchain-example

Example of Truffle configured with Loom Truffle Provider
JavaScript
92
star
9

solidity-social-example

Super simple social network interaction, where users can post and comment on posts
JavaScript
67
star
10

plasma-paper

Plasma Cash: Towards Improved Plasma Constructions.
TeX
50
star
11

EthDeploy

Ethdeploy is a platform for spinning up cloud based blockchains. Unrelated to dAppChains
JavaScript
43
star
12

plasma-cli

All In One stateful Plasma-Cash client, browser compatible
TypeScript
42
star
13

Etherboy

Etherboy in Blockchain world. A sample blockchain game that runs on a DAppchain.
C#
36
star
14

loom-sdk-documentation

Loom SDK Documentation Website
Shell
36
star
15

ethdeploy-client

EthDeploy - Client for deploying apps on the Ethdeploy private blockchain hosting
Go
31
star
16

transfer-gateway-example

Loom SDK Transfer Gateway ERC721 Example
JavaScript
31
star
17

loom-truffle-provider

Adapter that allows Truffle Suite to communicate with Loom DappChain
TypeScript
29
star
18

dashboard

Loom Basechain Gateway, wallet and DPoS UI / dashboard
Vue
28
star
19

tiles-chain

JavaScript
19
star
20

vue-block-explorer

Vue component for inspecting Loom DAppChains
TypeScript
18
star
21

blockscout

Elixir
18
star
22

soliditycookbook.com

CSS
18
star
23

weave-blueprint

Example Go Smart Contract project for Loom Blockchain
Go
18
star
24

loom-examples

Loom Examples
JavaScript
17
star
25

zb_game_mode

ZombiebBattleGround Game Modes in Solidity. For Extending the gameplay with custom game modes
Solidity
16
star
26

cocos-sdk

Cocos2d clientside integration
JavaScript
15
star
27

token-gateway-example

JavaScript
15
star
28

ethcontract

Ethutils for creating Ethereum Contracts in Golang. Related set of helpers
Go
15
star
29

phaser-sdk-demo

JavaScript
15
star
30

spores

Loom Network's all-in-one package to connect your client to your DApp on EthDeploy
JavaScript
14
star
31

etherboy-core

Etherboy Game Smart Contract for Loom DAppChain
Go
13
star
32

loom-js-samples

Sample code demonstrating usage of https://github.com/loomnetwork/loom-js
JavaScript
10
star
33

mamamerkle

Sparse Merkle Trees implementation
Go
10
star
34

unity-evm-blackjack

Unity Blackjack Demo of Loom SDK with EVM contracts
C#
8
star
35

solidityx.org

Python
7
star
36

unity3d-identity

Unity3d package for managing identities on Loom DAppChains
C#
5
star
37

Node.js-prototype

Node.js prototype
JavaScript
5
star
38

solidity-transfer-gateway

Transfer Gateway Solidity contracts for Ethereum & TRON
Go
4
star
39

loom-provider-json-rpc-proxy

Small proxy that proxies HTTP JSON RPC calls to Loomchain/EVM using LoomProvider under the hood
TypeScript
4
star
40

loom-identity-js

JS library for managing identities on Loom DAppChains.
TypeScript
4
star
41

loom-playbooks

Automation resources for Developers
4
star
42

loom-token

This repo contains smart contracts for the new LOOM ERC20 token, token swap, and staking system.
TypeScript
4
star
43

gamechain

Go
3
star
44

zombie-battleground-api

Public Api Docs for getting Zombie Battleground data, such as cards and matches
3
star
45

unity-tiles-chain-evm

C#
3
star
46

loom-cli

DPoS / Transfer Gateway CLI
TypeScript
3
star
47

homebrew-client

homebrew for osx for loom client
Ruby
3
star
48

loom-unity-project-template

C#
3
star
49

TimeLock

JavaScript
2
star
50

plasma-indexer

Syncs Go Smart Contract events from a Loom DAppChain to a MySQL DB
Go
2
star
51

go-transfer-gateway

Transfer Gateway Go contracts & Oracles
Go
2
star
52

dc-translations

DelegateCall i18N
1
star
53

truffle-loom-builder

Experimental Truffle built tool for easy integration with Loom
JavaScript
1
star
54

unity-sdk-docs

CSS
1
star
55

e2e

Test utility for Loom SDK
Go
1
star
56

zkloom-examples

Examples of deploying and interacting with contracts on zkLoom
TypeScript
1
star