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);
}
}