Skip to content

mega123-art/FileUploadingOnSOLANA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Solana Inscription File Sharing System

Store files on Solana for 1,000x less cost than traditional methods

A revolutionary file storage system that leverages Solana's transaction ledger for permanent, cost-effective file storage. Store data in transaction history instead of expensive on-chain accounts.

License: MIT Solana TypeScript Rust


๐Ÿ’ฐ The Big Win: 99.9% Cost Savings

Traditional Solana Storage:    0.1007 SOL for 14 KB (~$20)
Inscription Method (Ours):     0.0001 SOL for 14 KB (~$0.02)

YOU SAVE: 1,000x cheaper! ๐ŸŽ‰

โœจ What Makes This Special

๐Ÿš€ Ultra Cheap - 1,000x cheaper than traditional storage
โšก Fast Parallel Uploads - Concurrent transaction submission
๐Ÿ”’ Permanent - Stored in immutable Solana ledger
โœ… Verifiable - SHA-256 integrity checking
๐Ÿ”‘ Simple - One PDA address = One file
๐Ÿ› ๏ธ Production Ready - Complete CLI + documentation


๐ŸŽฏ Quick Start (3 Minutes)

1. Install

cd solana-inscription-system/cli
npm install && npm run build && npm link

2. Configure

solana config set --url devnet
solana airdrop 2

3. Upload Your First File

echo "Hello Solana!" > test.txt
sol-inscribe upload -f test.txt -c devnet

Output:

โœ… Upload complete!
  File PDA: 8Kp2wXxYqF7zM9nC5vR4tB3sA6hD2fE1...

That's it! Your file is now permanently on Solana. ๐ŸŽ‰


๐Ÿ“– Commands

Upload a File

sol-inscribe upload --file myfile.pdf --cluster devnet

Download a File

sol-inscribe read --pda <YOUR_PDA> --output recovered.pdf --cluster devnet

Close & Get Refund

sol-inscribe close --pda <YOUR_PDA> --cluster devnet

Get File Info

sol-inscribe info --file myfile.pdf

๐Ÿ”ฌ How It Works

Your File (14 KB)
    โ†“
Split into 18 chunks (800 bytes each)
    โ†“
Calculate SHA-256 hash
    โ†“
Create tiny PDA (76 bytes) - Stores metadata only
    โ†“
Send 18 transactions with chunk data
    โ†“
Data stored PERMANENTLY in Solana's transaction history
    โ†“
Close PDA, get rent refund
    โ†“
Net cost: 0.0001 SOL! ๐ŸŽ‰

Why So Cheap?

Traditional Method:

  • Stores data in on-chain accounts
  • Must pay rent to keep data alive
  • Rent = file_size ร— rate ร— time
  • Expensive! ๐Ÿ’ธ

Our Inscription Method:

  • Stores data in transaction instruction data
  • Transaction data is permanent (part of ledger)
  • Only pay tiny PDA rent (refundable!)
  • Only pay transaction fees (tiny!)
  • Super cheap! ๐Ÿš€

๐Ÿ’ฐ Cost Breakdown

For a 14 KB File:

Component Cost Refundable?
PDA Creation 0.00142 SOL โœ… Yes
18 Chunk Transactions 0.00009 SOL โŒ No
Init + Close TXs 0.00001 SOL โŒ No
Net Cost 0.0001 SOL

Real Money (at $200/SOL):

  • Traditional: $20.14
  • Inscription: $0.02
  • You save: $20.12 ๐ŸŽŠ

Scaling:

File Size Traditional Inscription Savings
14 KB 0.1007 SOL 0.0001 SOL 99.9%
100 KB 0.7144 SOL 0.0007 SOL 99.9%
1 MB 7.2589 SOL 0.0070 SOL 99.9%
10 MB 72.5888 SOL 0.0700 SOL 99.9%

๐Ÿ—๏ธ Architecture

Smart Contract (Rust/Anchor)

Program ID: BkkGGd4ccFd6ypmrCLsKU64EhT3gKCqgYAYoLECVwFAg

3 Instructions:

  1. initialize_session - Create file session
  2. inscribe_chunk - Store chunk data
  3. close_session - Close and refund

Account (76 bytes):

pub struct FileSession {
    owner: Pubkey,           // Who owns this file
    file_hash: [u8; 32],     // SHA-256 for verification
    total_chunks: u16,       // How many chunks
    chunks_inscribed: u16,   // Progress tracker
}

