Hedera
  • Welcome to Hedera — let’s build the future
  • Getting Started
    • Environment Setup
    • Web2 Developers
      • Transfer HBAR
      • Create a Token
      • Create a Topic
    • EVM Developers
      • Deploy a Contract
  • Tutorials
    • Smart Contracts
      • How to Mint & Burn an ERC-721 Token Using Hardhat and Ethers (Part 1)
      • How to Set Access Control, a Token URI, Pause, and Transfer an ERC-721 Token Using Hardhat (Part 2)
      • How to Verify a Smart Contract on HashScan
      • Deploy a Smart Contract Using Remix
      • Deploy a Smart Contract Using Hardhat and Hiero JSON-RPC Relay
      • Deploy Your First Smart Contract
      • Deploy a Contract Using the Hedera Token Service
      • Send and Receive HBAR Using Solidity Smart Contracts
      • Deploy By Leveraging Ethereum Developer Tools On Hedera
      • Deploy a Subgraph Using The Graph and Hedera JSON-RPC Relay
      • Deploy Smart Contracts on Hedera Using Truffle
      • The Power of Native Hedera Tokens as ERC-20 Tokens: A step-by-step guide
      • HTS x EVM - Part 1: How to Mint NFTs
      • HTS x EVM - Part 2: KYC & Update
      • HTS x EVM - Part 3: How to Pause, Freeze, Wipe, and Delete NFTs
      • Hedera Smart Contracts Workshop
        • Setup
        • Solidity
        • Hedera SDK JS
        • Hardhat and EthersJs
        • Outro
      • Foundry
        • How to Setup Foundry and Write a Basic Unit Test
        • How to Deploy and Verify a Hedera Smart Contract with Foundry
        • How to Test A Solidity Event
        • How to Fork Testnet on Latest Block
    • Consensus
      • Submit Your First Message
      • Submit Message to Private Topic
      • Query Messages with Mirror Node
    • Tokens
      • Create and Transfer Your First NFT
      • Create and Transfer Your First Fungible Token
      • Create and Transfer an NFT using a Solidity Contract
      • Structure Your Token Metadata Using JSON Schema V2
      • Hedera Token Service - Part 1: How to Mint NFTs
      • Hedera Token Service - Part 2: KYC, Update, and Scheduled Transactions
      • Hedera Token Service - Part 3: How to Pause, Freeze, Wipe, and Delete NFTs
      • Create Your First Frictionless Airdrop Campaign
    • Local Node
      • How to Run Hedera Local Node in a Cloud Development Environment (CDE)
        • Run a Local Node in Gitpod
        • Run a Local Node in Codespaces
      • How to Set Up a Hedera Local Node
      • Set Up a Hedera Local Node using the NPM CLI
    • More Tutorials
      • Create and Fund Your Hedera Testnet Account
      • How to Create a Personal Access Token (API Key) on the Hedera Portal
      • How to Auto-Create Hedera Accounts with HBAR and Token Transfers
      • How to Configure a Mirror Node and Query Data
      • How to Generate a Random Number on Hedera
      • Get Started with the Hedera Consensus Service Fabric Plugin
        • Virtual Environment Setup
      • Schedule Your First Transaction
      • How to Connect to Hedera Networks Over RPC
        • Configuring Hashio RPC endpoints
        • Configuring Hiero JSON-RPC Relay endpoints
        • Configuring Validation Cloud RPC endpoints
      • JavaScript Testing
      • Create a Hedera DApp Integrated with WalletConnect
      • How to Connect MetaMask to Hedera
    • Demo Applications
    • Starter Projects
    • Building on Hedera (course)
  • Networks
    • Mainnet
      • Mainnet Accounts
      • Mainnet Consensus Nodes
        • Node Requirements
          • FAQ
      • Fees
        • Transaction Records
    • Testnets
      • Testnet Accounts
      • Testnet Consensus Nodes
    • Localnet
      • Single Node Configuration
      • Multinode Configuration
    • Network Explorers and Tools
    • Release Notes
      • Consensus Node
      • Hedera Mirror Node
  • Core Concepts
    • Accounts
      • Account Creation
      • Auto Account Creation
      • Account Properties
    • Keys and Signatures
    • Schedule Transaction
    • Smart Contracts
      • Understanding Hedera's EVM Differences and Compatibility
        • For EVM Developers Migrating to Hedera
          • Accounts, Signature Verification & Keys (ECDSA vs. ED25519)
          • JSON-RPC Relay and EVM Tooling
          • Token Management with Hedera Token Service
          • Decimal Handling (8 vs. 18 Decimals)
          • Handling HBAR Transfers in Contracts
        • For Hedera-Native Developers Adding Smart Contract Functionality
          • Integrating ED25519 Accounts and Advanced Features Into Smart Contracts
          • JSON-RPC Relay and State Queries
          • Extending Token Management with Smart Contracts
      • Creating Smart Contracts
      • Compiling Smart Contracts
      • System Smart Contracts
        • Hedera Account Service
        • Hedera Schedule Service
      • Gas and Fees
      • JSON-RPC Relay
      • Deploying Smart Contracts
      • Smart Contract Addresses
      • Verifying Smart Contracts
      • Smart Contract Traceability
      • Tokens Managed by Smart Contracts
        • ERC-20 (Fungible Tokens)
        • ERC-721 (Non-Fungible Token)
        • ERC-3643 Real World Assets (RWA)
        • ERC-1363 (Payable Tokens)
        • Hedera Token Service System Contract
      • Wrapped HBAR (WHBAR)
      • Smart Contract Rent
      • Smart Contract Security
      • EVM Archive Node Queries
    • Tokens
      • Tokenization on Hedera
      • Hedera Token Service (HTS) Native Tokenization
        • Token Types and ID Formats
        • Token Properties
        • Token Creation
        • Custom Fee Schedule
        • Token Airdrops
      • ERC/EVM-Compatible Tokenization
      • Hybrid (HTS + EVM ) Tokenization
    • Staking
      • Staking Program
      • Stake HBAR
    • Hashgraph Consensus Algorithm
      • Gossip About Gossip
      • Virtual Voting
    • Transactions and Queries
      • Transaction Properties
    • State and History
    • Mirror Nodes
      • Hedera Mirror Node
      • One Click Mirror Node Deployment
      • Run Your Own Mirror Node
        • Run Your Own Mirror Node with Google Cloud Storage (GCS)
        • Run Your Mirror Node with Amazon Web Services S3 (AWS)
  • Open Source Solutions and Integrations
    • AI Tools for Developers
      • Hedera AI Agent Kit
      • ElizaOS Plugin for Hedera
      • Hedera Hivemind
      • Kapa AI
    • Asset Tokenization Studio (ATS)
      • Web User Interface (UI)
      • Frequently Asked Questions (FAQs)
    • HashioDAO
      • Governance Token DAO
      • NFT DAO
      • Multisig DAO
      • DAO Proposals
      • Local Environment Setup
    • Hedera CLI
    • Hedera Custodians Library
      • How to use it
    • Hedera Developer Playground
    • Hedera Wallet Snap By MetaMask
      • Hedera Wallet Snap Documentation
      • Tutorial: MetaMask Snaps – What Are They and How to Use Them
    • Interoperability and Bridging
      • LayerZero
    • NFT Studio
      • Airdrop List Verifier
      • Metadata Validator
      • NFT Rarity Inspector
      • NFT Token Holders List Builder
      • NFT Risk Calculator
      • Token Balance Snapshot
      • Hedera NFT SDK
    • Oracle Networks
      • Chainlink Oracles
      • Pyth Oracles
      • Supra Oracles
    • Stablecoin Studio
      • Core Concepts
      • Web UI Application
      • CLI Management
      • TypeScript SDK
    • Hedera Guardian
    • Hedera WalletConnect
  • SDKs & APIs
    • SDKs
      • Build Your Hedera Client
      • Set Up Your Local Network
      • Network Address Book
      • Keys
        • Generate a new key pair
        • Import an existing key
        • Create a key list
        • Create a threshold key
        • Generate a mnemonic phrase
        • Recover keys from a mnemonic phrase
      • HBAR
      • Specialized Types
      • Pseudorandom Number Generator
      • Transactions
        • Create a Batch Transaction
        • Transaction ID
        • Modify transaction fields
        • Create an unsigned transaction
        • Manually sign a transaction
        • Submit a transaction
        • Sign a multisignature transaction
        • Get a transaction receipt
        • Get a transaction record
      • Schedule Transaction
        • Schedule ID
        • Create a schedule transaction
        • Sign a scheduled transaction
        • Delete a schedule transaction
        • Get schedule info
        • Network Response Messages
      • Queries
      • General Network Response Messages
      • Accounts and HBAR
        • Create an account
        • Update an account
        • Transfer cryptocurrency
        • Approve an allowance
        • Delete an allowance
        • Delete an account
        • Get account balance
        • Get account info
        • Network Response Messages
      • Consensus Service
        • Create a topic
        • Update a topic
        • Submit a message
        • Delete a topic
        • Get topic messages
        • Get topic info
        • Network Response
      • Token Service
        • Token ID
        • NFT ID
        • Token types
        • Create a token
        • Custom token fees
        • Update a token
        • Update token custom fees
        • Update NFT metadata
        • Transfer tokens
        • Airdrop a token
        • Claim a token
        • Cancel a token
        • Reject a token
        • Delete a token
        • Mint a token
        • Burn a token
        • Freeze an account
        • Unfreeze an account
        • Enable KYC account flag
        • Disable KYC account flag
        • Associate tokens to an account
        • Dissociate tokens from an account
        • Pause a token
        • Unpause a token
        • Wipe a token
        • Atomic swaps
        • Get account token balance
        • Get token info
        • Get NFT info
        • Network Response Messages
      • File Service
        • Create a file
        • Append to a file
        • Update a file
        • Delete a file
        • Get file contents
        • Get file info
        • Network Response Messages
      • Smart Contract Service
        • Delegate Contract ID
        • Create a smart contract
        • Update a smart contract
        • Delete a smart contract
        • Call a smart contract function
        • Ethereum transaction
        • Get a smart contract function
        • Get smart contract bytecode
        • Get smart contract info
        • Hedera Service Solidity Libraries
        • Network Response Messages
      • Signature Provider
        • Provider
        • Signer
        • Wallet
        • Local Provider
    • Mirror Node REST API
      • Accounts
      • Balances
      • Blocks
      • Schedule Transactions
      • Smart Contracts
      • Tokens
      • Topics
      • Transactions
      • Network
    • Hedera Consensus Service gRPC API
    • Hedera APIs
      • Basic Types
        • AccountAmount
        • AccountID
        • ContractID
        • CryptoAllowance
        • CurrentAndNextFeeSchedule
        • FeeComponents
        • FeeData
        • FeeSchedule
        • FileID
        • Fraction
        • HederaFunctionality
        • Key
        • KeyList
        • NftAllowance
        • NftTransfer
        • NodeAddress
        • NodeAddressBook
        • RealmID
        • ScheduleID
        • SemanticVersion
        • ServicesConfigurationList
        • ServiceEndpoint
        • Setting
        • ShardID
        • Signature
        • SignatureList
        • SignatureMap
        • SignaturePair
        • SubType
        • TransferList
        • TransactionID
        • ThresholdKey
        • ThresholdSignature
        • TokenAllowance
        • TokenBalance
        • TokenBalances
        • TokenFreezeStatus
        • TokenPauseStatus
        • TokenID
        • TokenKycStatus
        • TokenRelationship
        • TokenTransferList
        • TokenType
        • TokenSupplyType
        • TopicID
        • TransactionFeeSchedule
      • Cryptocurrency Accounts
        • CryptoService
        • CryptApproveAllowance
        • CryptoDeleteAllowance
        • CryptoCreate
        • CryptoTransfer
        • CryptoUpdate
        • CryptoDelete
        • CryptoGetAccountBalance
        • CryptoGetAccountRecords
        • CryptoGetInfo
        • CryptoGetStakers
      • Consensus Service
        • Consensus Service
        • ConsensusCreateTopic
        • ConsensusUpdateTopic
        • ConsensusSubmitMessage
        • ConsensusDeleteTopic
        • ConsensusTopicInfo
        • ConsensusGetTopicInfo
      • Schedule Service
        • ScheduleService
        • SchedulableTransactionBody
        • ScheduleCreate
        • ScheduleDelete
        • ScheduleSign
        • ScheduleGetInfo
      • Token Service
        • TokenService
        • CustomFees
          • AssessedCustomFee
          • CustomFee
          • FractionalFee
          • FixedFee
          • RoyaltyFee
        • TokenCreate
        • TokenUpdate
        • TokenFeeScheduleUpdate
        • TokenDelete
        • TokenMint
        • TokenBurn
        • TokenFreezeAccount
        • TokenUnfreezeAccount
        • TokenGrantKyc
        • TokenRevokeKyc
        • TokenAssociate
        • TokenDissociate
        • TokenWipeAccount
        • TokenPause
        • TokenUnpause
        • TokenGetInfo
        • TokenGetNftInfo
        • TokenGetNftInfos
        • TokenGetAccountNftInfo
      • File Service
        • FileService
        • FileCreate
        • FileAppend
        • FileUpdate
        • FileDelete
        • FileGetContents
        • FileGetInfo
      • Smart Contracts
        • SmartContractService
        • ContractCall
        • ContractCallLocal
        • ContractCreate
        • ContractUpdate
        • ContractDelete
        • ContractGetByteCode
        • ContractGetInfo
        • ContractGetRecords
      • Miscellaneous
        • Duration
        • ExchangeRate
        • Freeze
        • FreezeType
        • GetByKey
        • GetBySolidityID
        • NetworkGetVersionInfo
        • NetworkService
        • Query
        • QueryHeader
        • Response
        • ResponseCode
        • ResponseHeader
        • SystemDelete
        • SystemUndelete
        • TimeStamp
        • Transaction
        • TransactionBody
        • TransactionContents
        • TransactionGetFastRecord
        • TransactionGetReceipt
        • TransactionGetRecord
        • TransactionReceipt
        • TransactionRecord
        • TransactionResponse
        • UncheckedSubmit
    • Hedera Status API
  • Support & Community
    • Glossary
    • Contributing to Hedera documentation
      • Contribution Guidelines
        • Creating Issues
        • Creating Pull Requests
        • Hedera Improvement Proposal (HIP)
        • Submit Demo Applications
      • Style Guide
        • Understanding different types of documentation
        • Use of HBAR and tinybars
        • Use of web2 and web3
        • Language and grammar
        • Formatting
        • Punctuation
        • GitBook Markdown Syntax
    • Discord
    • GitHub
    • Stack Overflow
    • Hedera Blog
    • Bug Bounty
    • Hedera Help
    • Documentation Survey
    • Meetups
    • Brand Guidelines
    • Status Page
