Let us deploy this contract to Sepolia Testnet using Chrome console.
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract ExecutionExplorer { uint256 public storedValue; address public lastSender; uint256 public callCount; event ValueUpdated(uint256 newValue, address indexed updater); constructor(uint256 initialValue) { storedValue = initialValue; lastSender = msg.sender; callCount = 0; } function updateValue(uint256 newValue) external { storedValue = newValue; lastSender = msg.sender; callCount += 1; emit ValueUpdated(newValue, msg.sender); } function getContractBalance() external view returns (uint256) { return address(this).balance; } receive() external payable {} // Accept ETH } Get the Compiled Bytecode from Remix
If you forget how to get it, please read https://dev.to/rwu_security_researcher/from-source-to-blockchain-how-smart-contracts-go-live-with-remix-and-metamask-25h8
In Chrome Console:
// The Compile Bytecode from remix // const bytecode = "0x608060405234801561000f575f80fd5b506..."; // We need to encode the constructor argument // into 32-byte ABI format. const dummy = 42; let hexString = dummy.toString(16); hexString = hexString.padStart(64, '0'); const constructorArg = hexString; // Combine const deploymentData = bytecode + constructorArg; // Connect to MetaMask await window.ethereum.request({method: 'eth_requestAccounts'}); const accounts = await window.ethereum.request({ method: 'eth_accounts' }); const sender = accounts[0]; // Prepare deployment transaction const txParams = { from: sender, data: deploymentData, gas: '0x2dc6c0' // (optional) 200,000 gas }; // Send transaction const txHash = await window.ethereum.request({ method: 'eth_sendTransaction', params: [txParams], }); console.log("Deployment Transaction Hash:", txHash); MetaMask pops up, asks you to confirm.
This becomes just a pending transaction β floating in the mempool of your network. Validators pick transactions from the mempool to include in the next block after simulating them.
A validator (Proof of Stake) picks up your transaction and simulate the transaction locally using the EVM:
- They run your deploymentData as code in their private EVM simulation.
- If execution succeeds without errors (and gas is sufficient):
- The blockchain engine creates a new contract address.
- The runtime bytecode, i.e. the remix bytecode inside the deploymentData without the argumentData is stored at that address.
- Your storedValue, lastSender, callCount variables are set into storage in the private EVM simulation.
π― If anything fails (out of gas, bad opcode, etc.), the whole transaction reverts β nothing is deployed.
After the validator successfully simulates and commits the block:
- The new contract is officially created on-chain.
- Your storedValue is truly set to 42 β and the world agrees on that.
π How to confirm Raw Smart Contract Storage in Chrome Console after the deployment
In Solidity, each public or internal variable is stored in a sequential "slot" in storage.
Slot 0 β first variable (storedValue)
Slot 1 β second variable (lastSender)
Slot 2 β third variable (callCount)
You want to check slot 0.
https://sepolia.etherscan.io/tx/0x37423eaf6aca4e8843fe5efbe62e79ac0e58dfcd47d09c50db0fdf28a2d759ac
const contractAddress = "0x9B45d1AAF6e91C818F416e1D948A24962A26EF7a"; const slot = "0x0"; // Slot 0 for storedValue const result = await window.ethereum.request({ method: "eth_getStorageAt", params: [contractAddress, slot, "latest"], }); console.log("Stored value (raw hex):", result); console.log("Stored value (parsed int):", parseInt(result, 16)); β This reads directly from Ethereum storage at the contract address!
In this walkthrough, we focused on deploying a contract and verifying its initial storage.
In the next article, we'll dive deeper β reading multiple storage slots, checking the contract's balance, and testing how it can receive ETH dynamically.
Top comments (0)