Explore-Beyond-Innovations/ZeroXBridge_Contracts

Add interactive TS script to register tokens

Open

#114 创建于 2025年8月21日

在 GitHub 查看
 (4 评论) (0 反应) (1 负责人)Cairo (35 fork)auto 404
3 Days ETAenhancementgood first issue

仓库指标

Star
 (4 star)
PR 合并指标
 (PR 指标待抓取)

描述

Summary

Create a Node/TypeScript interactive script that lets an admin register tokens via the contract function:

function registerToken(AssetType assetType, address tokenAddress, address priceFeed, uint8 decimals)
enum AssetType { ETH, ERC20 }

Requirements

  • File path: scripts/registertoken.ts

  • Prompts the admin for:

    • Asset Type (ETH or ERC20)
    • Token Address (skip/zero address if ETH)
    • Price Feed Address (Chainlink Sepolia; link in script help)
    • Decimals (e.g., 18 for ETH/ERC20)
  • Validates inputs (addresses, decimals range, etc.)

  • Loads config from env:

    • RPC_URL (Sepolia)
    • PRIVATE_KEY (admin)
    • CONTRACT_ADDRESS (ZeroXBridge or Registry contract exposing registerToken)
  • Displays a full transaction preview and asks for confirmation

  • Sends the tx and prints:

    • hash
    • mined block number
    • gas used
  • Clean exit codes (non-zero on failure)

  • Include minimal ABI for registerToken + AssetType

Reference

Acceptance Criteria

  • Running ts-node scripts/registertoken.ts (or pnpm ts-node …) launches an interactive flow
  • Successful registration logs tx details; failures provide actionable errors
  • Input validation prevents obvious misconfigs (bad address, decimals, etc.)
  • Script is documented with a short header comment and usage notes

贡献者指南