Skip to main content

Tutorial: Deploy a Smart Contract

This tutorial will guide you through deploying a simple "Hello World" smart contract on the Zenchain Network using Remix IDE.

Prerequisites & Considerations

  • Ethereum Wallet This tutorial assumes you already have MetaMask or another browser-based Ethereum wallet installed and ready to use.
  • Zenchain Network Details: Ensure your Ethereum wallet is connected to the Zenchain Testnet network.
  • Gas Fees: You will need some Zenchain native tokens to pay for gas fees associated with the deployment and interaction. You can obtain testnet ZCX to pay these fees from the Zenchain faucet at https://faucet.zenchain.io.

1. Set Up Remix IDE

2. Create the Smart Contract

  • In the left-hand file explorer pane, create a new file named HelloWorld.sol.
  • Paste the following Solidity code into the file:
pragma solidity ^0.8.0;

contract HelloWorld {
string public message;

constructor() {
message = "Hello, World!";
}
}

3. Compile the Smart Contract

  • Select the HelloWorld.sol file in the Remix file explorer next to the sidebar on the left side of the screen.
  • In the left-hand sidebar, click the "Solidity Compiler" icon.
  • Open the "Advanced Configuration" sub-section and sure you are using the "Shanghai" EVM version.
  • Click "Compile HelloWorld.sol."

4. Deploy the Smart Contract

  • Make sure your Ethereum wallet is connected to the Zenchain network.
  • In the left-hand sidebar, click the "Deploy & Run Transactions" plugin icon (it looks like an Ethereum diamond).
  • Under "Environment," select "Injected Provider".
  • Select your compiled contract HelloWorld under "Contract."
  • Click "Deploy." Confirm the transaction in your wallet if prompted.

5. Interact with the Smart Contract

  • Once deployed, your contract will appear under "Deployed/Unpinned Contracts" section of the "Deploy & Run Transactions" pane.
  • Expand it to see the message variable.
  • Click the blue "message" button to read the stored message. It should display "Hello, World!" in the Remix console.