Skip to content

typicalHuman/rpc-together

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpc-together

A Go backend system that allows users to pay for shared RPC access using EVM deposits. Users can purchase computational units, generate an API key, and use it to access RPC services, with payments handled on-chain.

Features

  • Vault deposits: Users deposit native currency to a vault to fund RPC access.
  • Computational units: Each RPC request consumes units, which are deducted from the vault.
  • API key generation: Unique API keys are issued per user for authenticated RPC usage.
  • Ethereum payments: Users can top up their vault by sending native currency.
  • Shared RPC pool: Multiple users can utilize the same backend RPC while maintaining individual usage accounting.

How it works

  1. Deposit native currency User sends native currency to the vault smart contract.

  2. Buy units Vault converts deposits into computational units for RPC usage.

  3. Generate API key Backend generates a unique key for the user, linked to their deposited balance.

  4. Use RPC User sends requests with API key; each request consumes units.

  5. Top up Users can deposit more native currency anytime to increase their computational units.


Installation

git clone https://github.com/typicalHuman/rpc-together.git
cd rpc-together
go mod tidy
go run main.go

Environment Variables

RPC_URL

RPC endpoint used for paid access

This is the RPC URL that users ultimately access using their API keys. All computational unit (CU) usage is measured against requests sent to this endpoint.

Example:

  • Your own hosted RPC
  • A premium provider endpoint

BASE_CHAIN_RPC_URL

RPC endpoint for the blockchain where the vault contract is deployed

This can be any reliable public or free RPC for the target chain.


VAULT_ADDRESS

Deployed RPCTogetherVault contract address

Must match the chain specified by BASE_CHAIN_RPC_URL.


DB_CONNECTION_STRING

PostgreSQL database connection string

Example format:

postgres://user:password@host:5432/dbname

PLAN_ID

Payment plan identifier from the smart contract

A bytes32 value returned when a payment plan is created on-chain. The backend uses this to associate deposits with a specific RPC pricing plan.

About

Mini-project that allows you to earn profit from unused computational units on your RPC

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages