- Requirements
- Analyze for this task
- The archiecture of this project
- Choosing tools
- Benefits and Drawbacks
- How to deploy this proram
- Some steps to check MongoDB
- How to run this proram
-
Scan all transactions in Illuvium blockchain game.
-
Save all transactions to a database.
-
Basic information of ILV token
- Token name: Illuvium
- Symbol: ILV
- Blockchain: Ethereum
- Token standard: ERC-20
- Contract: 0x767fe9edc9e0df98e07454847909b5e959d7ca0e
- Token type: Utility
- Total supply: 10.000.000 IVL
- Circulating supply: 7.000.000 IV
-
Some types of transactions
-
Pending transactions: transactions that have just created, and existed on the transaction pool. They are waiting miners or validators push into blocks.
The getPendingTransactions() method of IlvTokenTransactions class will get all pending transactions.
-
Transactions in blocks.
From the https://etherscan.io/, I can see the earliest block number is: 12084124, and the current block number is 13878202.
- Using getPreviousMintedTransactions() method to get all mined transactions from the block number - 12084124 to 13878202.
- And then using getLatestTransactions() method to get the latest transactions.
-
Internal transactions
I don't take care this transaction type because these transactions were created by the smart contract, not by human.
-
-
To scan all transactions in Ethereum blockchain for Illuvium.
There all some ways to deal with it:
-
get all transactions directly from Ethereum blockchain.
-
use the other services to work on it.
Now, I will use Infura to pull transactions because Infura supports caching data, so I can read the transactions from Infura fast.
-
-
The current system have write-intensive property.
Below is the architecture of the token-tracker project.
-
Using Infura to get all transactions.
-
Using in-memory queue to contain transactions from Infura, separate the processes between pulling data and saving data to database.
-
Using MongoDB to save all transactions.
Currently, our system is write-intensive. So using NoSQL is suitable because the underlying architecture of NoSQL is using Write Append Log.
-
Benefits
-
Using Infura service to get transactions in blocks from Ethereum blockchain. It will improve the performance of the read operations.
-
Using MongoDB will speed up the write operations.
-
-
Drawbacks
-
Using in-memory queue can increase the memory size of the server. If the server can be crashed, our data will be lost.
To reduce this case, we can use Kafka because:
- speed up write operations by using Zero-Copy.
- the data will be persistent.
- it's easy to scale horizontally.
-
Currently, I use free account of Infura. So Infura will limit the requests can access at a second. To increase the number of requests to Infura, we can use premium account.
-
When testing this project, scannng all mined transactions will take a long time.
-
Scanning the pending transactions, the latest transactions, and the mined transactions simultaneously may be impossible. Because the pending transactions are always raised and pushed into stack. It can block the scanning of the other transactions types because Node.js use single thread.
To solve this problem, we can have two solutions:
- Using some programming languages that support multithread.
- Deploy the scanning mined transactions and the rest of the type transactions to different servers.
-
In this task, I will use run MongoDB and Node Application as containers. These will be defined in the docker-compose.yml.
To run these applications, typing the following command at the terminal of this directory path:
docker-compose up -d --build
To remove all images:
docker-compose down --rmi all
-
Access to directly MongoDB container.
docker exec -it token-tracker-mongodb bash
-
Authenticate with MongoDB shell
mongo -u token -p "token" localhost/ilv-token
Currently, the common information of credentials:
- username: token
- password: token
- database: ilv-token
-
Show all collections.
show collections
The our current collections: tokentransactions.
-
Display all rows in MongoDB.
db.tokentransactions.find()
References:
https://etherscan.io/address/0x767fe9edc9e0df98e07454847909b5e959d7ca0e#code
https://etherscan.io/token/0x767fe9edc9e0df98e07454847909b5e959d7ca0e