This document provides detailed information about how DappGuardian integrates with IPFS (InterPlanetary File System) to store dApp manifests securely and cost-effectively.
Instead of storing all file hashes directly on the blockchain, DappGuardian now:
- Creates a manifest JSON file containing all file hashes and metadata
- Uploads this manifest to IPFS and pins it to ensure availability
- Stores only the IPFS CID (Content Identifier) on the blockchain
This approach dramatically reduces gas costs while maintaining the security and verifiability of the system.
By storing only a single IPFS CID on-chain rather than multiple file hashes:
- Gas costs for registering releases remain constant regardless of the number of files
- Developers can include unlimited files in their dApp without worrying about transaction costs
- Updates become more economical, encouraging more frequent security updates
IPFS provides excellent scalability advantages:
- No practical limit to manifest size
- Can include detailed metadata with each file hash
- Support for large dApps with hundreds or thousands of files
- Easy to extend the manifest schema without changing the smart contract
IPFS offers strong guarantees for content availability:
- Content-addressed storage ensures integrity
- Data can be retrieved from any IPFS node that has the content
- Pinning services ensure your manifests remain available
- Multiple gateway fallbacks for high availability
{
"domain": "your-dapp-domain.com",
"timestamp": 1682459853,
"globalHash": "a1b2c3d4e5f6...",
"files": [
{
"filename": "index.js",
"hash": "8d7c6b5a4e3...",
"timestamp": 1682459853
},
{
"filename": "app.js",
"hash": "7a6b5c4d3e2...",
"timestamp": 1682459853
}
// ... additional files
]
}- The
manifestGenerator.jsscript scans your dApp and creates the initial manifest - The
submitter.jsscript:- Enhances the manifest with metadata
- Uploads the manifest to IPFS using Pinata or another provider
- Retrieves the IPFS CID
- Registers the CID on the blockchain via the smart contract
- The browser extension detects JavaScript files loaded by the browser
- When the extension popup is opened, it:
- Retrieves the IPFS CID from the DappGuardian contract
- Fetches the manifest from one of several IPFS gateways
- Compares local file hashes with those in the manifest
- Displays verification results to the user
The CLI tool requires configuration for your preferred IPFS provider:
# .env file configuration
IPFS_API_URL=https://api.pinata.cloud/psa
IPFS_API_KEY=your-pinata-api-key
IPFS_API_SECRET=your-pinata-api-secret
Pinata is a popular IPFS pinning service that offers:
- Simple API integration
- Free tier with generous limits
- Reliable pinning infrastructure
To use Pinata:
- Create an account at pinata.cloud
- Generate API keys with pinning permissions
- Add the keys to your
.envfile
Infura provides enterprise-grade IPFS infrastructure:
- High availability
- Fast response times
- Production-ready infrastructure
To use Infura IPFS, modify the uploadToIPFS function in submitter.js to use Infura's endpoints and authentication.
Web3.Storage offers storage built on Filecoin and IPFS:
- Free tier available
- Built-in Filecoin storage deals
- Long-term storage guarantees
To use Web3.Storage, you'll need to adapt the uploadToIPFS function to use their API.
For complete control, you can run your own IPFS node:
- Install and run an IPFS node
- Use the IPFS HTTP API for uploading
- Configure your node for pinning
The browser extension uses multiple IPFS gateways for reliability:
// Multiple IPFS gateways for reliability
const IPFS_GATEWAYS = [
"https://ipfs.io/ipfs/",
"https://gateway.pinata.cloud/ipfs/",
"https://cloudflare-ipfs.com/ipfs/",
"https://dweb.link/ipfs/"
];You can modify this list in extension/services/contractService.ts to add or remove gateways according to your preferences.
-
IPFS Upload Failures
- Check your API credentials
- Verify network connectivity to the IPFS provider
- Ensure the manifest JSON is valid
-
Extension Cannot Retrieve Manifest
- Confirm the CID is registered correctly on-chain
- Check that the IPFS content is properly pinned
- Try using the retry functionality in the extension
-
Gateway Timeouts
- IPFS gateways may occasionally experience high load or downtime
- The extension will automatically try alternative gateways
- If all gateways fail, try again later or add more gateways to the configuration
If you operate your own IPFS gateway, you can configure the extension to use it first:
// Add your gateway at the beginning of the array for highest priority
const IPFS_GATEWAYS = [
"https://your-custom-gateway.com/ipfs/",
// ... other gateways
];The extension caches IPFS manifests to improve performance. To change the cache duration:
// In contractService.ts
private cacheExpiryTime: number = 3600000; // Default: 1 hour in millisecondsIf you're migrating from a previous version of DappGuardian that stored file hashes directly on-chain:
- Deploy the updated smart contract
- Register your domain on the new contract
- Generate a manifest with the CLI tool
- Submit the manifest to IPFS and register the CID
Users will seamlessly benefit from the new IPFS-based verification without needing to update their extension.