Powered by GitBook
LogoLogo

INTRODUCTION

  • Fees
  • Core Concepts
  • Network Information

TOOLS

  • Bridge
  • Oracles
  • Explorers
  • Developer Portal & Faucet

RESOURCES

  • Status
  • Bug Bounty
  • Build on Hedera (course)
  • Documentation Survey
On this page
  • Deploying a Contract Using the Hedera Smart Contract Service
  • Prerequisites
  • Step 1: Navigate to the hscs Directory and Start the Relay
  • Start the JSON-RPC Relay
  • Step 2: Guided Code Walkthrough
  • Write the Smart Contract
  • Compile the Smart Contract
  • Write the Deployment Script
  • Write Data to the Smart Contract
  • Read Data from the Smart Contract
  • Step 3: Deploy Contract and Verify on HashScan Mirror Node Explorer
  • Code Check ✅
  • Complete
  • Next Steps

Was this helpful?

Edit on GitHub
  1. Getting Started
  2. EVM Developers

Deploy a Contract

PreviousEVM DevelopersNextTutorials

Last updated 5 months ago

Was this helpful?

Deploying a Contract Using the Hedera Smart Contract Service

This tutorial will walk you through writing and compiling a Solidity smart contract. You'll then deploy and interact with it on the Hedera network using the and familiar EVM tools like Ethers.js, connecting via the .

