Skip to content

Genobank/api-base.genobank.py

Repository files navigation

Smart Contracts Deployment & API Setup

This guide explains how to install, configure and run the API (including smart contract deployment) on your local machine. All steps assume Python 3.8 (ideally 3.8.10) and use virtualenv.


📋 Prerequisites

  • Python 3.8 (e.g. 3.8.10) installed on your system
  • virtualenv package (pip install virtualenv)
  • Internet access to your RPC provider (e.g. Avalanche Fuji via Infura)
  • A wallet private key with sufficient test-net funds

1. Create & Activate a Virtual Environment

cd /path/to/your/project
virtualenv -p python3.8 venv
source venv/bin/activate

2. Configure settings.py

Open setup/settings.py and uncomment & fill in the values marked below. In particular, make sure your executor wallet private key has enough funds on the target network.

class settings:
    # ─── Web3 / Blockchain ────────────────────────────────
    # PROVIDER = "<YOUR_INFURA_OR_RPC_PROVIDER_URL>"
    # EXECUTOR_PRIVATE_KEY = "<YOUR_EXECUTOR_WALLET_PRIVATE_KEY>" 
    #   # Must have sufficient funds on the network.

    # ─── Contract constructor parameters ──────────────────
    BPT_NAME      = "Biosample Permission Token"
    BPT_SYMBOL    = "BPT"
    BPT_NAMESPACE = "io.genobank.test"

    XBPT_NAME   = "Extended Biosample Permission Token"
    XBPT_SYMBOL = "XBPT"

    BIOSAMPLE_URI = "https://genobank.io/"

    USDNA_CONTRACT = "0xB973E2B66f925bFA8206FEF61A1d89D2A664Cd23"

    # ─── .env generation control ──────────────────────────
    OUTPUT_ENV_FILE_NAME    = "generated.env"
    COPY_ENV_TO_PROJECT_ROOT = True

    # ─── Paths to compiled ABI JSONs (relative to setup/) ─
    ABI_BPT_PATH             = "../smart_contract/biosample-permission-token.json"
    ABI_XBPT_PATH            = "../smart_contract/extended_biosample_permission_token/extended_biosample_permission_token.json"
    ABI_BIOSAMPLE_PATH       = "../smart_contract/Biosample.json"
    ABI_POSP_PATH            = "../smart_contract/posp.json"
    ABI_POSP_FACTORY_PATH    = "../smart_contract/posp_factory.json"
    ABI_DELIVER_MANAGER_PATH = "../smart_contract/DeliverManager.json"

Note: The lines starting with # must be uncommented and replaced with your own values.


3. Run the Installation Script

From the setup/ folder:

cd setup
chmod +x install.sh
./install.sh

This script will:

  1. Generate generated.env with boilerplate entries
  2. Deploy all smart contracts in sequence
  3. Update generated.env with the deployed contract addresses (quoted)
  4. Copy generated.env to the project root as .env (if enabled)

4. Finalize Your .env

Open the newly created .env file in your project root and fill in any remaining placeholders:

# ─── Signing messages ───────────────────────────────────
MESSAGE=<YOUR_MESSAGE_TO_RECOVER_USER_WALLET>
NEW_MESSAGE=<YOUR_MESSAGE_TO_DOWNLOAD_USER_FILE>
ROOT_MESSAGE=<YOUR_ROOT_MESSAGE_TO_SIGN>

# ─── Buckets configuration ─────────────────────────────
BUCKET_PATH=<STORAGE_ENVIRONMENT>
BUCKET_ACCESS_KEY_ID=<YOUR_BUCKET_ACCESS_KEY_ID>
BUCKET_SECRET_ACCESS_KEY_ID=<YOUR_BUCKET_SECRET_ACCESS_KEY_ID>
BUCKET_NAME=<YOUR_BUCKET_NAME>

# ─── API & Database ────────────────────────────────────
API_BASE="https://api-test.genobank.io"
MONGO_DB_HOST=<YOUR_MONGODB_CONNECTION_STRING>
DB_NAME=<YOUR_DATABASE_NAME>

# ─── Root wallet (admin tasks) ────────────────────────
ROOT_GENOBANK=<YOUR_ROOT_WALLET_PRIVATE_KEY>
ROOT_GENOBANK_WALLET=<YOUR_ROOT_WALLET_PUBLIC_ADDRESS>

# ─── Third-party API keys ──────────────────────────────
MAGIC_API_KEY=<YOUR_MAGIC_AUTH_API_KEY>

Save and close the file when you’re done.


5. Run the API

From the project root, start the API with:

python3 start.py

Your API (and connected smart contracts) should now be running locally.


🎉 All set! You’ve configured your environment, deployed smart contracts, and launched the API.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors