1

I am working on a project where I have to retrieve source codes of deployed Ethereum smart contracts from Etherescan.io, and I am looking for very simple smart contracts where I can perform some processing.

Where can I find a simple smart contract deployed on the Ethereum blockchain that is equivalent to the following Solidity code ( this is just a very simple code with constraints shown for example):

 contract Arithmetic {
        uint256 public result;
    
        // Function to add two numbers and store the result
        function add(uint256 a, uint256 b) public {
            result = a + b;
        }
    
        // Function to subtract two numbers and store the result
        function subtract(uint256 a, uint256 b) public {
            result = a - b;
        }
    }
1
  • You can deploy it yourself and then verify it to access the desired smart contract code.
    – Mehran Ra
    Commented Sep 5, 2023 at 19:38

2 Answers 2

0

To help build your project, it seems like you would need to test interacting with multiple different contracts, so instead of finding contracts on mainnet that fit your criteria, I recommend you use a testnet.

This way you can deploy your own contracts exactly how you'd like them to be. Testnets act and feel exactly like mainnet, they even come with their own block explorers, the only difference is that testnet's use "play" money as opposed to real funds.

To get "play" money there are various faucets set up by members in the community, a popular one that I like to use is Alchemy's. All you need to do is create a free Alchemy account and they give you free Sepolia ETH daily. (Here is the Mumbai Alchemy faucet)

Here is a link to the Ethereum Sepolia testnet's block explorer, and here is a link to Polygon's Mumbai testnet block explorer.

A tool you can use to quickly deploy these "test" contracts is Remix. Before you deploy your contract, make sure you set the enviroment to Injected Provider. This will connect to whatever network your metamask is on.

enter image description here

In the picture above, you can see that I am connecting to the Ethereum Goerli testnet, however, it is no longer recommended to use since it will be depreciated.

For the reasoning behind why testnets are periodically shutdown and changed:

Ethereum has many testnets for users and developers to test things on before interacting with mainnet. These are effectively copies of the Ethereum mainnet on which Ether and other tokens have no value. They allow application, tooling, infrastructure and protocol developers to deploy changes to their products (or the protocol itself!) in a low stakes environment, before moving to mainnet.

That said, because testnets are full-featured blockchains, their history and state grow over time. This eventually makes them harder to run nodes on and to maintain. For this reason, some testnets are periodically sunsetted. This happened last year with the Pyrmont Beacon Chain testnet and more recently with the Kovan execution layer testnet.

0

As Rohan said, it will be good if you work with testnet instead of mainnet. you can call call and send functions without any problem. but if you don't want to deploy something in the network you can find contracts in the list of contracts in scanners. for example in Sepolia (Ethereum testnet network) you can find simple contracts at https://sepolia.etherscan.io/contractsVerified. I just found this one(https://sepolia.etherscan.io/address/0x2331fb827792879D21e11f7e13bA0d57391393D5#code) with just some search.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.