PRT Contracts
PRT stands for Permissionless Refereed Tournaments. It is a dispute-resolution algorithm that allows anyone to defend the correct outcome of a computation with sensible hardware and Ether requirements. PRT Rollups leverages the PRT algorithm to secure Rollups applications.
So PRT Rollups is not a separate project, but rather a superset of the "Core" Rollups contracts. Code generation for PRT Rollups contracts can be configured through the prt option of rollupsContracts.
import { rollupsContracts } from "@cartesi/wagmi-plugin";
import { defineConfig } from "@wagmi/cli";
export default defineConfig({
out: "src/generated.ts",
plugins: [rollupsContracts({ prt: true })],
});Everything rollupsContracts() generates is still there, with the same ABIs and the same addresses, plus DaveConsensus, DaveAppFactory, MultiLevelTournamentFactory, Tournament, CartesiStateTransition and the interfaces and libraries they are built against.
Where each piece comes from
dave publishes the PRT contracts and the deployment addresses, but it does not rebuild the rollups contracts — there is no InputBox or portal artifact in its release. Both releases publish the addresses they share, because a PRT deployment includes the rollups one.
So prt reads six tarballs:
| Source | What it provides |
|---|---|
| the rollups-contracts artifacts tarball | ABIs of the rollups contracts |
| the dave artifacts tarball | ABIs of the PRT rollups contracts |
| the rollups-contracts deployment addresses tarball | livenet addresses of the rollups contracts |
| the dave deployment addresses tarball | livenet addresses of both |
| the rollups-contracts anvil tarball | devnet addresses of the rollups contracts |
| the dave anvil tarball | devnet addresses of both |
A handful of interfaces are built by both projects, and most addresses are published by both. Each is generated once, and the copies must agree: ABIs that differ, or an address the two releases disagree on, fail the generation rather than silently picking one.
By default prt: true uses the dave v3.0.0-alpha.4 release, which is deployed against the rollups-contracts v3.0.0-alpha.10 release that artifacts defaults to. Overriding one without the other pairs releases that were not deployed together, and the address cross-check is what catches it:
InputBox is deployed at conflicting addresses on chain 1: 0xD4CA… and 0x35Cd….
The releases these tarballs come from were not deployed together.
Using a different dave release
Pass an object instead of true. Each source accepts a plain URL string, or an object with an expected SHA-256 hash of the tarball for integrity verification (recommended).
import { rollupsContracts } from "@cartesi/wagmi-plugin";
import { defineConfig } from "@wagmi/cli";
const version = "3.0.0-alpha.4";
const anvilVersion = "1.5.1";
const releaseUrl = `https://github.com/cartesi/dave/releases/download/v${version}`;
export default defineConfig({
out: "src/generated.ts",
plugins: [
rollupsContracts({
prt: {
artifacts: {
url: `${releaseUrl}/cartesi-rollups-prt-${version}-contract-artifacts.tar.gz`,
sha256: "622964166b4049b556dc20b26ef2b9a5e8621a2ad3e1f43eee0b802a085244b3",
},
deployments: {
url: `${releaseUrl}/cartesi-rollups-prt-${version}-deployment-addresses.tar.gz`,
sha256: "24bbd3df188952ad0abb1b1d3bc1d5da8e832da3e15286bf552abba9db60f1e8",
},
anvil: {
url: `${releaseUrl}/cartesi-rollups-prt-${version}-anvil-${anvilVersion}.tar.gz`,
sha256: "ed10a8077113c426a298bb3592ca3725c31aad0828c7e7853b655593db2cd006",
},
},
}),
],
});Each source can be turned off on its own: prt.anvil set to false drops dave's devnet addresses, while the top-level anvil: false drops the devnet altogether, both releases' tarballs included.
Selecting contracts
include and exclude work exactly as they do without prt, and apply to the union. A dave release also builds the libraries and dependencies its contracts are compiled against, so narrowing generation is often worthwhile.
rollupsContracts({
prt: true,
include: ["InputBox", "DaveConsensus", /Tournament/],
});Options
The prt option is either a boolean or an object of tarball sources. Every other option of rollupsContracts applies unchanged.
| Option | Type | Description |
|---|---|---|
prt | boolean | PrtOptions | Generate a PRT deployment's contracts. true uses the dave v3.0.0-alpha.4 release. Defaults to false. |
prt.artifacts | string | { url: string; sha256?: string } | Source of the dave contract artifacts tarball, hash-verified by default. |
prt.deployments | string | { url: string; sha256?: string } | Source of the dave deployment addresses tarball, read alongside the rollups-contracts one and cross-checked against it. |
prt.anvil | string | { url, sha256? } | false | Source of the dave anvil devnet tarball, whose addresses cover chain 31337. false leaves dave's devnet out; anvil: false leaves the devnet out entirely. |