What you will accomplish

By the end of this tutorial, you will be able to:

  • Write a smart contract

  • Compile a smart contract

  • Deploy a smart contract

  • Update smart contract state

  • Query smart contract state

Note: This tutorial is currently supported only in the Getting Started series and is not available for other languages.


Prerequisites

Before you begin, you should have completed the following tutorials:


Step 1: Navigate to the hscs Directory and Start the Relay

Navigate to the hscs directory to deploy a smart contract example:

cd hscs

If you completed a previous example in the series, you can go back to the root directory and cd into this example.

cd ../hscs

If you want to get back to the root directory, you can cd out from any directory with this command

cd ../

Start the JSON-RPC Relay

This step is not required for Gitpod

From the root directory of the hedera-future-world-js project, run a Hedera JSON-RPC Relay instance with the below script:

./util/04-rpcrelay-run.sh

What exactly is the JSON-RPC Relay?

Why is it important?

  • Developers can use familiar EVM tools and workflows on Hedera without learning new tooling.

  • Provides compatibility and support for Solidity smart contracts.

  • Enables smooth communication between dApps and Hedera.

Next: Code Walkthrough


Step 2: Guided Code Walkthrough

Open these two files located in the /hscs directory in a code editor, such as VS Code or your GitPod instance, to follow along:

  • my_contract.sol

  • script-hscs-smart-contract

