├── .dockerignore ├── .github └── workflows │ ├── build-everyday.yml │ ├── build-image.yml │ ├── build-on-push.yml │ └── release-version.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── bin └── my_init ├── docker-compose.dev.yml ├── docker-compose.yml └── patches └── .gitkeep /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !bin/my_init 3 | !patches/ 4 | -------------------------------------------------------------------------------- /.github/workflows/build-everyday.yml: -------------------------------------------------------------------------------- 1 | name: Build Every Day 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | 7 | jobs: 8 | build-latest: 9 | permissions: 10 | contents: read 11 | id-token: write 12 | uses: ./.github/workflows/build-image.yml 13 | with: 14 | image-version: latest 15 | secrets: inherit 16 | build-develop: 17 | permissions: 18 | contents: read 19 | id-token: write 20 | uses: ./.github/workflows/build-image.yml 21 | with: 22 | image-version: develop 23 | electrumx-version: develop 24 | secrets: inherit 25 | -------------------------------------------------------------------------------- /.github/workflows/build-image.yml: -------------------------------------------------------------------------------- 1 | name: Build Image 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | image-version: 7 | required: true 8 | type: string 9 | description: "The version of the image to build" 10 | electrumx-version: 11 | required: false 12 | type: string 13 | default: "master" 14 | 15 | jobs: 16 | build: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Set up QEMU 21 | uses: docker/setup-qemu-action@v3 22 | - name: Set up Docker Buildx 23 | uses: docker/setup-buildx-action@v3 24 | - name: Login to Docker Hub 25 | uses: docker/login-action@v3 26 | with: 27 | username: ${{ secrets.DOCKERHUB_USERNAME }} 28 | password: ${{ secrets.DOCKERHUB_TOKEN }} 29 | - name: Build and push Docker images 30 | # You may pin to the exact commit or the version. 31 | # uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 32 | uses: docker/build-push-action@v5.0.0 33 | with: 34 | # List of external cache sources for buildx (e.g., user/app:cache, type=local,src=path/to/dir) 35 | cache-from: type=gha # optional 36 | # List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir) 37 | cache-to: type=gha,mode=max # optional 38 | # Build's context is the set of files located in the specified PATH or URL 39 | context: . # optional 40 | # List of target platforms for build 41 | platforms: linux/amd64,linux/arm64 # optional 42 | # Push is a shorthand for --output=type=registry 43 | push: true # optional, default is false 44 | build-args: | 45 | VERSION=${{ inputs.electrumx-version }} 46 | # List of tags 47 | tags: lucky2077/atomicals-electrumx:${{ inputs.image-version }} 48 | -------------------------------------------------------------------------------- /.github/workflows/build-on-push.yml: -------------------------------------------------------------------------------- 1 | name: Build on Push 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | 7 | jobs: 8 | build: 9 | permissions: 10 | contents: read 11 | id-token: write 12 | uses: ./.github/workflows/build-image.yml 13 | with: 14 | image-version: latest 15 | secrets: inherit 16 | -------------------------------------------------------------------------------- /.github/workflows/release-version.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | electrumx-version: 7 | description: "ElectrumX Version, eg: v1.2.1" 8 | required: true 9 | image-version: 10 | description: "The version of the image to build" 11 | jobs: 12 | build: 13 | permissions: 14 | contents: read 15 | id-token: write 16 | uses: ./.github/workflows/build-image.yml 17 | with: 18 | # if image-version is not provided, it will default to electrumx-version 19 | image-version: ${{ inputs.image-version || inputs.electrumx-version }} 20 | electrumx-version: ${{ inputs.electrumx-version }} 21 | secrets: inherit 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | data/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.5-labs 2 | 3 | FROM python:3.10-alpine3.16 4 | 5 | ARG VERSION=master 6 | ADD https://github.com/atomicals/atomicals-electrumx.git#${VERSION} /electrumx 7 | 8 | WORKDIR /electrumx 9 | COPY patches patches 10 | 11 | RUN set -ex && \ 12 | apk add --no-cache build-base git openssl leveldb-dev && \ 13 | pip install .[ujson,uvloop,crypto] && \ 14 | apk del build-base git 15 | 16 | VOLUME ["/data"] 17 | 18 | ENV HOME /data 19 | ENV ALLOW_ROOT 1 20 | ENV EVENT_LOOP_POLICY uvloop 21 | ENV DB_DIRECTORY /data 22 | ENV COIN=BitCoin 23 | ENV SERVICES=tcp://0.0.0.0:50001,ws://0.0.0.0:50002,rpc://0.0.0.0:8000,http://0.0.0.0:8080 24 | ENV HOST "" 25 | ENV CACHE_MB=2000 26 | ENV MAX_SEND=3000000 27 | ENV COST_SOFT_LIMIT=100000 28 | ENV COST_HARD_LIMIT=1000000 29 | 30 | COPY ./bin /usr/local/bin 31 | 32 | EXPOSE 50001 50002 8000 8080 33 | 34 | HEALTHCHECK --start-period=180s --retries=5760 \ 35 | CMD netstat -ltn | grep -c ":8080" > /dev/null; if [ 0 != $? ]; then exit 1; fi; 36 | 37 | CMD ["my_init"] 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joyent, Inc. 4 | Copyright (c) 2015 Node.js contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Atomicals ElectrumX Docker 2 | 3 | Aims to provide a simple and easy way to run [atomicals-electrumx](https://github.com/atomicals/atomicals-electrumx) server. 4 | 5 | ## Requirements 6 | 7 | ### 1. Bitcoin Full Node with `txindex=1` and enable rpc. A example of `bitcoin.conf`: 8 | 9 | ```ini 10 | server=1 11 | txindex=1 12 | 13 | # genearate with [rpcauth.py](https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py) 14 | # equals to `rpcuser=nextdao` and `rpcpassword=nextdao` 15 | rpcauth=nextdao:cca838b4b19bdc6093f4e0312550361c$213834a29e8488804946c196781059a7ee0ac2b48dbf896b4c6852060d9d83dd 16 | 17 | rpcallowip=127.0.0.1 18 | rpcallowip=172.0.0.0/8 19 | rpcallowip=192.168.0.0/16 20 | 21 | rpcbind=0.0.0.0 22 | ``` 23 | ### 2. Install Docker with docker-compose. 24 | 25 | ### 3. At least **110G** left in your storage. 26 | 27 | ## Usage 28 | 29 | ### 1. Download [docker-compose.yml](https://github.com/Next-DAO/atomicals-electrumx-docker/raw/main/docker-compose.yml) to a folder. 30 | 31 | Edit `docker-compose.yml`: 32 | 33 | - Change `127.0.0.1` to `lan ip` of the bitcoin core host, eg: 192.168.50.2. 34 | - Also change `nextdao:nextdao` to your `rpcuser:rpcpassword` in `bitcoin.conf 35 | 36 | ### 2. Run the RPC server: 37 | 38 | ```bash 39 | docker-compose pull && docker-compose up -d 40 | ``` 41 | 42 | - the electrumx indexes stored in `./electrumx-data` directory. 43 | - use `docker-compose logs -f` to check the logs. 44 | - use `docker-compose down` to stop the server. 45 | 46 | ### 3. Used in [atomicals-js](https://github.com/atomicals/atomicals-js) 47 | 48 | Edit .env with `ELECTRUMX_PROXY_BASE_URL=http://localhost:8080/proxy`, then use all commands as usual. 49 | 50 | If you run atomicals cli in anthoer host, change `localhost` to the `ip` of the `proxy` server. 51 | 52 | ## FAQ 53 | 54 | ### 1. How to check if the server is ready? 55 | 56 | ```bash 57 | docker-compose ps 58 | ``` 59 | 60 | If you see `electrumx` is `healthy`, then the server is ready. 61 | 62 | ### 2. ERROR:Daemon:connection problem - check your daemon is running. Retrying occasionally... 63 | 64 | 1. Check if bitcoind is running. 65 | 2. Check if `rpcbind` include the `ip` used in `DAEMON_URL` 66 | 67 | ### 3. ERROR:Daemon:daemon service refused: Forbidden. Retrying occasionally... 68 | 69 | 1. Run `docker-compose ps` to check your container name. eg: `electrumx-electrumx-1` 70 | 2. Run `docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' electrumx-electrumx-1` to get container ip 71 | 3. Check if the ip in rpcallow range 72 | 73 | ### 4. ERROR:Daemon:daemon service refused: Unauthorize. Retrying occasionally... 74 | 75 | Check if rpc username and password correct? 76 | 77 | ### 5. Why the sync is so slow? 78 | 79 | There are many reasons that may cause the sync slow. 80 | 81 | 1. The `bitcoind` is not fully synced. 82 | 2. You are using a HDD instead of SSD. 83 | 3. Your CPU single core performance is not good enough. 84 | 4. You are runing docker on windows or macos. 85 | -------------------------------------------------------------------------------- /bin/my_init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec /electrumx/electrumx_server 4 | -------------------------------------------------------------------------------- /docker-compose.dev.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | electrumx: 4 | build: . 5 | restart: always 6 | ports: 7 | - 50001:50001 8 | - 50002:50002 9 | - 8000:8000 10 | - 8080:8080 11 | volumes: 12 | - ./electrumx-data-dev:/data 13 | environment: 14 | - DAEMON_URL=nextdao:nextdao@127.0.0.1:8332 15 | - COIN=BitCoin 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | electrumx: 4 | image: lucky2077/atomicals-electrumx:v1.5.1.0 5 | restart: always 6 | ports: 7 | - 50001:50001 8 | - 50002:50002 9 | - 8000:8000 10 | - 8080:8080 11 | volumes: 12 | - ./electrumx-data:/data 13 | environment: 14 | - DAEMON_URL=nextdao:nextdao@127.0.0.1:8332 15 | - COIN=BitCoin 16 | -------------------------------------------------------------------------------- /patches/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Next-DAO/atomicals-electrumx-docker/ed269785702dc2d0c93cf11268088d6584f4ab0e/patches/.gitkeep --------------------------------------------------------------------------------