Extending the ERC1155 Contract

Hello OpenZeppelin Community!

I've extended the openzeppelin ERC20 contract with some additional features that reflect the Crowdsale contract from 2.x but with a more recent version of solidity and the open zeppelin library. I was considering deploying a contract per user (gas intensive / expensive) when I came across the ERC1155 token it appears as though I can deploy one contract and allow my users to access a method in the contract to mint their own token (fungible token). So, I would like to extend the ERC1155 contract by adding the same methods I've added to the ERC20 contract but I will need to do it by ID and allow each user to control their token through methods that apply to their own token.

For example, the ERC1155 pausable contract here:

abstract contract ERC1155Pausable is ERC1155, Pausable {
     * @dev See {ERC1155-_beforeTokenTransfer}.
     * Requirements:
     * - the contract must not be paused.
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        require(!paused(), "ERC1155Pausable: token transfer while paused");

I've only been writing smart contract for a couple of weeks, so forgive me if I'm misunderstanding but it appears as though this contract pauses all activity in the entire contract and therefore all tokens under the contract instance.

What I am trying to do is assign admin/control rights to an account as a one-to-one relationship with a token at a given id with various methods in the contract under their control.

1.) Is this an appropriate use case for the 1155 contract?
2.) What would you suggest as an approach to allowing an address to control a token as admin?

Any feedback and direction you can provide is greatly appreciated. I was happy to find this library as a solid starting point for building dApps!


Yes, this sounds like an appropriate use case for ERC1155.

You could use the AccessControl contract and have a role for each token id, and then use the AccessControl functions like _checkRole.

You could also implement this by having a mapping from token id to admin, and then inserting the appropriate requires according to the operation that is attempted.

It's probably not very complicated, so give it a shot!

1 Like

Thanks @frangio! I ended up coming to the same conclusion. It was something like this:

contract Things {

  struct ThingToOwn {
    // some params
    address owner;

  mapping(uint256 => ThingToOwn) ownedThings;

  function _getOwner(uint256 id) public view virtual returns (address) {
      return tokens[id].owner;

   modifier onlyOwner(uint256 id) {
      require(_getOwner(id) == msg.sender, "You do not own this thing.");

   function _checkSomething(uint256 id) public view onlyOwner(id) returns(bool) {
      // Returns something

Do you see any issues with this approach?


Yeah, that looks good to me!

1 Like