Dipdup SDK
Let's generate a configuration for the DipDup crawler.
For this tutorial, you will need Poetry(it is a dependency of DipDup). One way to install it is
curl -sSL https://install.python-poetry.org | python3 -
Import KT1 from the blockchain
Start by generating an SDK for the contract in the current directory, with the extra --dipdup
option. If no option is given for the language, the Typescript SDK is generated:
factori import kt1 . KT1Fjiwsmo49yM7jch6KG4ETLFkatF3Qj8of \
--dipdup \
--name my_contract \
--network ghostnet \
--db-name tmp \
--force
Note: if you change the db-name
option, make sure it does not
contain any special characters except _
.
Look at the code
First, you may want to have a look at the content of src/dipdup/src/
directory.
tree src/dipdup/
src/dipdup/
├── dipdup.json
├── dipdup.yml
├── handlers
│ ├── on_my_contract_hello.json
│ ├── on_my_contract_hello.py
│ ├── on_my_contract_new_storage.json
│ ├── on_my_contract_new_storage.py
│ ├── on_my_contract_ping.json
│ └── on_my_contract_ping.py
├── models.json
└── models.py
First, get dipdup as follows:
poetry init --python ">=3.10,<3.11" -n
poetry add dipdup
poetry shell
Factori has generated a configuration file (dipdup.yml
) for you.
This configuration file will make DipDup indexer track every
transactions calling your contract and the big_map changes.
You should copy the ./src/dipdup/dipdup.yml
file
cp src/dipdup/dipdup.yml ./
Check that the field url
in dipdup.yml
is
url: https://api.ghostnet.tzkt.io/
Change it if it isn't.
The next step is:
dipdup init
This will create the python package and its structure in a
tmp
folder.
cp src/dipdup/models.py src/dipdup/handlers/*.py src/tmp/
Then you should be able to run it with:
dipdup run