Deploy & run smart contracts - Remix Tutorial 16

EatTheBlocksAbout 5 min readMay 27, 2025Watch original
THE SUMMARYAI-generated

Smart Contract Deployment and Interaction with Remix IDE

Key Concepts:

  • Smart contract deployment
  • Smart contract interaction
  • Remix IDE
  • ABI (Application Binary Interface)
  • Non-view functions
  • Payable functions
  • View/Pure functions
  • Low-level interaction
  • Fallback function
  • Receive function
  • Pinning contracts
  • MetaMask integration

Compiling and Deploying Smart Contracts

  1. Compilation: The video begins by demonstrating the compilation of a smart contract within the Remix IDE. The user navigates to the "Compile" tab and clicks the "Compile" button.
  2. Deployment Environment: The video highlights the selection of the deployment environment. The user chooses the "local development blockchain of Remix" for demonstration purposes but notes that public networks can also be selected.
  3. Deployment Process: The user clicks the "Deploy" button in the "Deploy" tab to deploy the compiled smart contract to the chosen environment.
  4. Deployed Contract Interface: After successful deployment, the deployed contract appears in the "Deployed Contracts" section, providing an interface for interaction.

Interacting with Smart Contracts

  1. Function Types: The video explains the different types of functions and their corresponding button colors in the Remix IDE:
    • Orange buttons: Represent non-view functions that modify the blockchain state and require a transaction.
    • Red buttons: Represent payable functions that allow sending Ether along with the transaction.
    • Blue buttons: Represent view and pure functions that read data from the blockchain without modifying the state.
  2. Non-View Function Interaction:
    • The video demonstrates executing a non-view function that requires an array of integers as input.
    • The user provides the input in the format [integer1, integer2, ...] using commas to separate the arguments and enclosing them in square brackets. This notation also works for tuples and structs.
    • Clicking the corresponding button executes the transaction, and the transaction receipt is displayed in the console.
  3. Payable Function Interaction:
    • The video demonstrates executing a payable function that requires multiple arguments and sending Ether along with the transaction.
    • The user expands the input field using the dropdown to provide the arguments.
    • The user specifies the amount of Ether to send using the "value" field, changing the unit to "ether" and entering the desired amount (e.g., 1 ether).
    • Clicking the corresponding button executes the transaction, including the Ether transfer.
  4. View Function Interaction:
    • The video demonstrates executing a view function that returns a string.
    • Clicking the corresponding button executes the function, and the returned string is displayed below the button.

Low-Level Interaction

  1. Purpose: The video explains that low-level interactions allow manual creation of the transaction's data field and interaction with the fallback or receive functions of a smart contract.
  2. Receive Function Interaction:
    • The video demonstrates calling the receive function by sending Ether to the smart contract.
    • The data field is left empty. If data needs to be sent, the user must manually construct the data argument and paste it into the data field.
    • The user specifies the amount of Ether to send using the "value" field.
    • The user clicks the "Transact" button in the low-level interaction section to send the transaction.
  3. Fallback and Receive Function Rules: The video emphasizes the importance of respecting the rules regarding fallback and receive functions, warning that Remix will display a warning if these rules are violated.

Interacting with Deployed Contracts on Public Networks

  1. Scenario: The video demonstrates interacting with a smart contract already deployed on the Sepolia test network.
  2. Requirements: To interact with an existing contract, you need either the ABI or the source code with the same compiler settings.
  3. ABI Retrieval: The user copies the ABI from Etherscan.
  4. ABI Integration: In Remix, the user creates a new file with the .abi extension and pastes the ABI into the file, ensuring this file is the active tab in the editor.
  5. Contract Address Retrieval: The user copies the contract address from Etherscan.
  6. Address Input: In Remix, the user navigates to the "Deploy" tab, finds the "At Address" input field, and pastes the contract address.
  7. Network Connection: The user connects Remix to the Sepolia network using MetaMask, ensuring the correct network is selected in MetaMask.
  8. Environment Selection: In Remix, the user selects "Injected Provider - MetaMask" in the environment dropdown. The chain ID should be displayed below the environment select box.
  9. Contract Instantiation: The user clicks the "At Address" button to instantiate the contract in the "Deployed Contracts" section.
  10. Interaction: The user can now interact with the deployed contract using the interface provided in the "Deployed Contracts" section.

Pinning Contracts

  1. Purpose: The pinning feature allows easy access to a contract without needing to remember its address or locate its ABI.
  2. Pinning Process: In the "Deployed Contracts" section, the user clicks the pin icon next to the contract.
  3. Persistence: The next time the user connects to the same network and uses the same workspace, the pinned contract will be present in the "Deployed Contracts" section.
  4. Network Compatibility: The pinning feature works for all networks, including the Remix VM.

Conclusion

The video provides a comprehensive guide on deploying and interacting with smart contracts using the Remix IDE. It covers compiling and deploying contracts, interacting with different function types, using low-level interactions, connecting to public networks, and utilizing the pinning feature for easy access to contracts. The video emphasizes the importance of understanding function types, providing correct inputs, and respecting the rules of fallback and receive functions. The pinning feature is highlighted as a convenient way to manage and access frequently used contracts.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.