How to create Crowdsale contract for ERC-1155 fungible tokens

I am new to develop ERC-1155 contracts. I have created a contract that holds two types of tokens (fungible and Non-fungible tokens).

Now I want to add a crowdsale functionality in my contract, where users can send ETH to get equivalent fungible tokens. Should I have to add this method in my token contract or should I implement a new Crowdsale contract for this? Which method would be better?

If creating Crowdsale contract is better, then will Crowdsale contract can distinguish itself the type of tokens (e.g: token id) of token contract , or I have to implement some method for it too?

I can only speak from my own experience and perspective. It’s better to keep contracts separate as a good modularization practice for clarity and maintainance.

Do you want to do crowdsale for both ERC20 and ERC721 tokens separately or altogether? Say 10000 tokens + 1 NFT is the basic unit of crowdsale or 10000 tokens or 1 NFT can be purchased separately. Either way, a smart contract can have these functions designed well enough to meet your needs.

I keep both contracts separate. After Deployment, I call the setApprovalForAll for the contract address, so that the contract can spend tokens on the owner’s behalf. But when I send Eth to contract, the transaction fails and an error pop-up saying:

Fail with error ‘ERC1155: insufficient balance for transfer’

The owner address already has tokens, then why I am getting this error?