https://github.com/slycompiler/torram-btc
https://github.com/slycompiler/torram-btc
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/slycompiler/torram-btc
- Owner: slycompiler
- Created: 2025-01-23T10:28:47.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-23T10:35:29.000Z (over 1 year ago)
- Last Synced: 2025-06-30T20:49:03.202Z (12 months ago)
- Language: Go
- Size: 167 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Torram
Torram is a Cosmos SDK-based blockchain project with a specialized BTC staking module (btcstake).
## Overview
Torram implements a blockchain system that includes functionality for interacting with Bitcoin transactions and staking mechanisms. The project is built using the Cosmos SDK framework and includes custom modules for BTC-related operations.
## Prerequisites
- Go 1.20 or later
- Make
- Docker (optional)
- Git
## Installation
1. Clone the repository:
```
git clone https://github.com/hardworking-toptal-dev/torram-btc.git
cd torram
```
2. Install dependencies:
```bash
make install
```
## Configuration
The project includes a default configuration in `config.yml` with:
- Pre-configured accounts (torram-validator)
- Validator settings
- Initial token distribution
## Running the Node
1. Initialize the chain with default denomination:
```bash
torramd init torram --chain-id torram --default-denom torram
```
2. Create validator key:
```bash
torramd keys add torram-validator --keyring-backend test
```
3. Add genesis account and create validator:
```bash
# Add genesis account
torramd genesis add-genesis-account cosmos15x28edujch4hmlvp343nj44evt7a9w9gftxvpw 1000000000000000torram --keyring-backend test
# Create validator transaction
torramd genesis gentx torram-validator 100000000000torram --chain-id torram --keyring-backend test
# Collect genesis transactions and validate
torramd genesis collect-gentxs
torramd genesis validate-genesis
```
4. Start the chain:
```bash
torramd start --minimum-gas-prices "0.01torram"
```
## Interacting with BTCStake Module
### Query BTC Transactions
1. Fetch BTC transactions for an address:
```bash
torramd tx btcstake fetch-btc-tx \
--btc-address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa \
--from torram-validator \
--chain-id torram \
--gas auto \
--gas-adjustment 1.5 \
--fees 20000torram \
--keyring-backend test \
-y
```
2. Query stored BTC transactions:
```bash
torramd query btcstake get-btc-txs --btc-address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa --output json
```
3. Query transaction details:
```bash
torramd query tx --output json | jq
```
### Direct BlockCypher API Query
For testing purposes, you can query the BlockCypher API directly:
```bash
curl "https://api.blockcypher.com/v1/btc/main/addrs/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?unspentOnly=true"
```
### Reset and Rebuild
If you need to reset the chain and rebuild:
```bash
torramd tendermint unsafe-reset-all
make install
torramd start --minimum-gas-prices "0.01torram"
```
## Features
### BTC Stake Module (btcstake)
#### Project Goal
The btcstake module aims to create a cross-chain staking mechanism where:
- Users can stake Bitcoin to the Torram chain
- Staking records are maintained on both Bitcoin and Torram chains
- Unstaking process is verified and recorded on both chains
- Provides secure and transparent cross-chain staking operations
#### Current Implementation
The btcstake module currently provides:
- Bitcoin transaction verification through BlockCypher API
- Transaction validation and storage on Torram chain
- Query functionality for Bitcoin transactions
- Basic stake address validation
#### Implemented Features
1. Transaction Verification
- Fetches BTC transactions from BlockCypher
- Validates transaction details and confirmations
- Stores verified transactions in Torram chain
2. Query System
- Retrieve stored BTC transactions
- Query transaction details
- Monitor stake address activities
### Current Limitations and TODOs
#### Authentication and Verification Flow
1. Wallet Authentication
- Users must sign their requests with their Bitcoin private key
- Module verifies ownership using public key verification
- Example request:
```bash
torramd tx btcstake verify-and-stake \
--btc-address \
--btc-pubkey \
--signed-data \
--from \
--chain-id torram \
--gas auto \
--fees 20000torram \
--keyring-backend test \
-y
```
2. Transaction Verification Process
- Module decrypts signed data using provided public key
- Validates wallet ownership and signature
- Fetches Bitcoin transactions for the provided address
- Verifies staking transactions to Torram's managed BTC address
- Example verification query:
```bash
torramd query btcstake verify-stake-tx \
--btc-address \
--tx-hash \
--output json
```
3. Token Minting/Distribution
- After verification, mints wrapped BTC tokens (wBTC) or
- Transfers existing staking tokens to user's Cosmos address
- Records stake details including:
- Bitcoin transaction hash
- Stake amount
- Timestamp
- Cosmos recipient address
- Verification signatures