how to differentiate between buyer and seller in smart contract? - solidity

I'm creating a new token in BSC using Solidity, and I want to identified when someone is buying, so I can make the contract do something specific
How can I identified when someone is BUYING? thanks

Related

Create own NFTs only can be sold on own marketplace

I'm facing a challenge with my NFT marketplace project. How I can create NFTs with the rule that those NFTs can only be sold on our own platform but others. Technically is possible, however, I need some help here.
Thank you.
Yes this possible For that you have to maintain a mapping or some sort of logic on smart contract level to keep track of whether to and from address belong to your ERC 721 contract or not.
transferFrom(from, to, tokenId)
Like when someone mints NFT on your smart contract you can save the address of the minter. And at the time of selling of you can have a condition at the start of transferFrom like.
require(to == exists[to], "Warning, You are selling outside of the contract")
mapping can be something of like this. mapping(address => address) exists;

Solidity openzeppelin public mint ERC721 token function, is any arguments really neccessary? [duplicate]

I'm trying to build an NFT marketplace. So I wanted to create an ERC1155 smart contract to allow content creators to put their art into the smart contract. I'm using OpenZeppelins wizard as a base but I found some weirdness on the mint function. It's allowing only the owner of the contract to mint:
It's made me suspicious about my actions. Should I disallow users to mint to create items on my contract?
I can't speak for the wizard authors why they decided on some specific approach.
However it's an established practice that when an artist or any other authorized person publishes an NFT collection, they don't want other people to contribute to this specific collection and change the overall meaning of it. For example, if you have a collection of NFTs representing pictures of dogs, you might not want other people to create NFTs representing pictures of cats in the same collection. Or any other unrelated pictures for that matter.
If you want to allow minting tokens in the collection by anyone, you can remove the onlyOwner modifier from the mint functions As well as the Ownable extension of MyTokens contract and its import, assuming you don't use the Ownable features elsewhere in your contract.

How do I modify my smart contract code so I'm the only one who can sell tokens? Everyone else send their tokens to me to exchange for either ETH, etc

So I have a token that has about 103 users. What I need to do is restrict the ability to sell those tokens to just myself the developer, so the other users can redeem their tokens for ETH or MATIC by sending to me. The alternative would be to just write a new smart contract, including this function and moving all users to the new platform. How would I write that new contract?
The first, you can't change code of deployed contract in Ethereum.
The second, look at ERC-20 and ERC-721 (NFT) standarts, its already have functionality you need.

adding credit card option function in smart contract for minting NFT

I'm looking into adding a function to allow payments by cc during mint. Has anyone done this successfully and is willing to share how you went about it? Thanks!
The only way for doing this is after user paying you need to make the minting from your server and transfer it to the user or mint it directly to the user wallet

ERC20 solidity contract with pre-existing balances - possible?

There's a part of me that thinks that if this is possible it kind of goes against the whole idea of a secure blockchain, but I just want to check and make sure.
Is it possible to create and deploy a smartcontract which creates a number of addresses, each with a pre-defined, initial balance of tokens? And if so, can these addresses then be made 'accessible' as a wallet for someone to use?
So, suppose I create a coin ABC, and it has a supply of 1.000.000.000 and I then create 10 addresses, each with, say, 50.000 ABC in them, with the remaining ABC tokens still in the 'genesis'/initial address - is that possible? Alternatively, can this kind of "pre-walleting" be done with a second contract after the token creation? And suppose now that I have said 50K ABC addresses, can they then be 'given' to users/made accessible?
Of course one can always create the coin and then do a bunch of transactions to do the above 'the old fashioned way' but I am curious if such a setup can be obtained in a faster/shortcut way.
This can not be achieved using the standard ERC20 token definition, what you want to do is very similar to an "Airdrop", in that case that can be achieved following these steps:
Create and deploy the ERC20 token.
Create a smart contract to handle the token distribution, this contract will contain the logic to handle or the distribution process.
Call the distribution contract and pass the array of addresses that
will receive the token.
The problem that i see with your proposed approach is that in order to give the addresses to the users you must provide them the private key, which means that they will not be in total control of their funds since you already know those keys, so i don't think this is a good decision.