Skip to content

HarK-github/AuthrNet

Repository files navigation

AuthrNet

Decentralized Article Publishing & Access Control Platform

https://authr-net.vercel.app/


Next.js Ethereum IPFS Deployment
Progress
License


Table of Contents


Features

  • Web3 authentication with Wagmi and MetaMask
  • Article publishing with IPFS (Pinata)
  • Premium access with Wallet-based unlocking
  • Profile & dashboard for authored and purchased articles
  • Modern UI & responsive design
  • Solidity-powered smart Contract

Tech Stack

  • Frontend: Next.js 14, TypeScript, TailwindCSS, ShadCN UI
  • Blockchain: Solidity, Wagmi, viem
  • Storage: IPFS (Pinata)
  • Other: React Query, Lucide Icons

Installation

1. Clone & Install

git clone https://github.com/yourusername/authrnet.git
cd authrnet

# Install dependencies
npm install

2. Configure Environment

Create .env.local in the root:

AUTH_SECRET=

# Pinata API keys
NEXT_PUBLIC_PINATA_API_KEY=
NEXT_PUBLIC_PINATA_SECRET_API_KEY=

# Deployed smart contract address
NEXT_PUBLIC_CONTRACT_ADDRESS=

3. Run

# Development
npm run dev

# Build for production
npm run build

# Start production server
npm start

Project Structure

AuthrNet/
├── app/             # Next.js app pages & APIs
├── components/      # Reusable UI components
├── contracts/       # Solidity contracts & ABIs
├── lib/             # Helpers / configs
├── public/          # Static assets
├── .env             # Env variables
├── package.json     # Scripts & deps
└── tsconfig.json    # TypeScript config

File Structure (Detailed)

App (./app)

app/
├── api
│   └── auth/ipfs/[hash]/route.ts   # Fetch IPFS content
├── auth.config.ts                  # Auth settings
├── components/
│   ├── connected.tsx               # Wallet view
│   ├── navbar_tp.tsx               # Navigation bar
│   ├── profile.tsx                 # User profile
│   └── wallet-options.tsx          # Wallet connect UI
├── config.ts                       # Wagmi / chain config
├── layout.tsx                      # Root layout
├── page.tsx                        # Landing page
├── publish/page.tsx                # Publish article page
├── read/[id]/page.tsx              # Read article page
├── support/page.tsx                # Support page
└── utils/
    ├── articleRegistry.ts
    ├── contractHelpers.ts
    ├── deployArticle.ts
    ├── readArticle.ts
    ├── supportArticle.ts
    └── uploadToPinata.ts

Contracts (./contracts)

contracts/
└── abis
    ├── ArticleRegistry.json     # ABI
    └── ArticleRegistry.sol      # Solidity source
Function / Feature Description Access / Notes
publishArticle Publishes a new article with title, IPFS hash, and price. Any user can call. Publisher gets automatic access.
grantAccess Grants access to a specific user for an article. Only contract owner or article publisher. Emits AccessGranted.
purchaseAccess Allows users to pay for access to a paywalled article. Any user can call. Funds are sent to publisher. Emits ArticlePurchased.
checkAccess Checks if a user has access to a given article. Public view function.
getArticle Returns article metadata and IPFS hash (if user has access). Access-controlled. Returns empty IPFS hash if no permission.
getArticles Returns arrays of all articles, with IPFS hashes filtered by access. Public view function. Useful for frontends to list articles.
transferOwnership Transfers contract ownership to a new address. Only contract owner.
Events ArticlePublished, AccessGranted, ArticlePurchased For frontend notifications and tracking actions on-chain.
State Variables owner, contractName, articles, accessPermissions, articleCount Track ownership, article data, permissions, and IDs.

Usage

  1. Connect wallet (MetaMask).
  2. Browse free articles.
  3. Unlock premium articles with ETH.
  4. Publish your own articles via IPFS.

Contracts

  • ArticleRegistry.sol – Manages publishing, ownership, and premium access.

Deploying the contract:

Deploying on Remix IDE

  1. Go to Remix IDE.

  2. Create a new file under the contracts/ folder and paste the ArticleRegistry.sol code.

  3. Compile the contract:

    • Click on the Solidity Compiler tab (left panel).
    • Select compiler version 0.8.x (matches your pragma).
    • Click Compile ArticleRegistry.sol.
  4. Deploy the contract:

    • Switch to the Deploy & Run Transactions tab (left panel).

    • Select your environment:

      • Injected Web3 to deploy via MetaMask to a testnet/mainnet.
      • Remix VM to deploy locally in Remix’s VM.
    • Ensure the correct account is selected.

    • Click Deploy next to ArticleRegistry.

  5. Once deployed, the contract will appear under Deployed Contracts, where you can:

    • Call publishArticle, grantAccess, purchaseAccess, etc.
    • View getArticle and getArticles.
  6. Copy the contract deployed address and set it as the environment variable


Scripts & Utilities

  • uploadToPinata.ts – Upload articles to IPFS
  • readArticle.ts – Fetch article metadata & access
  • deployArticle.ts – Smart contract deployment
  • supportArticle.ts – Support authors with ETH

Contributing

Pull requests are welcome. Open an issue first to discuss major changes.


License

Licensed under the MIT License.


Back to Top

⬆ Back to Top

 

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published