Giter Site home page Giter Site logo

steffqing / smart-contract-event-listener Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kshyun28/smart-contract-event-listener

0.0 0.0 0.0 51 KB

A smart contract event listener implemented in Node.js, using Web3.js, and deployed on AWS using AWS CDK.

JavaScript 18.07% TypeScript 79.13% Dockerfile 2.81%

smart-contract-event-listener's Introduction

smart-contract-event-listener

Smart contract event listener for Ethereum and other EVM-compatible blockchain networks. This sample repository listens to the Transfer and Approval events of Ethereum's USDT contract.

The smart contract listener is built with:

  • Node.js
  • TypeScript
  • Web3.js

Updating Environment Variables

Refer to the .env.example file.

ETH_WSS_ENDPOINT=wss://eth-mainnet.g.alchemy.com/v2/<YOUR_API_KEY>
ETH_SMART_CONTRACT_ADDRESS=0xdac17f958d2ee523a2206206994597c13d831ec7

For the ETH_WSS_ENDPOINT, you can an endpoint from popular providers such as Alchemy and Infura.

For the ETH_SMART_CONTRACT_ADDRESS, it's referencing the Ethereum USDT contract. If you want to update the contract address, make sure that you also update the src/abi.json to reflect the updated contract address.

Local Development

For local development, you can refer to the following set of commands for starting the smart contract event listener.

  1. TypeScript:
    • npm run start:dev
  2. JavaScript:
    • npm run build
    • npm run start
  3. Docker:
    • npm run build
    • docker build -t smart-contract-event-listener:latest .
    • docker run -d --env-file .env --name smart-contract-event-listener smart-contract-event-listener:latest
    • docker logs smart-contract-event-listener
    • docker stop smart-contract-event-listener

AWS CDK

This project uses AWS CDK as the IaC (Infrastructure as Code) tool for deploying and managing AWS resources.

AWS CDK deploys the following resources:

  • VPC
  • ECS Cluster
  • ECS Fargate Service
  • ECS Fargate Task Definition

Deploying with AWS CDK

To deploy the AWS resources, first, you need to have the permissions needed to deploy to your AWS account. You can refer to this [guide](AWS CLI documentation).

Then to deploy, run the following:

  • npm run build
  • cdk deploy

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

smart-contract-event-listener's People

Contributors

kshyun28 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.