Skip to content

Latest commit

 

History

History
102 lines (78 loc) · 2.67 KB

Backend.md

File metadata and controls

102 lines (78 loc) · 2.67 KB

Backend

Overview

Usually you will want to implement ethers in the backend for implementing some bussiness logic, to have certaing validations, more control in the application using blockchain, is also useful for analyze events or data.

Getting Started

Prerequisites

You will need a JS package manager.

  • npm
    npm install npm@latest -g

Installation

In order to interact with an EVM blockchain you will need a provider, get a free Provider API Key at one of these options:

Clone the repo

  1. Clone the repo
    git clone https://github.com/your_username_/Project-Name.git
  2. Install NPM packages
    npm install
  3. Create a .env file from .env.example and replace the environment variables.

Setup from scratch

  1. Set new project
    npm init 
  2. Install NPM packages
    npm install ethers
    npm install -D typescript
    npm install -D ts-node
    npm install -g solc
    npm install --save-dev @typechain/ethers-v6
  3. Set your environment variables
    PROVIDER_API_KEY = 'ENTER YOUR API'
    PRIVATE_KEY = 'ENTER YOUR PRIVATE KEY'

(back to top)

Usage

In example folder you will see several examples. for running any of those:

ts-node examples/example.ts

In case you want compile the contract and get bin or abi. For this you will need to install solc globally

 solcjs --bin --abi  --include-path node_modules/ --base-path ./examples/data -o ./examples/data/compiled ./examples/data/Voting.sol 

or

 npm run compile

In case you want generate types for the contract.

 typechain --target=ethers-v6 ./examples/data/compiled**/*.abi --out-dir ./examples/data/types

or

 npm run gen-types

(back to top)

File Resources

(back to top)