Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

simonbetton/dogecoin-core-trpc-api

Open more actions menu

Repository files navigation

🐕 Dogecoin Core tRPC API

🌟 Project Description

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.

🛠️ Tech Stack

  • 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.

🛠️ Setup Commands

🔧 Development Mode

  • Command: npm run dev
  • Description: Starts the development server with live reloading using tsx and environment variables managed by dotenvx.

🏗️ Build

  • Command: npm run build
  • Description: Compiles the TypeScript code into a production-ready format using tsup.

🚀 Start

  • Command: npm run start
  • Description: Runs the compiled application in production mode.

📦 Publish

  • 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.

🌐 Digital Ocean Server Setup

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:

⚙️ Initial Setup

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

📝 Dogecoin Configuration File

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

🚀 Start Dogecoin Daemon

mkdir /mnt/volume_sfo3_01/dogecoin_data
dogecoind -daemon

📦 Install Node.js and PM2

sudo apt install nodejs npm -y
sudo npm install -g pm2
mkdir ~/dogecoin-core-api

🏗️ Build the Project and Deploy

Refer to the build and publish sections above for the necessary commands to build and deploy the project.

🌐 Set API Environment Variables

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>

🚀 Start the API

Use PM2 to start and manage the API process efficiently:

pm2 start ~/dogecoin-core-api/index.cjs --name "API"

☁️ Cloudflare Tunnel Setup

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

🛠️ Cloudflare Tunnel Configuration

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

✅ Confirm the Tunnel Works

cloudflared tunnel run dogecoin-core-node-internal-api

🔄 Systemd Service Configuration

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

🔧 Enable and Start the Cloudflare Tunnel Service

sudo systemctl daemon-reload
sudo systemctl enable cloudflared-doge
sudo systemctl start cloudflared-doge

About

Dogecoin Core tRPC API is a subset API wrapper for the Dogecoin Core RPC API

Topics

Resources

License

Stars

Watchers

Forks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.