Write the Smart Contract

For this tutorial, a simple smart contract, my_contract.sol, has already been prepared for you. You will only need to make one modification (outlined below) for it to compile successfully.

Get the Name Stored in Mapping

my_contract.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

contract MyContract {
    string public constant scriptId = 'HFWV2_hscsSC';

    mapping(address => string) public names;

    function introduce(string memory name) public {
        names[msg.sender] = name;
    }

    function greet() public view returns (string memory) {
        // NOTE: Store name in smart contract
        string memory name = names[msg.sender];
        return string.concat("Hello future! - ", name);
    }
}

Note: This smart contract has two functions, introduce and greet. You will invoke both of them later on.

Compile the Smart Contract

Once you have completed writing the smart contract in Solidity, you must compile it using the Solidity compiler.

Install the dependencies using npm. You will also need to install a Solidity compiler using the --global flag.

npm install && npm install --global solc@0.8.17

Invoke the compiler on your Solidity file. Then list (ls) files in the current directory.

solcjs --bin --abi ./my_contract.sol
ls

You should see a console output similar to the following:

my_contract.sol
my_contract_sol_MyContract.abi
my_contract_sol_MyContract.bin
  • The .abi file contains the JSON representation of the interface used to interact with the smart contract.

  • The .bin file contains EVM bytecode, which is used in deploying the smart contract.

