The dogecoin-core-trpc-api
project is a Node.js-based API designed to interact with Dogecoin Core. It uses modern TypeScript tooling and libraries like trpc
for building APIs, zod
for validation, and ky
for HTTP requests. The project is modular and follows best practices for scalability and maintainability.
This API is designed to be private and limited in scope, providing a secure interface to the Dogecoin Core RPC API. It is intended to be accessed exclusively via a Cloudflare Tunnel and paired with a Cloudflare Workers project for seamless and secure access.
- Node.js: JavaScript runtime.
- TypeScript: Better tooling and type safety for JavaScript applications.
- tRPC: End-to-end type-safe APIs made easy.
- Zod: Schema declaration and validation library.
- Ky: A tiny and elegant HTTP client for making requests.
- Cloudflare Tunnel: Securely exposes the API to the Cloudflare network.
- Command:
npm run dev
- Description: Starts the development server with live reloading using
tsx
and environment variables managed bydotenvx
.
- Command:
npm run build
- Description: Compiles the TypeScript code into a production-ready format using
tsup
.
- Command:
npm run start
- Description: Runs the compiled application in production mode.
- Deploy any way you like, for example using
rsync
:
rsync -avz <location-to-project>/dist/ root@<droplet-ip>:~/dogecoin-core-api/
- Description: Deploys the built application to a remote server using
rsync
.
Follow these steps to set up a Digital Ocean server (Ubuntu 25.04, Basic Premium Intel NVMe SSD, 4GB, 2 CPUs) with a 250GB Block Storage volume attached:
sudo apt update && sudo apt upgrade -y
reboot
sudo apt install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git
wget https://github.com/dogecoin/dogecoin/releases/download/v1.14.9/dogecoin-1.14.9-x86_64-linux-gnu.tar.gz
tar -xvzf dogecoin-1.14.9-x86_64-linux-gnu.tar.gz
mv dogecoin-1.14.9/bin/* /usr/local/bin/
mkdir -p ~/.dogecoin
touch ~/.dogecoin/dogecoin.conf
nano ~/.dogecoin/dogecoin.conf
server=1
rpcuser=<your_rpc_username>
rpcpassword=<your_rpc_password>
rpcallowip=127.0.0.1
# Settings
maxconnections=125
datadir=/mnt/<your_volume_name>/dogecoin_data
blocksonly=0
maxuploadtarget=5G
txindex=1
mkdir /mnt/volume_sfo3_01/dogecoin_data
dogecoind -daemon
sudo apt install nodejs npm -y
sudo npm install -g pm2
mkdir ~/dogecoin-core-api
Refer to the build
and publish
sections above for the necessary commands to build and deploy the project.
Set the following environment variables to configure the API:
export RPC_USER=<your_rpc_username>
export RPC_PASSWORD=<your_rpc_password>
export RPC_HOST=<your_dogecoin_node_ip>
Use PM2 to start and manage the API process efficiently:
pm2 start ~/dogecoin-core-api/index.cjs --name "API"
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
cloudflared tunnel login
cloudflared tunnel create dogecoin-core-node-internal-api
nano ~/.cloudflared/config.yml
Configure ~/.cloudflared/config.yml
:
tunnel: dogecoin-core-node-internal-api
credentials-file: /root/.cloudflared/<tunnel-id>.json
ingress:
- hostname: <your-domain.com>
service: http://localhost:3000
- service: http_status:404
cloudflared tunnel run dogecoin-core-node-internal-api
sudo nano /etc/systemd/system/cloudflared-doge.service
[Unit]
Description=Cloudflare Tunnel for Dogecoin Core Node
After=network.target
[Service]
ExecStart=/usr/local/bin/cloudflared tunnel --no-autoupdate run dogecoin-core-node-internal-api
Restart=always
User=root
Environment=HOME=/root
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable cloudflared-doge
sudo systemctl start cloudflared-doge