npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

multi-token-standard

v2.2.2

Published

ERC1155 Multi-Token Standard implementation for Ethereum

Downloads

51

Readme

IMPORTANT!

Thank you, -the Horizon team




Multi-Token Standard (ERC1155) implementation

An implementation example of a standard Multi-Token (MT) contract, which contains multiple classes of fungible tokens referenced by IDs. Standard interface discussion at ERC-1155.

Description

The contracts in this repository follow a standard implementation of an (ERC-1155 contract. This standard provides basic functionality to track and transfer multiple tokens and the interface provide an API other contracts and off-chain third parties can use.

ERC-1155 contracts keep track of many token balances, which can lead to significant efficiency gains when batch transferring multiple token classes simultaneously. This is particularly useful for fungible tokens that are likely to be transfered together, such as gaming items (cards, weapons, parts of objects, minerals, etc.). The possible efficiency gains are more significant if the amount of tokens each address can own is capped, as shown in this implementation examples.

This repository contains two main implementations of the ERC-1155 token standards: ERC1155 and ERC155PackedBalance. The latter implementation packs multiple balances within a single uint256 using bitwise operations. This brings the cost of transferring 100 different token classes to 467,173 gas, an average of 4,671 gas per token type transfer. Still using MT, but without balance packing, transferring 100 different token types costs 2,763,399 gas, an average of 27,633 gas per token transfer. The latter is already an improvement over multiple fungible tokens that are stored on different contracts, since cross-contract calls have a base cost of 700 gas. This is ignoring the cost of initial approvals that would need to be set for each user and existing ERC-20 tokens.

Specification

A detailed specification document can be found at SPECIFICATIONS.md.

Security

multi-token-standard has been audited by two independant parties and all issues discovered were addressed.

** Agustín was hired as a full-time employee at Horizon after the audit was completed. Agustín did not take part in the writing of multi-token-standard contracts.

Usage

Dependencies

Install the multi-token-standard npm package npm install multi-token-standard or yarn add multi-token-standard

Dev / running the tests

  1. yarn install
  2. yarn build
  3. yarn ganache
  4. in another terminal run, yarn test - executes test suite

Importing into your Contracts

To write your custom contracts, import ours and extend them through inheritance.

pragma solidity ^0.7.4;

import 'multi-token-standard/contracts/tokens/ERC1155/ERC1155.sol';

contract MyERC1155Token is ERC1155 {
  ...
}