Note that while the .abi file is human-readable, the .bin file is not intended to be human-readable.

After compiling your smart contract, your project directory should look similar to the following:

Write the Deployment Script

Initialize Wallet and RPC Connection

The following code snippet from the script-hscs-smart-contract file will read your credentials from the .env file to initialize your wallet (operator account) and establish an RPC connection to interact with the Hedera network.

script-hscs-smart-contract.js
async function scriptHscsSmartContract() {
    logger.logStart('Hello Future World - HSCS smart contract - start');
    
    // Read in environment variables from `.env` file in parent directory
    dotenv.config({ path: '../.env' });

    // Initialize the operator account
    const operatorIdStr = process.env.OPERATOR_ACCOUNT_ID;
    const operatorKeyStr = process.env.OPERATOR_ACCOUNT_PRIVATE_KEY;
    const rpcUrl = process.env.RPC_URL;
    if (!operatorIdStr || !operatorKeyStr || !rpcUrl) {
        throw new Error('Must set OPERATOR_ACCOUNT_ID, OPERATOR_ACCOUNT_PRIVATE_KEY, and RPC_URL environment variables');
    }

    logger.logSection('Initializing operator account');
    const rpcProvider = new JsonRpcProvider(rpcUrl);
    const operatorWallet = new Wallet(operatorKeyStr, rpcProvider);
    const operatorAddress = operatorWallet.address;
    logger.log('Operator account initialized:', operatorAddress);
}

Prepare Smart Contract for Deployment

This section of the code reads the compiled ABI and bytecode files of the smart contract using the fs (file system) module. The first 32 characters of both the ABI and bytecode are then displayed in the console to confirm that they have been successfully read and are ready for deployment.

script-hscs-smart-contract.js
const abi = await fs.readFile(`${solidityFileName}.abi`, {
  encoding: 'utf8',
});
const evmBytecode = await fs.readFile(`${solidityFileName}.bin`, {
    encoding: 'utf8',
});
logger.log(
  'Compiled smart contract ABI:',
  abi.substring(0, 32),
  CHARS.HELLIP,
);
logger.log(
  'Compiled smart contract EVM bytecode:',
  evmBytecode.substring(0, 32),
  CHARS.HELLIP,
);

The ContractFactory class deploys the smart contract to the network using the ABI, bytecode, and the operatorWallet to authorize the transaction. After deployment, the contract's address, accessible via the address property of the myContract object, is displayed in the console and uniquely identifies the contract on the network. This deployment result is stored in the myContract variable, which is used in subsequent steps and already set up in the script.

