MvKT is the most advanced Mavryk blockchain indexer with powerful API created by the Mavryk Dynamics team. Forked from TzKT made by Baking Bad
The indexer fetches raw data from the Mavryk blockchain, processes it, and saves it to its database to provide efficient access to the blockchain data. Using indexers is necessary part for most blockchain-related applications, because indexers expose much more data and cover much more use-cases than native node RPC, for example getting operations by hash, or operations related to particular accounts and smart contracts, or created NFTs, or token balances, or baking rewards, etc.
First of all, install git, make, docker, docker-compose, then run the following commands:
git clone https://github.com/mavryk-network/mvkt.git
cd mvkt/
make init # Restores DB from the latest snapshot. Skip it, if you want to index from scratch.
make start # Starts DB, indexer, and API. By default, the API will be available at http://127.0.0.1:5000.
make stop # Stops DB, indexer, and API.
You can configure MvKT via Mvkt.Sync/appsettings.json (indexer) and Mvkt.Api/appsettings.json (API). All the settings can also be passed via env vars or command line args. See an example of how to provide settings via env vars and read some tips about indexer configuration and API configuration.
This guide is for Ubuntu 22.04, but even if you use a different OS, the installation process will likely be the same, except for the "Install packages" part.
sudo apt update
sudo apt install git
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y dotnet-sdk-7.0
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt -y install postgresql-16 postgresql-contrib-16
sudo -u postgres psql
postgres=# create database mvkt_db;
postgres=# create user mvkt with encrypted password 'qwerty';
postgres=# grant all privileges on database mvkt_db to mvkt;
postgres=# \q
wget "https://snapshots.tzkt.io/tzkt_v1.14_mainnet.backup" -O /tmp/mvkt_db.backup
sudo -u postgres pg_restore -c --if-exists -v -1 -d mvkt_db /tmp/mvkt_db.backup
Notes:
-1 with -e -j {n}, where {n} is a number of parallel workers (e.g., -e -j 8);-U mvkt parameter.sudo -u postgres psql mvkt_db
mvkt_db=# grant all privileges on all tables in schema public to mvkt;
mvkt_db=# \q
git clone https://github.com/mavryk-network/mvkt.git ~/mvkt
cd ~/mvkt/Mvkt.Sync/
dotnet publish -o ~/mvkt-sync
Edit the configuration file ~/mvkt-sync/appsettings.json. What you basically need is to adjust the MavrykNode.Endpoint and ConnectionStrings.DefaultConnection, if needed:
{
"MavrykNode": {
"Endpoint": "https://basenet.rpc.mavryk.network/"
},
"ConnectionStrings": {
"DefaultConnection": "host=localhost;port=5432;database=mvkt_db;username=mvkt;password=qwerty;command timeout=600;"
}
}
Read more about connection string and available parameters.
To avoid reorgs (chain reorganizations) you can set the indexing lag MavrykNode.Lag (1-2 blocks lag is enough):
{
"MavrykNode": {
"Lag": 1
}
}
You can enable/disable Prometheus metrics by setting MetricsOptions.Enabled. By default, they will be available at http://localhost:5001/metrics (protobuf) and http://localhost:5001/metrics-text (plain text):
"MetricsOptions": {
"Enabled": true
}
cd ~/mvkt-sync
dotnet Mvkt.Sync.dll
That's it. If you want to run the indexer as a daemon, take a look at this guide: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-7.0#create-the-service-file.
Suppose, you have already cloned the repo to ~/mvkt during the steps above.
cd ~/mvkt/Mvkt.Api/
dotnet publish -o ~/mvkt-api
Edit the configuration file ~/mvkt-api/appsettings.json. What you basically need is to adjust the ConnectionStrings.DefaultConnection, if needed:
Like this:
{
"ConnectionStrings": {
"DefaultConnection": "host=localhost;port=5432;database=mvkt_db;username=mvkt;password=qwerty;command timeout=600;"
},
}
Read more about connection string and available parameters.
The API has built-in response cache, enabled by default. You can control the cache size limit by setting the ResponseCache.CacheSize (MB), or disable it by setting to 0:
{
"ResponseCache": {
"CacheSize": 1024
}
}
The API provides RPC helpers - endpoints proxied directly to the node RPC, specified in the API settings. The Rpc helpers can be enabled in the RpcHelpers section:
{
"RpcHelpers": {
"Enabled": true,
"Endpoint": "https://basenet.rpc.mavryk.network/"
}
}
Please, notice, the API's RpcHelpers.Endpoint must point to the same network (with the same chain_id) as MavrykNode.Endpoint in the indexer. Otherwise, an exception will be thrown.
You can enable/disable Prometheus metrics by setting MetricsOptions.Enabled. By default, they will be available at http://localhost:5000/metrics (protobuf) and http://localhost:5000/metrics-text (plain text):
"MetricsOptions": {
"Enabled": true
}
By default, the API is available at the port 5000. You can configure it at Kestrel.Endpoints.Http.Url:
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:5000"
}
}
}
cd ~/mvkt-api
dotnet Mvkt.Api.dll
That's it. If you want to run the API as a daemon, take a look at this guide: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-7.0#create-the-service-file.
In general the steps are the same as for the mainnet, you will just need to use a different RPC endpoint and DB snapshot. Here are presets for the current testnets:
First of all, install git, make, docker, docker-compose, then run the following commands:
git clone https://github.com/mavryk-network/mvkt.git
cd mvkt/
make ghost-init # Restores DB from the latest snapshot. Skip it, if you want to index from scratch.
make ghost-start # Starts DB, indexer, and API. By default, the API will be available at http://127.0.0.1:5010.
make ghost-stop # Stops DB, indexer, and API.
Feel free to contact us via:
Cheers! 🍺
Content type
Image
Digest
sha256:1c3106262…
Size
93.2 MB
Last updated
7 months ago
docker pull mavrykdynamics/mvkt-api