I am creating an ERC-1155 smart contract whereby I create a number of different tokens and also want to be able to create new tokens on the fly. The code is something like:

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract MyVideos is ERC1155 {
    uint256 public constant Video1 = 0;
    uint256 public constant Video2 = 1;
    uint256 public constant Video3 = 2;

    constructor() public ERC1155("https://video/api/item/{id}.json") {
        _mint(msg.sender, Video1, 100, "IPFS hash");
        _mint(msg.sender, Video2, 1000, "IPFS hash");
        _mint(msg.sender, Video3, 1, "IPFS hash");

function addNewVideo(uint VideoN, uint ntokens, bytes memory IPFS_hash) public {
    _mint(msg.sender, VideoN, ntokens, IPFS_hash);

My question is twofold:

  1. Are ERC-1155 created tokens always atomic (i.e. not divisible into fractional parts)?
  2. If not, how can I distinguish between the two?


  • all the tokens are integers, and by the way Ethereum doesn't provide floating point operations. So, you do it by mentally placing the comma where you want. Or specify it in the decimals field and format according to the value in this field – Nulik Feb 1 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.