script-hscs-smart-contract.js
const myContractFactory = new ContractFactory(abi, evmBytecode, operatorWallet);
const myContract = await myContractFactory.deploy();
const deployTx = myContract.deployTransaction;
const deploymentTxReceipt = await deployTx.wait();
console.log('Smart contract deployment transaction fee', calculateTransactionFeeFromViem(deploymentTxReceipt));

const deploymentTxAddress = myContract.address;
const deploymentTxHashscanUrl = `https://hashscan.io/testnet/contract/${deploymentTxAddress}`;

logger.log('Smart contract deployment address:', deploymentTxAddress);
logger.log('Smart contract deployment Hashscan URL:\n',
        ...logger.applyAnsi('URL', deploymentTxHashscanUrl),
    );

Write Data to the Smart Contract

Next, you will invoke the introduce function on your deployed smart contract. This function call initiates a state-changing transaction on the smart contract.

script-hscs-smart-contract.js
// Write data to smart contract
// NOTE: Invoke a smart contract transaction
await logger.logSection('Write data to smart contract');
const scWriteTxRequest = await myContract.functions.introduce(
    `${logger.version} - ${logger.scriptId}`,
  );
  const scWriteTxReceipt = await scWriteTxRequest.wait();
  logger.log(
    'Smart contract write transaction fee',
    calculateTransactionFeeFromViem(scWriteTxReceipt),
  );
  const scWriteTxHash = scWriteTxReceipt.transactionHash;
  const scWriteTxHashscanUrl = `https://hashscan.io/testnet/transaction/${scWriteTxHash}`;
  logger.log('Smart contract write transaction hash', scWriteTxHash);
  logger.log(
    'Smart contract write transaction Hashscan URL:\n',
    ...logger.applyAnsi('URL', scWriteTxHashscanUrl),
  );

Read Data from the Smart Contract

In the previous step, you changed the state of the smart contract by invoking the introduce function. This involved submitting a transaction to the network, which stored new data in the smart contract, such as an introduction message or relevant information. This change was recorded on the network as part of the transaction.

This time, you will read the state of the smart contract. Unlike the previous operation, reading the state is simpler since it does not require submitting a transaction or modifying the contract.

Finally, invoke the greet function to read data from the smart contract and save its response to a variable, myContractQueryResult. This operation is read-only and does not modify the state. This function will return stored data without creating a transaction.

script-hscs-smart-contract.js
// Read data from smart contract
// NOTE: Invoke a smart contract query
await logger.logSection('Read data from smart contract');
const [scReadQueryResult] = await myContract.functions.greet();
logger.log('Smart contract read query result:', scReadQueryResult);

When invoking functions in a smart contract, you may do so in two different ways:

  • With a transaction → Smart contract state may be changed.

  • Without a transaction → Smart contract state may be queried but may not be changed.


Step 3: Deploy Contract and Verify on HashScan Mirror Node Explorer

In the terminal, cd into the hscs directory and run the contract create transaction script to deploy the smart contract:

node script-hscs-smart-contract.js

Sample output:

🏁 Hello Future World - HSCS smart contract - start  …

🟣 Initializing operator account  …
↪️ file:///workspace/hello-future-world-js/hscs/script-hscs-smart-contract.js:37:10
(Hit the "return" key when ready to proceed)Operator account initialized: 0xc8Cc82640c2D47162Ecd441C4a1e9752D75ee2De

