Start a search engine (Docker)
Start a smart contract search engine for your own DApp
This documentation details how you can start, and host, your own smart contract search engine using Docker. If you would like to build from scratch from a fresh Ubuntu install, please refer to this document.
Prerequisite
We start from a fresh install of Ubuntu 18.04. You should first follow the instructions here to install Docker.
Next install the Python pip and AWS CLI utilities as follows. The AWS CLI is required to access AWS ElasticSearch services.
ElasticSearch
We use the AWS ElasticSearch services to run the search engine. You should create a new ES cluster here. For now, a single machine development cluster would suffice. In the Access Policy section, please select IAM users. You will need an IAM user already set up to access AWS ES services. Here is an example.
Once the ElasticSearch service is up and running, you should have an ES endpoint like the following.
Docker
Now, go back to the Ubuntu 18.04 machine.
AWS credentials
Configure AWS CLI to access the ElasticSearch engine.
It requires four pieces of information. The access keys are found in the IAM user console for the user you configured to access the ElasticSearch engine you just created.
After configuration, AWS config and credentials are placed in ~/.aws/
.
Configure search engine
Next, get the source code for the search engine.
Fill in the following configuration options.
ServerName
in apache configconfig/site.conf
. This could be your public IP address for now.blockchain
,elasticsearch
, and the initial ABI configs inpython/config.ini
.publicIp
injs/secondStateJS.js
. This could be your IP address for now.Check here for details about configurations.
Build Docker image
Run Docker container
If the above command failed because the host port 80 is already taken, try the following command sudo apachectl stop
to stop the host apache server.
Now you can visit http://<your_host>
to check your smart contract search engine. Be patient, as it may take hours before the results show up on that page.
Upload more ABIs
Your search engine is started with a single ABI to index from the config.ini
file. You can add more ABIs to the index by executing the following script from inside the Docker instance.
You can find the container_id
for your docker instance on your host OS, by running
Next, logging into your docker container using the container_id
Once logged, in the /app
directory, create a file upload_abi.py
like the following.
Then run
Also once all of this is done, please just exit docker and give it a reboot.
Last updated