Compile a Solidity contract, get a typed F# API for it — no codegen step, no hand-written DTOs.
SolidityProvider turns a contract's ABI into a typed F# API — deploy it, call its methods, decode its results and events — using an F# type provider that expands the members at compile time. No codegen step to rerun, no DTOs to hand-write; the moment the ABI changes, so does the type. Encoding, decoding and remote calls all go through Nethereum.
| Area | Technology |
|---|---|
| Language | F# (netstandard2.0 + net8.0) |
| Type provider host | FSharp.TypeProviders.SDK |
| Ethereum client | Nethereum 6.x |
| ABI parsing | System.Text.Json for artifact discovery, Newtonsoft.Json for Nethereum's ABI deserializer |
| Package management | Paket |
| Tests | xUnit |
| Compatible build tools | Hardhat, or anything producing Hardhat/Truffle-shaped artifact json |
flowchart LR
A[Solidity contract] -->|hardhat compile| B[ABI + bytecode json]
B --> C{SolidityProvider}
C -->|design time| D[Generated FooContract type]
D -->|ContractPlug| E[Nethereum]
E --> F[Ethereum JSON-RPC node]
- Compile your contracts with anything that emits ABI/bytecode json - Hardhat's nested
artifacts/layout and a flat build folder both work. - Point a type provider at the output, or let it compile for you.
- The compiler expands a real
FooContracttype: one member per function, event and constructor in the ABI. - Instantiate it against an address, or deploy fresh by giving it constructor arguments.
type Contracts = AbiTypeProvider.AbiTypes<"./build/contracts">
let storageContract = Contracts.SimpleStorageContract(web3)
let getResult = storageContract.getQuery()
storageContract.set(newValue, weiValue 0UL, gasLlimit 8500000UL)Swap in AbiTypeProvider.AbiTypesFromHardhat<"./hardhat.config.js"> and it runs npx hardhat compile for you before generating types. An example project is in example/.
| Member | Behavior |
|---|---|
fooQuery / fooQueryAsync |
Read-only call, decoded to a .NET value |
foo / fooAsync |
State-changing call, returns a TransactionReceipt |
fooData / fooTransactionInput |
Raw calldata / an unsent TransactionInput |
FooEventDTO.DecodeAllEvents |
Decodes a receipt's logs into typed events |
Prerequisites: .NET 8 SDK (plus Node.js + npx for AbiTypesFromHardhat).
dotnet tool restore # installs the Paket bootstrapper
dotnet paket install # resolves NuGet dependencies
dotnet build -c Release
dotnet test tests/SolidityProviderTest/SolidityProviderTest.fsproj