Fail with error 'ERC1155: insufficient balance for transfer'

Hey Everyone :slight_smile: Testing out a purchase function on my smart contract and running into this ERC1155 error when attempting to purchase an NFT for sale. Contract has been deployed via Remix on Ropsten network with Gas Limit of 300000000 and 1 ETH of Value. Solidity function will be pasted below but I'm thinking this is not a code error?

    function createMarketSale(
        address nftContract,
        uint256 itemId,
        uint256 amount,
        bytes memory data
        ) public payable nonReentrant {
            uint price = idToMarketItem[itemId].price;
            uint tokenId = idToMarketItem[itemId].tokenId;
            bool sold = idToMarketItem[itemId].sold;
            require(msg.value == price, "Please submit the asking price in order to complete the purchase");
            require(sold != true, "This Sale has alredy finnished");
            emit MarketItemSold(

            IERC1155(nftContract).safeTransferFrom(msg.sender, address(this), tokenId, amount, data);
            idToMarketItem[itemId].owner = payable(msg.sender);
            idToMarketItem[itemId].sold = true;

I'm not entirely sure what funds I need in order to complete. The wallet I am making this transaction with has more than enough ETH to make this purchase. Any help would be greatly appreciated :slight_smile:

Transaction Hash: 0xa0680bd6625b8a898e27b76dc20b51950b04ddfc3a5498b8102095292e23c174

It's the contract bug.
Did you implement the test script with javascript?

So how I am executing the function is as follows:

On my Frontend I have a page that shows all NFT's currently for sale. Users can view an NFT and when they click purchase I fire off a purchase function which I'll paste below.

  async function purchase() {
    const tokenDetails = getMarketItem(nftToBuy);
    const itemID = tokenDetails.itemId;
    const tokenPrice = tokenDetails.price;
    const ops = {
      contractAddress: marketAddress,
      functionName: purchaseItemFunction,
      abi: contractABIJson,
      params: {
        nftContract: nftToBuy.token_address,
        itemId: itemID,
        amount: nftToBuy.amount,
        data: [],
      msgValue: tokenPrice,
    await contractProcessor.fetch({
      params: ops,
      onSuccess: () => {
      onError: (error) => {

The getMarketItem essentially just retrieves the nft data that is being stored on Moralis, I then set that itemID as well as get the price.

Market Address is 0x83cDeE9f50c40E74704200993c529B4AB6959354
functionName: "createMarketSale"
ABI which I get from Remix.

nftContract: "0x309f24be235e3be133b617e126a16e171b916331"
itemID: I retrieve from Moralis
amount: is generally 1
data: []

(ContractProcessor is using useWeb3ExecuteFunction())

I have tested another function from the smart contract on my Frontend (Listing NFT for sale) and that works without error.

I hope that gives a bit more insight :slight_smile: