This document provides comprehensive documentation for all Hardhat tasks, Hardhat scripts, and standalone ethers.js scripts available in the WTTP Site package.
Hardhat tasks are CLI commands that can be executed using npx hardhat <task-name>. They integrate with Hardhat's runtime environment and provide convenient access to WTTP Site functionality.
Deploy a Web3Site contract to the blockchain.
Usage:
npx hardhat site:deploy [options] --network <network>Parameters:
--dpr(optional): DataPointRegistry contract address. Defaults to official ESP deployment for the current network.--owner(optional): Site owner address. Defaults to deployer address.--cache-preset(optional): Cache preset value. Accepts numeric (0-6) or named values:none(0): No cachingshort(2): Short-term cachemedium(3): Medium-term cache (default)long(4): Long-term cacheaggressive(5): Aggressive cachingpermanent(6): Permanent cache
--header-preset(optional): Header preset configuration:basic: Standard caching and CORS settingsdevelopment: Development-friendly settings (no cache, permissive CORS)production: Production-optimized settings (long cache, strict CORS)
--cors-preset(optional): CORS preset configuration:permissive: Allow all originsstrict: Same-origin onlybasic: Basic CORS settings
--skip-verify(flag): Skip contract verification on block explorer--auto-fund(flag): Automatically fund deployer from owner if needed
Examples:
# Deploy with default settings
npx hardhat site:deploy --network localhost
# Deploy with custom cache preset
npx hardhat site:deploy --cache-preset aggressive --network sepolia
# Deploy with header preset
npx hardhat site:deploy --header-preset production --network polygon
# Deploy with auto-funding enabled
npx hardhat site:deploy --auto-fund --network sepoliaOutput:
- Contract address
- Owner address
- DPR address
- Transaction hash
- Deployment cost estimate
Verify a deployed Web3Site contract on a block explorer.
Usage:
npx hardhat site:verify --address <address> --dpr <dpr-address> --owner <owner-address> [options] --network <network>Parameters:
--address(required): Web3Site contract address to verify--dpr(required): DPR address used in constructor--owner(required): Owner address used in constructor--cache-preset(optional): Same assite:deploy--header-preset(optional): Same assite:deploy--cors-preset(optional): Same assite:deploy--confirmations(optional): Number of confirmations to wait before verifying (default: 5)--skip-wait(flag): Skip waiting for confirmations
Examples:
# Verify with default settings
npx hardhat site:verify --address 0x... --dpr 0x... --owner 0x... --network sepolia
# Verify without waiting for confirmations
npx hardhat site:verify --address 0x... --dpr 0x... --owner 0x... --skip-wait --network sepoliaUpload files or directories to a WTTP site. Supports both direct uploads and manifest-based uploads.
Usage:
npx hardhat site:upload [options] --network <network>Parameters:
--site(optional): WTTP site contract address. Required unless using--manifestwith a manifest containingchainData.contractAddress.--source(optional): Source file or directory path. Required unless using--manifest.--manifest(optional): Path to manifest file for manifest-based uploads.--destination(optional): Destination path on the WTTP site (default:/).--nodefaults(flag): Disable default ignore patterns (not recommended).--gaslimit(optional): Maximum gas price in gwei to wait for before sending transactions (default: 300).--filelimit(optional): Maximum file size in MB (default: 400).
Upload Modes:
-
Direct Upload Mode:
npx hardhat site:upload --site 0x... --source ./public --network localhost
-
Manifest-Based Upload:
npx hardhat site:upload --manifest ./wttp.manifest.json --network localhost
Examples:
# Upload a directory
npx hardhat site:upload --site 0x... --source ./public --destination / --network localhost
# Upload a single file
npx hardhat site:upload --site 0x... --source ./index.html --destination /index.html --network localhost
# Upload using manifest
npx hardhat site:upload --manifest ./wttp.manifest.json --network sepolia
# Upload with custom gas limit
npx hardhat site:upload --site 0x... --source ./public --gaslimit 200 --network polygonFeatures:
- Automatic file chunking (32KB chunks)
- Smart upload optimization (skips unchanged chunks)
- Progress reporting
- Gas price monitoring
- File size validation
Fetch a resource from a WTTP site via the WTTPGateway.
Usage:
npx hardhat site:fetch [options] --network <network>Parameters:
--url(optional): Full URL of the WTTP site (alternative to--siteand--path).--site(optional): WTTP site contract address (required if not using--url).--path(optional): Path to the resource (default:/).--range(optional): Byte range in formatstart-end(e.g.,10-20).--if-modified-since(optional): Unix timestamp for If-Modified-Since header.--if-none-match(optional): ETag value for If-None-Match header.--head(flag): Perform a HEAD request instead of GET.--datapoints(flag): Fetch datapoint addresses instead of resource data.
Examples:
# Fetch root resource
npx hardhat site:fetch --site 0x... --network localhost
# Fetch specific path
npx hardhat site:fetch --site 0x... --path /index.html --network localhost
# Fetch with URL
npx hardhat site:fetch --url http://0x...localhost:8545/index.html --network localhost
# HEAD request
npx hardhat site:fetch --site 0x... --path /style.css --head --network localhost
# Fetch byte range
npx hardhat site:fetch --site 0x... --path /large-file.bin --range 0-1024 --network localhostOutput:
- Status code
- Content-Type
- Charset, Encoding, Language
- File size
- Version
- ETag
- Last Modified timestamp
- Content (for GET requests)
Generate a manifest file for a WTTP site directory. Manifests track file structure, chunk addresses, and cost estimates.
Usage:
npx hardhat site:manifest --source <directory> [options] --network <network>Parameters:
--source(required): Source directory path.--site(optional): WTTP site contract address (for cost estimates).--testconfig(optional): Path to test config JSON file with site/network info.--destination(optional): Destination path on the WTTP site (default:/).--output(optional): Output path for manifest file (default:source/wttp.manifest.json).--gaslimit(optional): Maximum gas price in gwei (stored in manifest config).--filelimit(optional): Maximum file size in MB (stored in manifest config).--nodefaults(flag): Disable default ignore patterns.--ignorepattern(optional): Custom ignore pattern file path ornone.--externalrules(optional): JSON file path containing external storage rules.--update(optional): Path to existing manifest to update.
Examples:
# Generate manifest without cost estimates
npx hardhat site:manifest --source ./public --network localhost
# Generate manifest with cost estimates
npx hardhat site:manifest --source ./public --site 0x... --network sepolia
# Generate manifest with external storage rules
npx hardhat site:manifest --source ./public --externalrules ./arweave-rules.json --network localhost
# Update existing manifest
npx hardhat site:manifest --source ./public --update ./wttp.manifest.json --network localhostManifest Structure:
name: Site namepath: Site pathwttpConfig: Upload configurationsiteData: File and directory structurechainData: Blockchain information and cost estimates
Estimate gas costs for uploading a file or directory to a WTTP site.
Usage:
npx hardhat site:estimate --source <path> [options] --network <network>Parameters:
--source(required): Source file or directory path.--site(optional): WTTP site contract address (uses default test contract if not provided).--destination(optional): Destination path on the WTTP site (auto-generated if not provided).--gasprice(optional): Custom gas price in gwei.--rate(optional): Multiplier rate for current gas price (default: 2, accepts decimals like 1.5).--min(optional): Minimum gas price in gwei (default: 150).--nodefaults(flag): Disable default ignore patterns.
Examples:
# Estimate file upload
npx hardhat site:estimate --source ./index.html --network localhost
# Estimate directory upload
npx hardhat site:estimate --source ./public --network sepolia
# Estimate with custom gas price
npx hardhat site:estimate --source ./large-file.bin --gasprice 100 --network polygon
# Estimate with rate multiplier
npx hardhat site:estimate --source ./public --rate 1.5 --min 100 --network localhostOutput:
- Total cost (gas + royalties)
- Total gas
- Total royalty cost
- Transaction count
- Cost per MB
Upload site resources to Arweave using the official Arweave library. Updates manifest with Arweave transaction IDs.
Usage:
npx hardhat arweave:upload [options]Parameters:
--manifestPath(optional): Path to an existing manifest file.--source(optional): Source directory path (required if generating manifest).--wallet(required): Path to Arweave wallet JSON file (JWK format).--externalrules(optional): JSON file path containing external storage rules (for manifest generation).--gaslimit(optional): Maximum gas price in gwei (for manifest generation).--filelimit(optional): Maximum file size in MB (for manifest generation).--ignorepattern(optional): Custom ignore pattern file path ornone.--output(optional): Output path for manifest file (when generating).--upload-manifest(flag): Upload the manifest itself to Arweave after updating.
Examples:
# Upload using existing manifest
npx hardhat arweave:upload --manifestPath ./wttp.manifest.json --wallet ./wallet.json
# Generate manifest and upload
npx hardhat arweave:upload --source ./public --wallet ./wallet.json --externalrules ./arweave-rules.json
# Upload manifest itself
npx hardhat arweave:upload --manifestPath ./wttp.manifest.json --wallet ./wallet.json --upload-manifestWorkflow:
- Load or generate manifest
- Find files marked for Arweave storage
- Upload files to Arweave
- Update manifest with transaction IDs
- Optionally upload manifest to Arweave
Generate a new Arweave wallet and save to file.
Usage:
npx hardhat arweave:generate [options]Parameters:
--output(optional): Output filename for the wallet JSON file (default:wallet.json).--force(flag): Force overwrite existing wallet file (with balance check and warning).
Examples:
# Generate wallet
npx hardhat arweave:generate --output ./arweave-wallet.json
# Force overwrite (with safety checks)
npx hardhat arweave:generate --output ./wallet.json --forceSecurity:
- Automatically adds wallet file to
.gitignore - Warns if overwriting wallet with non-zero balance
- Provides 10-second countdown before overwriting
Get the Arweave address from a wallet file.
Usage:
npx hardhat arweave:address [options]Parameters:
--wallet(optional): Path to Arweave wallet JSON file (default:wallet.json).
Examples:
# Get address from default wallet
npx hardhat arweave:address
# Get address from specific wallet
npx hardhat arweave:address --wallet ./arweave-wallet.jsonGet the balance of an Arweave wallet or address.
Usage:
npx hardhat arweave:balance [options]Parameters:
--wallet(optional): Path to Arweave wallet JSON file (default:wallet.json).--address(optional): Arweave address to check balance.
Examples:
# Check wallet balance
npx hardhat arweave:balance --wallet ./wallet.json
# Check address balance
npx hardhat arweave:balance --address <arweave-address>Output:
- Balance in Winston (smallest unit)
- Balance in AR (readable format)
Send AR tokens from a wallet to an address.
Usage:
npx hardhat arweave:send --wallet <path> --to <address> --amount <amount>Parameters:
--wallet(required): Path to Arweave wallet JSON file.--to(required): Destination Arweave address.--amount(required): Amount to send in AR (not Winston).--self(flag): Allow sending to the same address (for testing/debugging).
Examples:
# Send AR tokens
npx hardhat arweave:send --wallet ./wallet.json --to <address> --amount 0.1
# Self-send (for testing)
npx hardhat arweave:send --wallet ./wallet.json --to <same-address> --amount 0.01 --selfOutput:
- Transaction ID
- Transaction status
- View transaction link
Minimize WordPress site by identifying unused files. Can generate .wttpignore or delete unused files.
Usage:
npx hardhat wp-minimize --path <directory> [options]Parameters:
--path(required): Path to WordPress site directory.--delete-files(flag): Delete unused files instead of creating.wttpignore.--dry-run(flag): Show what would be done without making changes.--debug(flag): Enable debug output to see reference processing.
Examples:
# Analyze and generate .wttpignore
npx hardhat wp-minimize --path ./wordpress-site
# Delete unused files
npx hardhat wp-minimize --path ./wordpress-site --delete-files
# Dry run to see what would be done
npx hardhat wp-minimize --path ./wordpress-site --dry-runFeatures:
- Scans HTML files for references
- Scans CSS files for references
- Tracks file usage counts
- Identifies unused files
- Calculates potential savings
Replace Ninja Forms with custom HTML forms. Removes Ninja Forms JavaScript and replaces forms with static HTML.
Usage:
npx hardhat wp-ninja-fix --path <directory> [options]Parameters:
--path(required): Path to WordPress site directory.--dry-run(flag): Show what would be done without making changes.--backup(flag): Create backup files and add them to.wttpignore.
Examples:
# Replace Ninja Forms
npx hardhat wp-ninja-fix --path ./wordpress-site
# Dry run to see changes
npx hardhat wp-ninja-fix --path ./wordpress-site --dry-run
# With backups
npx hardhat wp-ninja-fix --path ./wordpress-site --backupFeatures:
- Extracts form data from Ninja Forms JavaScript
- Generates custom HTML forms
- Removes Ninja Forms JavaScript
- Preserves form functionality
- Creates backups (optional)
Process WordPress site routes using routes.json configuration. Updates links and creates client-side redirects.
Usage:
npx hardhat wp-routes --path <directory> [options]Parameters:
--path(required): Path to WordPress site directory.--config-file(optional): Path toroutes.jsonconfiguration file (defaults to{path}/routes.json).--dry-run(flag): Show what would be done without making changes.--backup(flag): Create backup files.--no-redirect(flag): Skip creating client-side redirect script.
Examples:
# Process routes
npx hardhat wp-routes --path ./wordpress-site
# Dry run
npx hardhat wp-routes --path ./wordpress-site --dry-run
# With backups
npx hardhat wp-routes --path ./wordpress-site --backupConfiguration File (routes.json):
{
"routes": {
"/old-path": {
"redirect": "/new-path",
"method": "replace"
}
},
"settings": {
"backupOriginals": false,
"updateCanonicalUrls": true,
"updateOembedUrls": true,
"clientSideRedirects": true,
"preserveQueryParams": true,
"preserveHashFragments": true
}
}Hardhat scripts are Node.js modules that can be imported and used in your own scripts. They use Hardhat's ethers instance and are designed for use within Hardhat projects.
Upload a single file to a WTTP site.
Location: src/scripts/uploadFile.ts
Usage:
import { uploadFile } from "./scripts/uploadFile";
import { ethers } from "hardhat";
const wttpSite = await ethers.getContractAt("Web3Site", siteAddress);
await uploadFile(
wttpSite,
"./index.html",
"/index.html",
400 * 1024 * 1024, // fileLimitBytes
300 // gasLimitGwei
);Parameters:
wttpSite: Web3Site contract instancesourcePath: Source file pathdestinationPath: Destination path on sitefileLimitBytes(optional): Maximum file size in bytesgasLimitGwei(optional): Maximum gas price in gwei
Upload a directory recursively to a WTTP site.
Location: src/scripts/uploadDirectory.ts
Usage:
import { uploadDirectory } from "./scripts/uploadDirectory";
import { ethers } from "hardhat";
const wttpSite = await ethers.getContractAt("Web3Site", siteAddress);
await uploadDirectory(
wttpSite,
"./public",
"/",
{ includeDefaults: true }, // ignoreOptions
400 * 1024 * 1024, // fileLimitBytes
300 // gasLimitGwei
);Parameters:
wttpSite: Web3Site contract instancesourcePath: Source directory pathdestinationPath: Destination path on siteignoreOptions(optional): WTTP ignore configurationfileLimitBytes(optional): Maximum file size in bytesgasLimitGwei(optional): Maximum gas price in gwei
Upload files using a manifest file.
Location: src/scripts/uploadFromManifest.ts
Usage:
import { uploadFromManifest } from "./scripts/uploadFromManifest";
import { ethers } from "hardhat";
const wttpSite = await ethers.getContractAt("Web3Site", siteAddress);
await uploadFromManifest(
wttpSite,
"./wttp.manifest.json",
"./public" // optional source path
);Parameters:
wttpSite: Web3Site contract instancemanifestPath: Path to manifest filesourcePath(optional): Source directory path
Fetch a resource from a WTTP site.
Location: src/scripts/fetchResource.ts
Usage:
import { fetchResource } from "./scripts/fetchResource";
const resource = await fetchResource(
siteAddress,
"/index.html",
{
range: { start: 0, end: 1024 },
ifModifiedSince: 1234567890,
ifNoneMatch: "0x...",
headRequest: false,
datapoints: false
}
);Parameters:
siteAddress: WTTP site contract addresspath: Resource pathoptions(optional): Request options
Generate a manifest file for a directory.
Location: src/scripts/generateManifest.ts
Usage:
import { generateManifest, saveManifest } from "./scripts/generateManifest";
import { ethers } from "hardhat";
const wttpSite = await ethers.getContractAt("Web3Site", siteAddress);
const manifest = await generateManifest(
wttpSite,
"./public",
"/",
{
gasLimit: 300,
fileLimit: 400,
ignorePattern: ".wttpignore"
}
);
saveManifest(manifest, "./wttp.manifest.json");Parameters:
wttpSite: Web3Site contract instance (optional, for cost estimates)sourcePath: Source directory pathdestinationPath: Destination path on siteconfig(optional): Manifest configurationexistingManifest(optional): Existing manifest to update
Upload files to Arweave and update manifest.
Location: src/scripts/uploadToArweave.ts
Usage:
import { uploadToArweave } from "./scripts/uploadToArweave";
const result = await uploadToArweave(
"./wttp.manifest.json",
{
walletPath: "./wallet.json",
sourcePath: "./public",
uploadManifest: false
}
);Parameters:
manifestPath: Path to manifest fileoptions: Upload options
Standalone ethers.js scripts can be used outside of Hardhat projects. They work with standard ethers.js providers and signers.
Deploy a Web3Site contract using standard ethers.js.
Location: src/ethers/deploy.ts
Usage:
import { deployWeb3Site } from "@wttp/site/ethers";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = new ethers.Wallet(privateKey, provider);
const result = await deployWeb3Site({
provider,
signer,
ownerAddress: "0x...",
dprAddress: "0x...",
defaultHeader: DEFAULT_HEADER,
autoFund: false
});
console.log(`Deployed at: ${result.address}`);Parameters:
provider: Ethers.js providersigner: Ethers.js signerownerAddress: Site owner addressdprAddress: DPR contract addressdefaultHeader(optional): Default header configurationautoFund(optional): Auto-fund deployer if needed
Returns:
contract: Deployed contract instanceaddress: Contract addressdeployerAddress: Deployer addressownerAddress: Owner addressdprAddress: DPR addresstxHash: Transaction hashactualCost: Actual deployment cost
Upload a file using standard ethers.js.
Location: src/ethers/uploadFile.ts
Usage:
import { uploadFile } from "@wttp/site/ethers";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = new ethers.Wallet(privateKey, provider);
const result = await uploadFile(
"0x...", // siteAddress
"./index.html",
"/index.html",
{
provider,
signer,
fileLimitBytes: 400 * 1024 * 1024,
gasLimitGwei: 300
}
);Parameters:
wttpSiteAddress: WTTP site contract addresssourcePath: Source file pathdestinationPath: Destination path on siteoptions: Upload options
Returns:
response: LOCATEResponseStructcontent: File content (optional)
Upload a directory using standard ethers.js.
Location: src/ethers/uploadDirectory.ts
Usage:
import { uploadDirectory } from "@wttp/site/ethers";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = new ethers.Wallet(privateKey, provider);
await uploadDirectory(
"0x...", // siteAddress
"./public",
"/",
{
provider,
signer,
ignoreOptions: { includeDefaults: true },
fileLimitBytes: 400 * 1024 * 1024,
gasLimitGwei: 300
}
);Parameters:
wttpSiteAddress: WTTP site contract addresssourcePath: Source directory pathdestinationPath: Destination path on siteoptions: Upload options
Estimate gas costs for uploads using standard ethers.js.
Location: src/ethers/estimate.ts
Usage:
import { estimateFile, estimateDirectory } from "@wttp/site/ethers";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
// Estimate file
const fileEstimate = await estimateFile(
"0x...", // siteAddress
"./index.html",
"/index.html",
{
provider,
gasPriceGwei: 50,
rate: 2,
minGasPriceGwei: 150
}
);
// Estimate directory
const dirEstimate = await estimateDirectory(
"0x...", // siteAddress
"./public",
"/",
{
provider,
gasPriceGwei: 50,
rate: 2,
minGasPriceGwei: 150
}
);Parameters:
wttpSiteAddress: WTTP site contract addresssourcePath: Source file or directory pathdestinationPath: Destination path on siteoptions: Estimation options
Returns:
totalGas: Total gas estimatetotalCost: Total cost estimateroyaltyCost: Royalty cost estimatetransactionCount: Number of transactionschunksToUpload: Number of chunks to upload
Fetch a resource using standard ethers.js.
Location: src/ethers/fetchResource.ts
Usage:
import { fetchResource } from "@wttp/site/ethers";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const resource = await fetchResource(
provider,
"0x...", // siteAddress
"/index.html",
{
ifModifiedSince: 1234567890,
ifNoneMatch: "0x...",
range: { start: 0, end: 1024 },
headRequest: false,
datapoints: false
}
);Parameters:
provider: Ethers.js providersiteAddress: WTTP site contract addresspath: Resource pathoptions: Request options
Returns:
response: LOCATEResponseStructcontent: Resource content (optional)
Generate a manifest using standard ethers.js.
Location: src/ethers/generateManifest.ts
Usage:
import { generateManifestStandalone, saveManifest } from "@wttp/site/ethers";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = new ethers.Wallet(privateKey, provider);
const manifest = await generateManifestStandalone(
"./public",
"/",
{
gasLimit: 300,
fileLimit: 400,
ignorePattern: ".wttpignore"
},
undefined, // existingManifest
{
provider,
signer,
wttpSiteAddress: "0x...",
chainId: 11155111,
chainName: "sepolia",
currencySymbol: "ETH"
}
);
saveManifest(manifest, "./wttp.manifest.json");Parameters:
sourcePath: Source directory pathdestinationPath: Destination path on siteconfig(optional): Manifest configurationexistingManifest(optional): Existing manifest to updateoptions(optional): Generation options
Upload files to Arweave using standard ethers.js.
Location: src/ethers/uploadToArweave.ts
Usage:
import { uploadToArweave } from "@wttp/site/ethers";
const result = await uploadToArweave(
"./wttp.manifest.json",
{
walletPath: "./wallet.json",
sourcePath: "./public",
uploadManifest: false
}
);Parameters:
manifestPath: Path to manifest fileoptions: Upload options
Returns:
filesUploaded: Number of files uploadedfilesSkipped: Number of files skippedtxIds: Map of file paths to transaction IDsmanifestTxId: Manifest transaction ID (if uploaded)
# 1. Deploy a site
npx hardhat site:deploy --network sepolia
# 2. Generate manifest with cost estimates
npx hardhat site:manifest --source ./public --site 0x... --network sepolia
# 3. Upload files using manifest
npx hardhat site:upload --manifest ./wttp.manifest.json --network sepolia
# 4. Fetch a resource
npx hardhat site:fetch --site 0x... --path /index.html --network sepoliaimport { deployWeb3Site, uploadFile } from "@wttp/site/ethers";
import { ethers } from "ethers";
// Setup
const provider = new ethers.JsonRpcProvider("https://sepolia.infura.io/v3/YOUR_KEY");
const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
// Deploy
const deployment = await deployWeb3Site({
provider,
signer,
ownerAddress: signer.address,
dprAddress: "0x...", // Official ESP DPR
});
// Upload
await uploadFile(
deployment.address,
"./index.html",
"/index.html",
{
provider,
signer,
fileLimitBytes: 400 * 1024 * 1024,
gasLimitGwei: 300
}
);# 1. Minimize unused files
npx hardhat wp-minimize --path ./wordpress-site --dry-run
# 2. Fix Ninja Forms
npx hardhat wp-ninja-fix --path ./wordpress-site --backup
# 3. Process routes
npx hardhat wp-routes --path ./wordpress-site --backup
# 4. Generate manifest
npx hardhat site:manifest --source ./wordpress-site --network sepolia
# 5. Upload
npx hardhat site:upload --manifest ./wordpress-site/wttp.manifest.json --network sepoliaFor issues, questions, or contributions, please visit the WTTP Site GitHub repository.