Version: 0.1.0
Core contracts, interfaces, and TypeScript types for the Web3 Transfer Protocol (WTTP).
WTTP Core provides the foundational contracts and type definitions used across the WTTP ecosystem. This package serves as the base dependency for all WTTP implementations including sites, gateways, and client applications.
- Complete Type Definitions: All WTTP protocol structures and interfaces
- Interface Contracts: Standard interfaces for Site, Gateway, Storage, and Permissions
- TypeChain Types: Generated TypeScript types for seamless web3 integration
- ESP Integration: Built-in support for External Service Provider data points
# Install from npm
npm install wttp-core
# Or install the organizational scoped package
npm install @tw3/wttp-core
import "wttp-core/contracts/interfaces/IWTTPSite.sol";
import "wttp-core/contracts/interfaces/WTTPTypes.sol";
contract MyWTTPImplementation {
using WTTPTypes for WTTPTypes.RequestLine;
function processRequest(WTTPTypes.HEADRequest memory request) external {
// Your implementation here
}
}
import {
RequestLine,
HEADRequest,
HEADResponse,
Method,
artifacts,
IWTTPSite__factory
} from "wttp-core";
// Use types in your TypeScript application
const request: HEADRequest = {
requestLine: {
protocol: "WTTP/3.0",
path: "/index.html",
method: Method.HEAD
},
ifModifiedSince: 0,
ifNoneMatch: "0x0000000000000000000000000000000000000000000000000000000000000000"
};
// Access contract artifacts
const siteABI = artifacts.IWTTPSite.abi;
// Connect to contracts
const site = IWTTPSite__factory.connect(siteAddress, provider);
import { ethers } from 'ethers';
import { IWTTPSite__factory, Method } from 'wttp-core';
async function querySiteContent(siteAddress: string, path: string) {
const provider = new ethers.JsonRpcProvider('your-rpc-url');
const site = IWTTPSite__factory.connect(siteAddress, provider);
const response = await site.HEAD({
requestLine: {
protocol: "WTTP/3.0",
path: path,
method: Method.HEAD
},
ifModifiedSince: 0,
ifNoneMatch: "0x0000000000000000000000000000000000000000000000000000000000000000"
});
console.log('Content metadata:', {
statusCode: response.responseLine.code,
mimeType: response.metadata.mimeType,
size: response.metadata.size.toString()
});
}
-
contracts/interfaces/: Core Solidity interface definitions
-
IWTTPSite.sol
- Site interface for content serving -
IWTTPGateway.sol
- Gateway interface for routing and ranges -
IWTTPStorage.sol
- Storage interface for content management -
IWTTPPermissions.sol
- Permissions interface for access control -
WTTPTypes.sol
- Complete protocol type definitions
-
- typechain-types/: Generated TypeScript type definitions
- artifacts/: Compiled contract artifacts
- dist/: Built package with CJS, ESM, and TypeScript declarations
-
@tw3/wttp-sites
- WTTP Site contract implementations -
@tw3/wttp-gateway
- WTTP Gateway contract implementations -
@tw3/wttp-client
- Client libraries for WTTP interaction -
@tw3/esp
- External Service Provider framework (dependency)
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.
Please read our Contributing Guidelines before submitting pull requests.