Skip to content

JSON model ​

--json prints everything sourcetruth knows about the code, for your own tooling.

bash
sourcetruth ./contracts --json -o model.json

Versioning ​

The document starts with:

json
{
  "schemaVersion": 1,
  "tool": { "name": "sourcetruth", "version": "0.1.0" },
  "language": "solidity",
  "root": "/absolute/path/of/the/folder",
  "...": "..."
}

schemaVersion changes only when a field changes meaning or is removed. New fields may appear without a bump.

root is the absolute path of the folder that was read, on the machine that ran the command, so a script can find the files that path fields point at. Remove it before sharing the JSON — the HTML map shows only the folder's name.

Top level ​

Field
language"daml" or "solidity"
unitsContracts (Daml templates, Solidity contracts, interfaces, libraries)
entriesActions (Daml choices, Solidity external/public functions)
holesEvery blind spot, with the action it belongs to
statsunits, entries, edges, holes, resolution (% traced), soloAuthority, terminal
notesPlain-language warnings, such as imports that aren't on disk

An entry ​

Field
unit, nameThe contract and the action
path, lineWhere it is written
authorityWho can take it, as the source names them. Empty in Solidity means anyone
effect"none" (repeatable), "transition" (changes it), "terminal" (ends it)
args{ name, type } for each argument
guardsChecks and non-access modifiers, as source lines
edgesWhat it touches — see below
holesNumber of blind spots
sourceThe action's source, comments intact (display only)
declaredSolidity — a declaration with no code
deployOnlySolidity — a constructor
inheritedSolidity — the vendored parent it was inherited from
unreadSolidity — helpers or modifiers it relies on whose code isn't on disk

An edge ​

Field
kind"create", "call", "read" or "destroy"
targetThe contract it reaches, or null for a blind spot
resolvedfalse for a blind spot
rawThe source line
throughThe helper function the edge is written in, if any
externalThe target isn't defined in the code you pointed at
metaDetails, e.g. { "lowLevel": "delegatecall" }, { "eth": true }, { "library": "SafeERC20" }

Recipes ​

Every state-changing function with no access check:

bash
jq -r '.entries[] | select(.authority == [] and .effect != "none" and (.declared|not) and (.deployOnly|not)) | "\(.unit).\(.name)"' model.json

Every blind spot, with where it is:

bash
jq -r '.holes[] | "\(.path)  \(.owner)  \(.raw)"' model.json

Actions that carry an inherited vendored implementation:

bash
jq -r '.entries[] | select(.inherited) | "\(.unit).\(.name) from \(.inherited)"' model.json

Released under the MIT License.