USDT transfers API
Pre-requisites: NodeJS 20.x or newer, Docker.
@subsquid/evm-processor- for retrieving Ethereum data- the triad of
@subsquid/typeorm-store,@subsquid/typeorm-codegenand@subsquid/typeorm-migration- for saving data to PostgreSQL
@subsquid/evm-typegen- for decoding Ethereum data and useful constants such as event topic0 values@subsquid/evm-abi- as a peer dependency for the code generated by@subsquid/evm-typegen@subsquid/graphql-server/ OpenReader
Define the schema for both the database and the core GraphQL API
Define the schema for both the database and the core GraphQL API in
schema.graphql:schema.graphql
Generate TypeORM classes based on the schema
src/model/index.ts.Prepare the database
- create
.envanddocker-compose.yamlfiles.envdocker-compose.yaml - start the database container
- compile the TypeORM classes
- generate the migration file
- apply the migration with
Generate utility classes for decoding USDT contract data
Generate utility classes for decoding USDT contract data based on its ABI.
-
Create an
./abifolder: - Find the ABI at the “Contract” tab of the contract page on Etherscan. Scroll down a bit:
-
Copy the ABI, then paste to a new file at
./abi/usdt.json. -
Run the utility classes generator:
src/abi/usdt.tsTie all the generated code together with `src/main.ts`
Tie all the generated code together with a
src/main.ts executable with the following code blocks:- Imports
EvmBatchProcessorobject definitionTypeormDatabaseobject definition- A call to
processor.run()with an inline definition of the batch handlerNote how supplying aTypeormDatabaseto the function causedctx.storeto be a PostgreSQL-compatibleStoreobject.
Compile the project and start the processor process
