Interact With Your Smart Contract On Ropsten

Noah Hein
InstructorNoah Hein

Share this video with your friends

Send Tweet
Published 6 months ago
Updated 5 months ago

We will start off with calling the increment and decrement functions on your Number smart contract that's deployed on the Ropsten testnet. After we've interacted with it successfully, we'll go to a website known as a "block explorer" that allows us to easily see our smart contract, and the individual transactions that we sent.

Noah Hein: [0:00] We can actually see here the same calls that we were making. Instead of cast call on this contract address, we will use this Deployed to address instead. Here we can delete all of this and run that. You can see the same deal here. We need to provide the --rpc-url of this guy right here and pass that in. Cool. We can see that we are getting that base of 10 again. [0:40] Again, if instead of cast call, if we do cast send, then we have our --rpc-url here, but we're also going to want to put in our private key again. Instead of getNum(), let's do increment like we did before and then our private key.

[1:07] We will go grab our private key from MetaMask, or we just have it up here, so we can copy that and paste that in, and we can run that. Again, this will probably take a little bit longer than before because we're sending that up to the network and waiting for it to confirm our transaction. Fantastic.

[1:30] You can see, hey, cool, look that it deployed this and here you can see that our blockNumber is much, much higher than on our local test network, but it does the blockHash and it mines the transaction, everything. That's cool.

[1:43] Let's do one more so that we can make sure that all of this is working how we expect it to. We did our increment successfully. Let's just change this back to decrement and then we'll add the parameter as well. Let's change this to decrement. Then uint256 and then we will decrement it by 3. Awesome, cool.

[2:11] Now, we're going to use what's called a block explorer to go take a look at all of these. I'll just grab this transaction hash from this most recent transaction. We'll go over here and etherscan is by far the most popular one.

[2:24] We'll say and we want to be not on Ethereum Mainnet. We want to go to the Ropsten TestNet. Block explorers let you look at everything, all of the activity that's happening on any particular blockchain on a particular network. You can see that it shows you here, here are some of the most recent blocks, and the most recent transactions where you can look it up.

[2:48] If I paste in my transaction hash here. You can see, hey, cool, does pop up. You can see that it came from us. Again, if we take a look here at MetaMask, we can see that we have this E9FC and look at that ends in e9fc as well.

[3:08] You can verify that, "Hey, this is indeed that we have been interacting with this particular smart contract." We know that it's us. It's from us, but what is it to? It's to this particular contract. Here, you can see this actual thing. It looks like, cool, that we uploaded this four minutes ago. This was our contract creation whenever we deployed it. Then, we incremented it, and we decremented it.

[3:32] Here, you can take a look at the contract. You can see this is the published ByteCode that's up and living on the chain. You can see that the methods it's getting based on the input data. Very cool. This is an overview of what it looks like to deploy a smart contract and interact with things on chain.

[3:58] You can see this is the exact same scenario that you would have on Mainnet for example. It was done. It wouldn't be quite so easy to get all the money, but you can see on any of these transaction hashes that hey, cool, if we increment that, that we did that.

[4:15] You could see how much our transaction fee was. We used .00007 or 3 Gwey was the GAS price at the time. It gets you some block along with how many block confirmations, which is, you can see right here, the number of blocks that has been mined since, along with the transaction hash. That tells you, "Hey, look, this was on Ropsten. No actual money was changing hands here."

[4:45] Awesome. From here, you have successfully deployed a smart contract and incremented it and decremented it. You may also notice here that you don't see that read operation deployed on here because that didn't change any state.

[5:00] All of the people that are running Ethereum nodes on the Ropsten didn't need to record that you read it. They took the request, and they gave you the information, but it doesn't need to stay there because a lot of bloat on the chains. They already have a lot of information that they have to log.

[5:16] They don't write any of the read operations that you do. That's only whenever you're changing state that you'll see these transaction hashes come up. You have now successfully deployed a contract to a test network and interacted with it. Congratulations.