Skip to content

polkadot-developers/polkadot-api-example-cli

Repository files navigation

Contributors Forks Stargazers


Logo

Polkadot API Account Watcher

This was built using the Polkadot API Typescript Boilerplate

A decentralized command-line application that monitors a user's account on the Polkadot relay chain for the system.remarkWithEvent extrinsic. When a remark addressed to the specified account is detected, the application plays the iconic "You've Got Mail!" sound byte.

Features

  • Monitors the Westend Test Network for system.remarkWithEvent extrinsics.
  • Uses a light client powered by smoldot for efficient synchronization.
  • Detects remarks addressed to a specific account and plays a sound notification.
  • Displays the sender's account and the hash of the remark.

Prerequisites

Before starting, ensure the following tools and dependencies are installed:

Additionally, you will need an account with Westend tokens. Refer to the following resources for assistance:

Installation

  1. Clone the repository:

    git clone https://github.com/CrackTheCode016/polkadot-api-example-cli --branch empty-cli
    cd polkadot-api-example-cli
  2. Install dependencies:

    npm install

Usage

  1. Start the application and specify the account to monitor:

    npm start -- --account <account-address>

    Example:

    npm start -- --account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
  2. The application will display the following output and start monitoring the specified account:

     __        __   _    _____   __  __       _ _  __        __    _       _
     \ \      / /__| |__|___ /  |  \/  | __ _(_) | \ \      / /_ _| |_ ___| |__   ___ _ __
      \ \ /\ / / _ \ '_ \ |_ \  | |\/| |/ _` | | |  \ \ /\ / / _` | __/ __| '_ \ / _ \ '__|
       \ V  V /  __/ |_) |__) | | |  | | (_| | | |   \ V  V / (_| | || (__| | | |  __/ |
        \_/\_/ \___|_.__/____/  |_|  |_|\__,_|_|_|    \_/\_/ \__,_|\__\___|_| |_|\___|_|
    
    Watching account: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
    
  3. When a remark is detected, the application will play the "You've Got Mail!" sound and display the following:

    You've got mail!
    From: 5Cm8yiG45rqrpyV2zPLrbtr8efksrRuCXcqcB4xj8AejfcTB
    Hash: 0xb6999c9082f5b1dede08b387404c9eb4eb2deee4781415dfa7edf08b87472050
    

Testing the Application

  1. Navigate to the PAPI Dev Console > Extrinsics.

  2. Select the System pallet and the remark_with_event call.

  3. Input a remark in the format address+email. For example, if monitoring 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, input:

    5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY+email
    
  4. Submit the extrinsic and sign it using the Polkadot.js browser wallet. The application will detect the remark and display the output.

Extending the Application

This application can be extended in various ways, such as:

  • Implementing a chatroom using remarks.
  • Leveraging rollups on Polkadot to enhance functionality.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors