How to: Deploy a Smart Contract on Eclipse Testnet [Thai]
December 21st, 2023

สวัสดีครับ วันนี้ผมจะมาช่วยอธิบายการสร้าง Smart Contract บน Eclipse Testnet โดยเบื้องต้นครับ

โดยขั้นตอนหลักๆคือ

  1. มี Macbook

  2. มี Private Key และ Seed Phrase ของกระเป๋า (จึงแนะนำให้สร้างกระเป๋าใหม่)

  3. มี เงินใน Eclipse Testnet

  4. การ deploy Smart Contract

อ้างอิง Documentation ณ วันที่ 21 ธันวาคม 2023 เขาจะใช้วิธี generate private key ผ่าน command line solana-keygen new ซึ่งอาจเกิดปัญหาตรงที่เราจะแปลง private key ที่เก็บไว้ ซึ่งอยู่ในรูปของ list ตัวเลข (ตัวอย่าง [1,2,3,…]) เป็น seed phrases ยังไง ซึ่งเราจะขอเสนอวิธีที่ practical กว่า มาเริ่มกันครับ

  1. Install สิ่งเหล่านี้ผ่าน terminal (สามารถเปิดผ่าน Command + Space bar) ตามลิ้งค์

    1. brew: https://docs.brew.sh/Installation

    2. git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

    3. npm: https://nodejs.org/en/download

  2. เราจะใช้การ gen private seed ผ่านกระเป๋าตังค์ Web3 ทั้ง Metamask และ Phantom เพื่อลดความยุ่งยากครับ หากท่านใดมีกระเป๋าใช้งานอยู่แล้ว ผมแนะนำให้สร้าง user ใหม่ใน chrome แล้วติดตั้ง extension เพื่อเพิ่มความสะดวกในการใช้กับงาน Dev ต่อๆไปครับ

    • Metamask: เราจะนำ private key เพื่อใช้ bridge เงินจาก Sepolia ไป Eclispe Testnet และนำ seed phase มาใช้งานต่อภายหลัง

    • Phantom: สามารถ import seed phase เพื่อดู Solana Adress ของตัว Metamask ได้เลย ซึ่งเราเช็คแล้วว่า address ตรงกับการใช้ Snaps ผ่าน Metamask

  3. ใส่เงิน (อาทิการขอ faucet) ใน Ethereum Sepolia

    My favorite faucet list:

    faucet.quicknode.com/ethereum/sepolia

    sepoliafaucet.com

    www.infura.io/faucet/sepolia

    จากนั้นกดรัน command ต่างๆผ่าน terminal ดังนี้

    1. ดาวน์โหลดไฟล์หลักเพื่อใช้ bridge

      git clone https://github.com/Eclipse-Laboratories-Inc/testnet-deposit

    2. เข้าถึงโฟล์ที่โหลดมา

      cd testnet-deposit

    3. Install script dependencies

      yarn install

    4. โค้ด เพื่อ bridge

      node deposit.js [YOUR_SOLANA_ADDRESS] 0x7C9e161ebe55000a3220F972058Fb83273653a6e [AMOUNT_IN_GWEI] [FEE_IN_GWEI] [ETHEREUM_PRIVATE_KEY] https://rpc.sepolia.org

      โดยที่

      • [YOUR_SOLANA_ADDRESS] จะใช้ Solana address ที่ได้จาก Phantom

      • [AMOUNT_IN_GWEI] เราจะใช้ 15000000 (จะอยู่ที่ 0.015 $ETH)

      • [FEE_IN_GWEI] ใช้ 100 (หน่วย gwei)

      • [ETHEREUM_PRIVATE_KEY] จะใช้ private key ที่ได้จาก Metamask

      ซึ่งสามารถนำโค้ดด้านล่างไปใช้ได้เลย

      node deposit.js [YOUR_SOLANA_ADDRESS] 0x7C9e161ebe55000a3220F972058Fb83273653a6e 15000000 100 [ETHEREUM_PRIVATE_KEY] https://rpc.sepolia.org

      หากสำเร็จ จะต้องขึ้นคำว่า Transaction successful และสามารถนำเลข transaction ด้านหลังไปเช็คใน https://sepolia.etherscan.io/

    ซึ่งปัจจุบันสามารถขอ faucet ได้ผ่าน command solana airdrop 100 เลย

  4. หลังจากเช็คใน https://explorer.dev.eclipsenetwork.xyz/?cluster=testnet ว่าเงินเข้า Eclipse Test แล้ว ให้เปิด terminal ใหม่

    1. ดาวน์โหลด Rust

      curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

    2. ดาวน์โหลด Solana CLI

      sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

    3. set Environment เป็น Eclipse Testnet ผ่าน command

      solana config set --url https://testnet.dev2.eclipsenetwork.xyz

    4. รัน command

      solana-test-validator

      เพื่อ test ว่า environment ที่ install ไปสมบูรณ์หรือไม่

    5. จากนั้นก็จะง่ายละ รันโค้ดดังกล่าวได้เลย

      git clone https://github.com/solana-labs/example-helloworld

      cd example-helloworld

      npm install

      npm run build:program-rust

      solana program deploy dist/program/helloworld.so

      npm run start

ซึ่งหากขึ้น output ประมาณ

Let's say hello to a Solana account... Connection to cluster established: http://127.0.0.1:8899 { 'feature-set': 2045430982, 'solana-core': '1.7.8' } Using account AiT1QgeYaK86Lf9kudqKthQPCWwpG8vFA1bAAioBoF4X containing 0.00141872 SOL to pay for fees Using program Dro9uk45fxMcKWGb1eWALujbTssh6DW8mb4x8x3Eq5h6 Creating account 8MBmHtJvxpKdYhdw6yPpedp6X6y2U9dCpdYaZJdmwV3A to say hello to Saying hello to 8MBmHtJvxpKdYhdw6yPpedp6X6y2U9dCpdYaZJdmwV3A 8MBmHtJvxpKdYhdw6yPpedp6X6y2U9dCpdYaZJdmwV3A has been greeted 1 times Success

อ้างอิง Documentation ถือว่าเสร็จกระบวนการครับ หากชื่นชอบบทความดังกล่าวสามารถ mint รูปเก็บไว้เป็นที่ระลึกได้ครับ

 
Subscribe to lordachita
Receive the latest updates directly to your inbox.
Nft graphic
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from lordachita

Skeleton

Skeleton

Skeleton