🟣 Reading compiled smart contract artefacts  …
↪️ file:///workspace/hello-future-world-js/hscs/script-hscs-smart-contract.js:44:16
Compiled smart contract ABI: [{"inputs":[],"name":"greet","ou …
Compiled smart contract EVM bytecode: 608060405234801561001057600080fd …

🟣 Deploying smart contract  …
↪️ file:///workspace/hello-future-world-js/hscs/script-hscs-smart-contract.js:64:16
Smart contract deployment transaction fee 0.05690034 ℏ
Smart contract deployment address: 0xd3127d5544615326343e4c0E4516B94bf06552B7
Smart contract deployment Hashscan URL:
 https://hashscan.io/testnet/contract/0xd3127d5544615326343e4c0E4516B94bf06552B7

🟣 Write data to smart contract  …
↪️ file:///workspace/hello-future-world-js/hscs/script-hscs-smart-contract.js:87:16
Smart contract write transaction fee 0.02866563 ℏ
Smart contract write transaction hash 0x45cc36108088958a245dd591a68c1e7c615ec93b32884c1579e5587eab61aa53
Smart contract write transaction Hashscan URL:
 https://hashscan.io/testnet/transaction/0x45cc36108088958a245dd591a68c1e7c615ec93b32884c1579e5587eab61aa53

🟣 Read data from smart contract  …
↪️ file:///workspace/hello-future-world-js/hscs/script-hscs-smart-contract.js:106:16
Smart contract read query result: Hello future! - 0.2.1-7487be2e - hscsSC

🎉 Hello Future World - HSCS smart contract - complete  …
  • The contract exists

  • Under the "Contract Bytecode" section, its "Compiler Version" field matches the version of the Solidity compiler that you used (0.8.17) (2)

  • Under the "Recent Contract Calls" section, There should be two transactions:

    • The transaction with the earlier timestamp (bottom) should be the deployment transaction. (3A)

      • Navigate to this transaction by clicking on the timestamp.

      • Under the "Contract Result" section, the "Input - Function & Args" field should be a relatively long set of hexadecimal values.

      • This is the EVM bytecode output by the Solidity compiler.

      • Navigate back to the Contract page (browser ⬅ button).

    • The transaction with the later timestamp (top) should be the function invocation transaction, of the introduce function. (3B)

      • Navigate to this transaction by clicking on the timestamp.

      • Under the "Contract Result" section, the "Input - Function & Args" field should be a relatively short set of hexadecimal values.

      • This is the representation of

        • the function identifier as the first eight characters (e.g. 0xc63193f6 for the introduce function), and

        • the input string value (e.g. 0x5626775697a0 for bguiz).

      • Navigate back to the Contract page (browser ⬅ button).

Additional

The steps above are sufficient to check that you have deployed and interacted with the same contract successfully. You may optionally wish to perform these additional checks as well.

Open myContractWriteTxExplorerUrl in your browser. This should be the same page as "the transaction with the later timestamp" in 3B from the previous checks. Check that:

  • The transaction exists

  • Its "Type" field is "ETHEREUM TRANSACTION"

  • Under the "Contract Result" section, its "From" field matches the value of accountId

  • Under the "Contract Result" section, its "To" field matches the value of myContractAddress


Code Check ✅


Complete

Congratulations, you have completed the Deploy a Contract tutorial in the Getting Started series for the EVM Developers learning path! 🎉🎉🎉!

You learned how to:


Next Steps

Explore the tutorials below to discover all the EVM-compatible tools available on Hedera. Happy building!

The Hedera JSON-RPC Relay connects your dApps to Hedera’s EVM-compatible nodes, translating JSON-RPC requests from tools like or into commands Hedera understands. This enables seamless interaction with smart contracts on Hedera.

In the next code walkthrough step, you can follow along or skip ahead to to execute and deploy the contract. If you decide to skip ahead, first.

Inside the greet() function, we want to access the names mapping to retrieve the name of the account calling this function. The account is identified by its and can be accessed using msg.sender in Solidity.

If you have not configured your RPC connection to the Hedera network, do so by choosing one of the options from the tutorial before moving on to the next step. Then run ./util/04-rpcrelay-run.sh to run a Hedera JSON-RPC relay instance.

The and a link to view it on HashScan will be provided in your console. See the example output .

Open the in your browser and check that:

File:

File:

Have questions? Join the and post them in the channel or ask on .

ethers.js
web3.js
How to Connect to Hedera Networks Over RPC
smart contract deployment Hashscan URL
my_contract.sol
script-hscs-smart-contract.js
Hedera Discord
developer-general
Stack Overflow
Step 3
compile the smart contract
JSON-RPC relay
JavaScript
Create and Fund Your Hedera Testnet Account
Environment Setup
Configure RPC Connection
here
LogoDeploy a Smart Contract Using Hardhat and Hedera JSON-RPC Relay | Hedera
LogoDeploy By Leveraging Ethereum Developer Tools On HederaHedera
LogoHow to Verify a Smart Contract on HashScan | Hedera
EVM account alias
Hedera Smart Contract Service (HSCS)
transaction hash
HSCS contract in Hashscan, with annotated items to check.