Skip to content

Cloudflare.Web3 reference

Source: src/Cloudflare/Web3/ContentList.ts

The IPFS content-blocking list of a Web3 universal-path gateway hostname — blocks specific CIDs or content paths from being served.

The content list is a per-hostname singleton: it always exists for an ipfs_universal_path hostname (empty by default), so this resource never creates or deletes a physical object. Reconciliation replaces the whole list declaratively via the bulk PUT, and destroy resets the list to empty.

Block a CID and a content path

const gateway = yield* Cloudflare.Web3.Hostname("UniversalGateway", {
zoneId: zone.zoneId,
name: "gateway.example.com",
target: "ipfs_universal_path",
});
yield* Cloudflare.Web3.HostnameContentList("Blocklist", {
zoneId: zone.zoneId,
hostnameId: gateway.hostnameId,
entries: [
{
type: "cid",
content: "QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco",
description: "blocked CID",
},
{
type: "content_path",
content: "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki",
},
],
});

Clear the blocklist

// An empty entries array removes every block (also what destroy does).
yield* Cloudflare.Web3.HostnameContentList("Blocklist", {
zoneId: zone.zoneId,
hostnameId: gateway.hostnameId,
entries: [],
});

Source: src/Cloudflare/Web3/Hostname.ts

A Cloudflare Web3 gateway hostname — serve Ethereum or IPFS content from a hostname on your zone via Cloudflare’s distributed web gateways.

A hostname’s identity is its name within the zone; only dnslink and description are mutable, so changing name, target, or zoneId triggers a replacement. Hostnames activate asynchronously: they start in pending status and flip to active once the CNAME is verified.

Note: Cloudflare has restricted Web3 gateways for new customers — on accounts without the entitlement, creation fails with the typed Web3HostnameNotEntitled error.

Safety: Web3 hostnames carry no ownership markers. When there is no prior state, read scans the zone for an existing hostname with the same name and reports it as Unowned, so the engine refuses to take it over unless --adopt (or adopt(true)) is set.

IPFS hostname pinned to a DNSLink

const gateway = yield* Cloudflare.Web3.Hostname("IpfsGateway", {
zoneId: zone.zoneId,
name: "ipfs.example.com",
target: "ipfs",
dnslink: "/ipns/onboarding.ipfs.cloudflare.com",
description: "IPFS gateway for example.com",
});

IPFS universal-path gateway

// Serves any CID under /ipfs/... and /ipns/... paths.
const universal = yield* Cloudflare.Web3.Hostname("UniversalGateway", {
zoneId: zone.zoneId,
name: "gateway.example.com",
target: "ipfs_universal_path",
});
yield* Cloudflare.Web3.Hostname("EthGateway", {
zoneId: zone.zoneId,
name: "eth.example.com",
target: "ethereum",
});