- Features
- Tech Stack
- Installation
- Project Structure
- File Structure (Detailed)
- Usage
- Contracts
- Scripts & Utilities
- Contributing
- License
- Back to Top
- 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
- Frontend: Next.js 14, TypeScript, TailwindCSS, ShadCN UI
- Blockchain: Solidity, Wagmi, viem
- Storage: IPFS (Pinata)
- Other: React Query, Lucide Icons
git clone https://github.com/yourusername/authrnet.git
cd authrnet
# Install dependencies
npm install
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=
# Development
npm run dev
# Build for production
npm run build
# Start production server
npm start
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
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/
└── 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. |
- Connect wallet (MetaMask).
- Browse free articles.
- Unlock premium articles with ETH.
- Publish your own articles via IPFS.
- ArticleRegistry.sol – Manages publishing, ownership, and premium access.
Deploying the contract:
-
Go to Remix IDE.
-
Create a new file under the
contracts/
folder and paste theArticleRegistry.sol
code. -
Compile the contract:
- Click on the Solidity Compiler tab (left panel).
- Select compiler version
0.8.x
(matches your pragma). - Click Compile ArticleRegistry.sol.
-
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
.
-
-
Once deployed, the contract will appear under Deployed Contracts, where you can:
- Call
publishArticle
,grantAccess
,purchaseAccess
, etc. - View
getArticle
andgetArticles
.
- Call
-
Copy the contract deployed address and set it as the environment variable
uploadToPinata.ts
– Upload articles to IPFSreadArticle.ts
– Fetch article metadata & accessdeployArticle.ts
– Smart contract deploymentsupportArticle.ts
– Support authors with ETH
Pull requests are welcome. Open an issue first to discuss major changes.
Licensed under the MIT License.