Create an open-source faucet service offering small amounts of digital tokens for testing purposes on the BSV Blockchain. This service aids developers and testers in their work without requiring them to acquire real digital currencies. It's applicable to non-production environments such as testnet.
A testnet faucet provides users with free testnet tokens for testing and development. This allows developers to test their applications and smart contracts before deploying them to the main network.
Bitcoin SV (BSV) is a blockchain that aims to maintain the original vision of Bitcoin, focusing on scalability, security, and stability. This list gathers various resources to help you explore, develop, and contribute to the BSV ecosystem.
-
Open Standards for industry collaboration
-
BSV Wiki – Aim to provide correct and up-to-date information on the Bitcoin protocol, network, and its features and functionality.
-
Paymail – A collection of protocols for BSV blockchain wallets that allow for a set of simplified user experiences to be delivered across all wallets in the ecosystem.
- Official BSV SDK maintained by the BSV Association with zero dependencies.
- Bitcoin SV Lib - A pure and powerful JavaScript Bitcoin SV library. A fork of BitPay's bitcore-lib-cash, but for Bitcoin SV only. Maintained by Yours Inc.
- Framework - Next.js (App Router)
- Language - TypeScript
- Auth - Auth.js
- Database - Postgres
- Deployment - Vercel
- Styling - Tailwind CSS
- Components - Shadcn UI
- Analytics - Vercel Analytics
- Formatting - Prettier
This uses the new Next.js App Router. This includes support for enhanced layouts, colocation of components, tests, and styles, component-level data fetching, and more.
To successfully finish this guide, you'll need:
- Node.js
- A Vercel Account (to set up a free Postgres database and deploy the app)
- A GitHub Account (to create an OAuth app)
During the deployment, Vercel will prompt you to create a new Postgres database. This will add the necessary environment variables to your project.
Inside the Vercel Postgres dashboard, create a table based on the schema defined in this repository.
CREATE TYPE status AS ENUM ('active', 'inactive', 'archived');
CREATE TABLE products (
id SERIAL PRIMARY KEY,
image_url TEXT NOT NULL,
name TEXT NOT NULL,
status status NOT NULL,
price NUMERIC(10, 2) NOT NULL,
stock INTEGER NOT NULL,
available_at TIMESTAMP NOT NULL
);
Then, uncomment app/api/seed.ts and hit http://localhost:3000/api/seed to seed the database with products.
Next, copy the .env.example file to .env and update the values. Follow the instructions in the .env.example file to set up your GitHub OAuth application.
npm i -g vercel
vercel link
vercel env pull
Finally, run the following commands to start the development server:
pnpm install
pnpm dev
You'll need the the following BSV Libraries:
npm i @bsv/sdk
npm i @bsv/paymail
You should now be able to access the application at http://localhost:3000.
Maintaining a consistent PostgreSQL database schema is crucial for collaboration among all contributors.
This section outlines the process for managing schema changes, creating migration scripts, and ensuring everyone is on the same page.
Use a migration tool Knex.js
To create a migration script, run the following command in your terminal:
bash
npx knex migrate:make <migration_name>
Replace <migration_name> with a descriptive name reflecting the changes being made (e.g., create_users_table).
Open the newly created migration file in the migrations directory. You’ll find two functions: up and down. In the up function, add the SQL commands to create or modify tables. In the down function, add commands to revert these changes. For example:
exports.up = function(knex) {
return knex.schema.createTable('users', function(table) {
table.increments('id').primary();
table.string('name');
table.string('email').unique();
table.timestamps(true, true);
});
};
exports.down = function(knex) {
return knex.schema.dropTable('users');
};
Before pushing changes, run your migration scripts locally to ensure they work as expected. Use the following command: bash
npx knex migrate:latest
This will apply all pending migrations to your local database. You can revert changes using:
bash
npx knex migrate:rollback
After testing your migration scripts, create a pull request (PR) in the repository: Include a concise description of the schema changes. List the migration scripts included in the PR. Reference any discussions related to your changes. Tag other contributors for review.
Once the PR is approved, merge the changes into the main branch. After merging, make sure to run the migration scripts on the shared development database hosted on Vercel. Applying Migrations in Vercel
After merging your PR, ensure that the migration scripts are executed on the Vercel DB. You can run migrations by adding a script in your package.json:
Copy code
"scripts": {
"migrate": "knex migrate:latest --env production"
}
Run the migration command on Vercel using:
bash
Copy code
npm run migrate
Update the README or project wiki to reflect any changes to the schema, including new tables, fields, or relationships.