CLI Tool (TypeScript)

Features:

  • File chunking (800 bytes per chunk)
  • SHA-256 hashing
  • Parallel transaction submission
  • Integrity verification
  • Progress indicators
  • Error handling

๐Ÿ“š Use Cases

โœ… Perfect For:

  • NFT Metadata - Permanent metadata storage
  • Documents - Certificates, diplomas, contracts
  • Archives - Historical records, logs
  • Configuration Files - App configs, parameters
  • Code Storage - Smart contract source code
  • Small Files - Up to 10 MB efficiently

โŒ Not For:

  • Very large files (>100 MB) - too many TXs
  • Frequently updated content
  • Real-time streaming
  • Private/encrypted data (everything is public)

๐ŸŽฏ Examples

Basic Usage

# Upload
sol-inscribe upload -f document.pdf -c devnet

# Download
sol-inscribe read -p <PDA> -o recovered.pdf -c devnet

# Verify
diff document.pdf recovered.pdf  # Should be identical!

Batch Upload

for file in *.txt; do
  sol-inscribe upload -f "$file" -c devnet
done

Integration (TypeScript)

import { uploadFile } from 'sol-inscribe';

const pda = await uploadFile({
  filePath: 'data.json',
  cluster: 'mainnet-beta',
  batchSize: 20
});

console.log(`File stored at: ${pda}`);

๐Ÿ› ๏ธ Development

Project Structure

solana-inscription-system/
โ”œโ”€โ”€ programs/file-inscription/    # Rust smart contract
โ”œโ”€โ”€ cli/                           # TypeScript CLI tool
โ”œโ”€โ”€ target/idl/                    # Program interface
โ””โ”€โ”€ docs/                          # Documentation

Build from Source

# Smart contract
cd programs/file-inscription
cargo build-bpf

# CLI
cd cli
npm install
npm run build

โšก Performance

Benchmarks (Devnet, batch-size=10):

File Size Upload Time Cost
10 KB ~10s 0.0001 SOL
100 KB ~60s 0.0007 SOL
1 MB ~10min 0.0070 SOL

Optimization Tips:

# Faster uploads
sol-inscribe upload -f large.pdf --batch-size 50

# Use mainnet RPC for better speed
sol-inscribe upload -f data.json --cluster https://your-rpc.com

โš ๏ธ Important Notes

Security

  • โœ… Owner-only operations
  • โœ… Cryptographic verification
  • โœ… Immutable data
  • โš ๏ธ All data is public
  • โš ๏ธ No built-in encryption

Limitations

  • Max chunk: 800 bytes
  • Many TXs for large files
  • Retrieval requires TX history query
  • Data is permanent (cannot delete)

Best Practices

  1. Test on devnet first
  2. Save all PDA addresses
  3. Close sessions to reclaim rent
  4. Verify downloads
  5. Monitor SOL balance

๐Ÿ“Š Stats

  • Cost Savings: 1,000x cheaper
  • Program ID: BkkGGd4ccFd6ypmrCLsKU64EhT3gKCqgYAYoLECVwFAg
  • Chunk Size: 800 bytes max
  • PDA Size: 76 bytes only
  • Max File Size: Unlimited (practically <10 MB)

๐Ÿค Contributing

Contributions welcome! Feel free to:

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ“– Improve docs
  • ๐Ÿ”ง Submit PRs

๐Ÿ“„ License

MIT License - see LICENSE file


๐Ÿ—บ๏ธ Roadmap

v1.0 (Current)

  • โœ… Core inscription functionality
  • โœ… CLI tool
  • โœ… Documentation

v1.1 (Soon)

  • ๐Ÿ”„ Compression support
  • ๐Ÿ”„ Web interface
  • ๐Ÿ”„ Resume uploads

v2.0 (Future)

  • ๐Ÿ”ฎ Encryption layer
  • ๐Ÿ”ฎ Access control
  • ๐Ÿ”ฎ Search functionality

๐ŸŽ‰ You're Ready to Go!

sol-inscribe upload -f myfile.pdf -c devnet

Save 99.9% on storage costs today! ๐Ÿš€


Full Documentation โ€ข Examples โ€ข Cost Analysis

Built with โค๏ธ on Solana

โญ Star us on GitHub!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors