Skip to content

aleph-im/aleph-indexer-library

Repository files navigation

Aleph Indexer Library

If you want to create an indexer, you're in the right place.

But if you like to contribute to the indexing framework itself, head over to the framework repo

START HERE to create an indexer

There are three way's to create your indexer after you create a new project:

  1. If you have an IDL, use the Anchor Indexer Generator.
  2. Use one of the pre-built, customized indexer examples in the package folder as a starting point.
  3. Build one from scratch.

Building and deploying an indexer

  • Make a fork of this project in your GitHub Workspace.
  • Create a package with your project name's and put it inside /packages directory.
  • Modify the lerna.json file and ensure to add your project to the list.
  • Write your custom indexer code or copy it from another project like the spl-lending indexer in the package folder.
  • Substitute the INDEXER variable inside .github/workflows/main.yml file, changing it to your project's name:
- name: Build and export
  uses: docker/build-push-action@v3
  with:
    context: .
    tags: aleph-framework:latest
    outputs: type=docker,dest=/tmp/aleph-framework.tar
    build-args: |
      INDEXER=XXXXXX
  • Once your indexer code is finished and working, create a PR on GitHub and push it.
  • Label your PR with the deploy tag.
  • The GitHub action will be triggered, and you will be able to download the final root filesystem of your indexer, ready to be pushed to Aleph network.
  • You will find this rootfs file inside Actions -> "Name of your last commit" -> Artifacts -> rootfs.squashfs.
  • Download it, upload this rootfs.squashfs runtime file to IPFS, pin it, and you will be ready to proceed with the deployment.

Deploying with GitHub Actions

Using this method you will need to store you wallet private key's inside GitHub Secrets.

  • Go to repository Secrets tab and add a new one like WALLET_PRIVATE_KEY.
  • Inside .github/workflows/main.yml file, uncomment the last action that is commented and ensure to replace XXXXXX with the IPFS hash of your rootfs.squashfs file uploaded:
- uses: aleph-im/aleph-github-actions/publish-runtime@main
  id: publish-runtime
  with:
    fs_path: ./rootfs.squashfs
    private-key: ${{ secrets.WALLET_PRIVATE_KEY }}
    runtime_hash: XXXXXX
    indexer: spl-lending
  • Pushing this new changes with a PR or a simple commit to the repository, the GitHub action will be triggered.
  • Once the action finishes successfully, inside Actions -> "Name of your last commit" -> Generate runtime job -> Publish runtime step, you will be able to see the VM address:
https://aleph.sh/vm/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Deploying in Local Machine

Requirements

Steps

  • Pin your rootfs.squashfs runtime file hash (that is already uploaded to IPFS) inside Aleph network:
aleph pin RUNTIME_HASH --private-key WALLET_PRIVATE_KEY
  • Download the program files in the current directory through here.
  • Deploy the program inside a persistent VM at Aleph network (changing INDEXER by your indexer name):
aleph program ./program "run.sh INDEXER" --persistent --private-key WALLET_PRIVATE_KEY --runtime RUNTIME_HASH
  • Once command finishes, you will be able to see the VM address:
https://aleph-vm-lab.aleph.cloud/vm/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

About

Solana indexer examples

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published