Who will be the owner?

I’m a bit confusing the concept of owner for NFT.

I’m creating NFT platform which allows user to create their NFTs.
The smart contract is based on ERC1155 like this.

contract MyNFT is ERC1155, Ownable {
  mapping(uint256 => address) private minters;

  constructor() ERC1155(""){}

  function mint(address account, uint256 id, uint256 amount) public {
    require(minters[id] == address(0) || minters[id] == msg.sender);
    if(minters[id] == address(0)) {
      minters[id] = msg.sender;
    }
    _mint(account,id,amount,"");
  }

I will deploy the contract. So the owner is me. Let’s say I am contract creator.
Users will call mint when they create their NFTs. Let’s say the user is minter.

In this timing, the minter is owner?
I can see the user owns the NFT on OpenSea and Rarible.

Buyer can buy the NFT on OpenSea. Once buyer buy the NFT, who will be the owner?

Contract creator, minter or buyer?

The smart contract has a few functions with onlyOwner
Is the function callable only by contract creator always? Or it can be called by minter and buyer sometimes?

Shinya

You might be mixing up the terms “contract owner” and “token (nft) owner”. If this is your full contract code, you are not setting the contract owner anywhere so your contract does not have an owner. And a token owner is the person who owns an nft (or more, can be of the same id as well, since you are using erc1155). So for the example you have provided, using the mint function your wrote, the address which was put into your mint function will be the owner, and when they sell the nft the buyer will become the new owner

1 Like

Thanks for your reply! Let me confirm one thing.

The smart contract has this function.

  function withdraw() onlyOwner public payable {
    payable(owner()).transfer(address(this).balance);
  }

It’s onlyOwner. So only contract owner (= me) can call the function. Right?

Well I am not sure how ownable works exactly, but I believe you have to set the owner somewhere, for example in the constructor of your contract maybe

1 Like

By default the contract creator/deployer is set as the owner.

2 Likes