Silver is a static analysis and formal verification tool for Stratis smart contracts. Silver can analyze both C# source code using a Roslyn diagnostic analyzer and CIL code in a .NET bytecode assembly and can run both inside Visual Studio and on the command line.
Silver can validate C# code using a Roslyn diagnostic analyzer according to the same rules for types and members used by the Stratis CLR VM for smart contracts. All the validation policies currently in use will be ported to the Roslyn analyzer.
Silver can disassemble smart contract CIL code in a .NET bytecode assembly:
and statically analyze it using the Analysis.Net framework e.g. the following is a call-graph analysis of the methods in the Address Mapper contract.
Silver can output graphs in different formats like PNG images:
or in the DGML format which are natively supported in Visual Studio:
Silver can formally verify smart contracts in C# using the Spec# compiler from Microsoft Research:
See the wiki for more in-depth technical information and documentation.
- NET 6.0
- Mono (on *nix/MacOs)
- libgdiplus (on *nix/MacOs, for graph drawing)
The verifier is currently broken on non-Windows as the Spec# verifier depends on some Windows specific code in the compiler to write .PDB files which are needed to verify an assembly. Everything else should work cross-platform including the analyzers and compiler.
- Ensure requirements are installed
- Clone this git repo and submodules:
git clone https://github.com/allisterb/Silver.git --recurse-submodules
- Run .
/build
orbuild.cmd
in the root repo directory. Build should complete without errors. - Run
./silver install
to download and install the external tools needed. - Compile and analyze one of the example projects e.g.
./silver compile examples\AddressMapper\AddressMapper.csproj
andsilver dis examples/AddressMapper/bin/Debug/netcoreapp2.1/AddressMapper.dll
- On Windows you can verify one of the example projects e.g.
silver verify examples\SimpleVerifiableContracts\SimpleVerifiableContracts.csproj
orsilver compile examples\SimpleVerifiableContracts\SimpleVerifiableContracts.csproj --verify
See silver help
for the different commands and actions.