← Back to list

Tutorial: Deploy Smart Contract Pakai Hardhat

Hai teman-teman penggemar blockchain! Kali ini kita akan belajar cara deploy smart contract pakai Hardhat. Kita akan pakai repositori…

FAFA · 2024-07-26 14:57 · 10 claps · 1.2 min read
#swisstronik #testnetguide #testnet-airdrop #indonesia #airdrop
Open on Medium ↗
Wiki topics: CRY · Crypto & Web3

Tutorial: Deploy Smart Contract Pakai Hardhat

Hai teman-teman penggemar blockchain! Kali ini kita akan belajar cara deploy smart contract pakai Hardhat. Kita akan pakai repositori Swisstronic-Test-Project sebagai contoh. Yuk, langsung aja kita mulai!

Swisstronik Tesnet Techinal Task 1

1. Clone Repository

git clone https://github.com/Mnuralim/hardhat-deploy-contract.git
cd hardhat-deploy-contract

2. Install Dependency

npm install

3. Set .env File

create .env file in root project

PRIVATE_KEY="your private key"

4. Create Smart Contract

  • Open contract folder
  • Create Hello_swtr.sol file
  • Copy this code and paste there
/// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

//This contract is only intended for testing purposes

contract Swisstronik {
    string private message;

    /**
     * @dev Constructor is used to set the initial message for the contract
     * @param _message the message to associate with the message variable.
     */
    constructor(string memory _message) payable{
        message = _message;
    }

    /**
     * @dev setMessage() updates the stored message in the contract
     * @param _message the new message to replace the existing one
     */
    function setMessage(string memory _message) public {
        message = _message;
    }

    /**
     * @dev getMessage() retrieves the currently stored message in the contract
     * @return The message associated with the contract
     */
    function getMessage() public view returns(string memory){
        return message;
    }
}

5. Compile Smart Contract

npm run compile

6. Deploy Smart Contract

npm run deploy

7. Get Message

npm run get-message

8. Get Message

npm run set-message

9. Selesai

Bagaimana cara push ke github?

git init
git add .
git remote set-url origin your_repo_link
git branch -M main
git push -u origin main

Kesimpulan

Selamat! Kamu sudah berhasil deploy smart contract menggunakan Hardhat dengan repositori Swisstronic-Test-Project. Sekarang kamu punya dasar yang solid untuk membangun dan deploy smart contract yang lebih kompleks.

Untuk detail lebih lanjut dan penggunaan tingkat lanjut, cek dokumentasi Hardhat.

Selamat ngoding!


메타데이터
post_id
fe162c893025
slug
tutorial-deploy-smart-contract-pakai-hardhat-fe162c893025
url
https://medium.com/@fafa95/tutorial-deploy-smart-contract-pakai-hardhat-fe162c893025
canonical_url
https://medium.com/@fafa95/tutorial-deploy-smart-contract-pakai-hardhat-fe162c893025
author_url
https://medium.com/@fafa95
status
ok
fetched_at
2026-07-23 07:31:57