Skip to content

flare-foundation/evm-verifier

Repository files navigation

Flare Logo

Welcome to Flare EVM Transaction Verifier server.

This verifier is based on the Verifier Server Template according to the attestation type EVMTransaction. It is implemented using Nest framework.

Installation

$ yarn

Configuration

Configuration of the verifier server is carried out through environment variables, specifically by using standard ConfigModule from Nest.js, which gets configured from .env file in the root of the repository (working directory when run). See details here.

PORT specifies the port that is used for HTTP (default is port number 3000).

API_KEYS are keys that allow connection to the HTTP service.

RPC is an optional parameter for a RPC connection (default is https://flare-api.flare.network/ext/C/rpc).

Running the app

# Use the default env
cp .env.example .env
# Or configure your by editing the .env file

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

Example on Flare network

Copy .env.example file and rename it to .env. Run the code with yarn start:dev. Check the Swagger interface in browser at http://localhost:4500/api. Use Authorize button to enter API key abc123. Test API routes /EVMTransaction/prepareResponse, /EVMTransaction/mic and /EVMTransaction/prepareRequest with the following parsed request for a transaction on Flare network.

{
  "attestationType": "0x45564d5472616e73616374696f6e000000000000000000000000000000000000",
  "sourceId": "0x4554480000000000000000000000000000000000000000000000000000000000",
  "requestBody": {
    "transactionHash": "0xe1ad057e71ac82cd2eaaee0dc8700a2c1b6cff4f295a7674b9e97a5f8dd9b51c",
    "requiredConfirmations": "1",
    "provideInput": true,
    "listEvents": true,
    "logIndices": ["0"]
  }
}

In order to test the API route ETH/EVMTransaction, use the output of ETH/EVMTransaction/prepareRequest.

Locally you can check the service with curl:

 curl -X 'POST' \
  'http://localhost:4500/ETH/EVMTransaction/prepareResponse' \
  -H 'accept: */*' \
  -H 'X-API-KEY: 12345' \
  -H 'Content-Type: application/json' \
  -d '{
  "attestationType": "0x45564d5472616e73616374696f6e000000000000000000000000000000000000",
  "sourceId": "0x4554480000000000000000000000000000000000000000000000000000000000",
  "requestBody": {
    "transactionHash": "0xe1ad057e71ac82cd2eaaee0dc8700a2c1b6cff4f295a7674b9e97a5f8dd9b51c",
    "requiredConfirmations": "1",
    "provideInput": true,
    "listEvents": true,
    "logIndices": ["0"]
  }
}
'

Code Tests

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

License

This template is under MIT licensed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages