Skip to content

NearDeFi/bos-gateway-template

Repository files navigation

BOS Gateway Template

This repository contains a clean, light-weight gateawy for the Blockchain Operating System (BOS). It serves as a great starting point for launching a customized BOS gateway. Contributions are most welcome!

Setup & Development

  1. Initialize repo:

    pnpm i
  2. Add .env file:

    cp .env.example .env
  3. The entry component is BosMain and it's located at /src/components/index.tsx

    It loads the ciocan.near/widget/hello-world BOS component. The source can be found here.

  4. Edit web3.js and change the projectId and dappUrl for WalletConnect (dappUrl is required by WalletConnect to work with the MetaMask on mobile)

Start development version:

pnpm dev:next

Deployment

This is a Next.js app and a fork of NEAR Discovery gateway app.

For static exports just run next build and upload the build files to your hosting provider. More info here.

For Vercel, Cloudflare or others that supports a Next app just connect the repo and follow the deploy steps from the dashboards.

More info on Next.js deployments here.

Running with docker

docker build -t bos-gateway-template .
docker run -p 3000:3000 bos-gateway-template

Building the native apps

We use Tauri to build the native apps.

Prerequisites

The first step is to install Rust and system dependencies. More info here here.

Building

Edit the src-tauri/tauri.conf.json file and change:

  • productName from BOS Gateway Template to your gateway name.
  • identifier from com.bos-gateway-template to your gateway identifier.
  • icon array to your gateway icons.
  • windows.title from BOS Gateway Template to your gateway name.

For the macOS app you need to have a valid Apple Developer account and a valid certificate. Set these env variables to configure the build:

export APPLE_ID=your-apple-id
export APPLE_PASSWORD=your-apple-password
export APPLE_CERTIFICATE=your-apple-certificate
export APPLE_CERTIFICATE_PASSWORD=your-apple-certificate-password
export APPLE_DEVELOPER_TEAM_NAME=your-apple-developer-team-name
export APPLE_SIGNING_IDENTITY=your-apple-developer-code-sign-identity

More info here about the Apple code signing: here.

Optionally if you want to use the Tauri updater you need to set the TAURI_PRIVATE_KEY and TAURI_KEY_PASSWORD env variable. More info here: here.

Then run:

pnpm build

The native app will be located in src-tauri/target/release/bundle.

Note: Tauri relies heavily on native libraries and toolchains, so meaningful cross-compilation is not possible at the current moment. The next best option is to compile utilizing a CI/CD pipeline More info here.

To distribute the native app you need Code Signing for specific platforms. More info here.

Publish the release files

Run this action to publish the release files to GitHub: .github/workflows/publish.yml