Is it possible to create a middleman like contract to burn from one ERC1155 contract(Contract A) and mint another ERC1155 contract(Contract B) to the sender if he meets the criteria written within the contract.

When I tried to do it with remix, I can burn the token but could not mint the token from Contract B.

I'm getting the error

The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

I tried creating minter role or even transferring the ownership to the middleman contract, seems to get the same error still in remix.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";

interface ContractA {
    function burn(address, uint256, uint256) external;
    function transferOwnership(address) external;

interface ContractB {
    function mint(address, uint256, uint256) external;
    function transferOwnership(address) external;

contract MiddleMan is Ownable, ERC1155Holder {
    address internal contractAAddress = 0x4D9f44094F448D949fc3EECa230A01d362529424;
    address internal contractBAddress = 0xa2e9669fC58d055D0aF1BaEd20dcF10A9e0DCb97;

    ContractA contractA = ContractA(contractAAddress);
    ContractB contractB = ContractB(contractBAddress);

    constructor() {}

    function burnAndMint(uint256 _tokenId, uint256 _amount) public
        // some logic to determine whether it can be proceed
        contractA.burn(msg.sender, _tokenId, _amount);
        contractB.mint(msg.sender, _tokenId, _amount);

1 Answer 1


As you can see that the ERC1155 contract from openzeppelin wizard creates the mint function with onlyOwner modifier as you can see here

function mint(address account, uint256 id, uint256 amount, bytes memory data)
    _mint(account, id, amount, data);

The issue you are facing is most likely because of this as the contract calling mint function is not the owner of the ERC1155 Contract

Here are a couple of solutions to fix this issue

  1. Remove onlyOwner modifier from ERC1155 code
  2. Make the Middleman contract the owner of that ERC1155 contract

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.