Private smart contract code?


I've seen smart contracts where in the "Contract" tab, the code is not available on various block explorers, like this:

Thus hiding and protecting the source code. I've looked around but don't know how to do that myself, how can I make my code hidden like that?


Unless you verify your code via Etherscan, it won't display the contract source code. Hardhat-etherscan is another way of verifying your code. Remix offers a contract verification plugin as well.

Technically the data is still able to be read, it's just not remotely as simple as Etherscan makes it for verified contracts. If the contract has been deployed and is callable, the data is publicly visible as bytecode.

Generally verifying the code is to be regarded as a good thing.

But if I don't verify the contract, I'm not even able to call Read and Write functions. Here you can, while having the code hidden.

You can think of the Read and Write functions as friendly extra tools that Etherscan makes available when it knows how to plug in to the contract code. A contract that has not been verified via Etherscan is still deployed to the actual blockchain, which is totally a separate thing. Etherscan is a great block explorer, but it's just a block explorer -- a very useful frontend app that plugs in to the blockchain. There are others, like ethplorer, etherchain, etc.

Hope that helps clarify!