One of the main things we talked about with wallets is that this is the gateway for a user to consent to using the blockchain to doing certain transactions. This removes that ability. And some folks might say, you can still cancel the transaction, but no, you've got to stop, because if your wallet immediately pops up, you don't have that opportunity to actually go through the application and understand what's going on.
So I mentioned this a little bit, just a couple of slides ago, going beyond connect wallet and using something called sign in with Ethereum. One of my favorite things that have come up out of the Web 3 space is this true single sign on experience, where you can take a wallet, connect it, validate your address, as we looked at before, and then from there do something like connecting to a server as you would normally do for authentication, for actually pulling someone in, creating a user profile for them on your Dapp or application. And the cool thing here is that user profile can travel with them anywhere. They don't need to create a new email or password every single time they go to a new application. They don't need to trust their credentials to a service like sign in with Google or sign in with Facebook. Everything is actually specifically owned by them. That user profile is owned by them through this wallet. And the way that wallet works is that the wallet gives you access through a key value pair, a public address and a private address. The public address is the one we displayed on the page. And then there's a private address that only they have access to that actually allows them access to the blockchain and is what allows them to approve transactions, view their holdings and just access the overall web three space.
So we talked about the wallet side of things, of doing interactions, of like actual user interactions, but how do we interact with the blockchain, RPC and Point Edition? In this case, we may only want to do read only transactions, maybe we want to create our own block Explorer, maybe we want to just display some data in the form of graphs, dashboards, whatever it is. On here, I have this provider. And this provider is something given to us from the ethers package, which is a popular JavaScript package you can use in your front ends. And all you really have to do is just use this method, and enter an RPC endpoint. These RPC endpoints are basically just like a URL, an HTTP endpoint, given to you like the services I mentioned earlier from alchemy and Azure. And this is like a blob of information that you can actually get from the RPC endpoint. So, here, what I'm doing is I'm getting the information about the latest block on the blockchain, and what does that mean? What is the latest block? So, blockchain data is broken up into these blocks, they all have some type of number associated to them, a timestamp, different hashed values, and this is what houses all of the data on this block. So, on this specific block, there's several transactions. There's only one displaying here, this is a timestamp, and just some information about the miner who actually validated this, as well as just additional data like the gas that was used. And this is the information you can use to build out some of those dashboards, some of that information. I'm going to give you a quick demo of something that I built using that blob of data. This is just like a list of like the last 10 blocks on the polygon blockchain, including their block number, their timestamp, and the number of transactions on each of those blocks. You can dive a little bit deeper into that JSON data that's returned from some of these calls, but this is just like a very basic implementation of like what a block explorer might start off as. So cool. But how do we actually fetch data from smart contracts, right? Sure, maybe there's like someone wrote some like developer, smart contract developer wrote a contract for us and that houses some information. How do we access that information? We need a map. So Solidity code, like I mentioned before, gets compiled down to bytecode.
Comments