| Crates.io | fdev |
| lib.rs | fdev |
| version | 0.3.5 |
| created_at | 2023-09-21 14:39:44.310068+00 |
| updated_at | 2025-09-26 01:04:35.987159+00 |
| description | Freenet development tool |
| homepage | |
| repository | https://github.com/freenet/freenet |
| max_upload_size | |
| id | 979566 |
| size | 386,948 |
The Freenet Development Tool (fdev) is a command-line utility to create, build, publish, inspect, and test Freenet contracts or delegates. It also supports local node simulations, a TUI-based WASM runtime, and optional network metrics gathering.
fdev helps Freenet developers:
Usually you'll build fdev as part of the Freenet project:
freenet-core/main/crates/fdev.cargo build --release
./target/release/fdev --help
Or place target/release/fdev on your PATH.If you want to try out a contract in local mode, you typically run a separate “local node” process that listens for contract commands. There is a local-node executable (or an equivalent) in the Freenet repository. You can do something like:
# Example: run the local node (CLI options may vary)
local-node local-node-cli --help
Once the local node is up, you can run fdev or a script to send commands to it.
Below is a legacy style example (paths/names may differ in current code):
# Example: older usage for local node exploration
./fdev run-local \
--input-file /tmp/input \
--terminal-output \
--deser-format json \
"/home/.../freenet/crates/http-gw/examples/test_web_contract.wasm"
In newer code, you will likely use fdev wasm-runtime, described in a later section, to do an equivalent local testing workflow.
fdev new scaffolds a new Freenet package. Two options:
contract: A standard WASM contract.webapp: A contract container that also bundles a front-end (TypeScript/webpack by default).Example:
fdev new contract
Generates Rust cargo boilerplate (and for web apps, TypeScript/webpack scaffolding too).
Use fdev build to compile a Rust-based WASM contract or delegate. For example:
fdev build \
--package-type [contract|delegate] \
[--features some_features] \
[--debug] \
[--version 0.0.2]
--package-type defaults to contract.--features can specify crate features, e.g. freenet-main-contract or freenet-main-delegate.--debug produces an unoptimized WASM (useful for local tests).--version sets the embedded Freenet ABI version (defaults to 0.0.1).fdev looks for a freenet.toml in your current directory that defines if your contract is standard or a webapp, and (for webapps) how to compile front-end code.
After building, the output artifact is typically placed in build/freenet/ unless overridden by your config file.
fdev publish uploads a new contract or delegate to a node (either local or network mode).
Example: Publishing a contract:
fdev publish \
--code path/to/my_contract.wasm \
--parameters path/to/params \
contract \
--state path/to/initial_state
--code: path to your built WASM.--parameters: optional contract parameters file (typically binary format).--state: optional initial state file (typically binary format).Example: Publishing a webapp contract with pre-compressed archive:
# First compress your webapp directory
tar cf - webapp/ | xz > webapp.tar.xz
# Then publish the webapp contract
fdev publish \
--code path/to/webapp_contract.wasm \
--parameters path/to/params \
contract \
--webapp-archive webapp.tar.xz \
--webapp-metadata path/to/metadata.json
--webapp-archive: path to your xz-compressed tar archive containing the webapp files.
The archive should contain an index.html file at the root level.--webapp-metadata: optional path to metadata file for the webapp (can be any binary format).This alternative to the TypeScript/webpack build process allows you to provide your own pre-compressed webapp archive.
Example: Publishing a delegate:
fdev publish \
--code path/to/my_delegate.wasm \
--parameters delegate_params \
delegate \
[--nonce ... --cipher ...]
--nonce and --cipher, a default local-only encryption is used (fine for tests, not recommended for production).By default, fdev publish pushes in local mode unless you specify --mode network or set MODE=network.
To push a state delta to an existing contract (identified by its Base58 key):
fdev execute update <BASE58_CONTRACT_KEY> \
--delta path/to/delta \
[--address 127.0.0.1 \
--port 50509 \
--release]
--delta: The state delta file (JSON or binary).--release indicates you want to push to the network, instead of local-only.Sometimes you only want to build the “state artifact” for a contract or a web front-end. fdev build can do this if your freenet.toml includes a state-sources or webapp config.
Older Freenet docs mention build_state as a separate script, but in practice you can do:
# Build a web-based front end
fdev build \
--input-metadata-path /optional/metadata \
--input-state-path contracts/freenet-microblogging/view/web \
--output-file contracts/freenet-microblogging-web/freenet_microblogging_view \
--package-type contract # or 'webapp' if your config demands
Similarly, you can specify --state for a model-only contract:
fdev build \
--input-state-path contracts/freenet-microblogging/model/ \
--output-file contracts/freenet-microblogging-data/freenet_microblogging_model
(Adjust paths, actual flags, and config to match your usage.)
fdev inspect prints metadata about a built WASM artifact, such as its hash, version, or a derived contract key.
Examples:
# Show code hash + contract API version
fdev inspect code path/to/contract.wasm
# Display the contract key (hash+empty params => key)
fdev inspect key path/to/contract.wasm
# For a delegate
fdev inspect delegate path/to/delegate.wasm
fdev wasm-runtime provides a local, interactive environment to test your contract. For instance:
fdev wasm-runtime \
--input-file /tmp/input \
--deserialization-format binary \
--terminal-output
--mode, --address, --port if needed).put, get, update, or exit—are forwarded to the local node.--input-file.Common subcommands once inside the TUI:
help # print instructions
put # publish a fresh contract state
get # retrieve the current contract state
update # apply a delta to the contract state
exit # quit TUI
You can list a node’s open connections:
fdev query
It prints a table of peer identifiers and socket addresses for debugging or analysis.
fdev test orchestrates an entire simulated network of Freenet nodes for end-to-end testing.
Spins up multiple in-memory nodes under one process:
fdev test \
--gateways 2 \
--nodes 10 \
--events 100 \
single-process
fdev test \
--gateways 2 \
--nodes 10 \
network
fdev test ... network --mode supervisor).--mode peer) connecting to the supervisor. This can scale across multiple machines or containers.(See internal documentation or run fdev test --help for more detail.)
fdev network-metrics-server [--log-directory path]
55010) for collecting or pushing network stats and event logs.Here’s a quick look at the major modules in the fdev crate:
fdev
├── src
│ ├── main.rs # CLI entrypoint, top-level subcommands
│ ├── config.rs # Config structs, subcommand definitions
│ ├── commands/ # 'put', 'update', connect to node, etc.
│ ├── build.rs # Builds Rust WASM, web assets, etc.
│ ├── wasm_runtime/ # Local TUI runtime for testing contracts
│ ├── testing/ # Tools for single vs multi-process simulations
│ ├── network_metrics_server # Optional server for collecting network stats
│ └── util.rs # Shared utility helpers
└── Cargo.toml
Below are a few typical steps you might perform:
fdev new contract
fdev build
fdev publish \
--code build/freenet/my_contract.wasm \
contract \
--state initial_state
fdev execute update <contract_key> \
--delta path/to/delta.json
fdev inspect code build/freenet/my_contract.wasm
fdev wasm-runtime \
--input-file my_input.json \
--terminal-output \
--deserialization-format json
fdev query
fdev test --nodes 5 --gateways 1 single-process
fdev network-metrics-server --log-directory /path/to/logs
Feel free to run fdev <subcommand> --help for more details on any step. Enjoy building with Freenet!Below is a comprehensive README for fdev that combines the existing reference documentation and the original README content. You can drop it in place of your current README.md.
The Freenet Development Tool (fdev) is a command-line utility to create, build, publish, inspect, and test Freenet contracts or delegates. It also supports local node simulations, a TUI-based WASM runtime, and optional network metrics gathering.
fdev helps Freenet developers:
Usually you'll build fdev as part of the Freenet project:
freenet-core/main/crates/fdev.cargo build --release
./target/release/fdev --help
Or place target/release/fdev on your PATH.If you want to try out a contract in local mode, you typically run a separate “local node” process that listens for contract commands. There is a local-node executable (or an equivalent) in the Freenet repository. You can do something like:
# Example: run the local node (CLI options may vary)
local-node local-node-cli --help
Once the local node is up, you can run fdev or a script to send commands to it.
Below is a legacy style example (paths/names may differ in current code):
# Example: older usage for local node exploration
./fdev run-local \
--input-file /tmp/input \
--terminal-output \
--deser-format json \
"/home/.../freenet/crates/http-gw/examples/test_web_contract.wasm"
In newer code, you will likely use fdev wasm-runtime, described in a later section, to do an equivalent local testing workflow.
fdev new scaffolds a new Freenet package. Two options:
contract: A standard WASM contract.webapp: A contract container that also bundles a front-end (TypeScript/webpack by default).Example:
fdev new contract
Generates Rust cargo boilerplate (and for web apps, TypeScript/webpack scaffolding too).
Use fdev build to compile a Rust-based WASM contract or delegate. For example:
fdev build \
--package-type [contract|delegate] \
[--features some_features] \
[--debug] \
[--version 0.0.2]
--package-type defaults to contract.--features can specify crate features, e.g. freenet-main-contract or freenet-main-delegate.--debug produces an unoptimized WASM (useful for local tests).--version sets the embedded Freenet ABI version (defaults to 0.0.1).fdev looks for a freenet.toml in your current directory that defines if your contract is standard or a webapp, and (for webapps) how to compile front-end code.
After building, the output artifact is typically placed in build/freenet/ unless overridden by your config file.
fdev publish uploads a new contract or delegate to a node (either local or network mode).
Example: Publishing a contract:
fdev publish \
--code path/to/my_contract.wasm \
--parameters path/to/params.json \
contract \
--state path/to/initial_state.json
--code: path to your built WASM.--parameters: optional contract parameters.--state: optional initial state JSON or binary.Example: Publishing a delegate:
fdev publish \
--code path/to/my_delegate.wasm \
--parameters delegate_params.json \
delegate \
[--nonce ... --cipher ...]
--nonce and --cipher, a default local-only encryption is used (fine for tests, not recommended for production).By default, fdev publish pushes in local mode unless you specify --mode network or set MODE=network.
To push a state delta to an existing contract (identified by its Base58 key):
fdev execute update <BASE58_CONTRACT_KEY> \
--delta path/to/delta.json \
[--address 127.0.0.1 \
--port 50509 \
--release]
--delta: The state delta file (JSON or binary).--release indicates you want to push to the network, instead of local-only.Sometimes you only want to build the “state artifact” for a contract or a web front-end. fdev build can do this if your freenet.toml includes a state-sources or webapp config.
Older Freenet docs mention build_state as a separate script, but in practice you can do:
# Build a web-based front end
fdev build \
--input-metadata-path /optional/metadata \
--input-state-path contracts/freenet-microblogging/view/web \
--output-file contracts/freenet-microblogging-web/freenet_microblogging_view \
--package-type contract # or 'webapp' if your config demands
Similarly, you can specify --state for a model-only contract:
fdev build \
--input-state-path contracts/freenet-microblogging/model/ \
--output-file contracts/freenet-microblogging-data/freenet_microblogging_model
(Adjust paths, actual flags, and config to match your usage.)
fdev inspect prints metadata about a built WASM artifact, such as its hash, version, or a derived contract key.
Examples:
# Show code hash + contract API version
fdev inspect code path/to/contract.wasm
# Display the contract key (hash+empty params => key)
fdev inspect key path/to/contract.wasm
# For a delegate
fdev inspect delegate path/to/delegate.wasm
fdev wasm-runtime provides a local, interactive environment to test your contract. For instance:
fdev wasm-runtime \
--input-file /tmp/input.json \
--deserialization-format json \
--terminal-output
--mode, --address, --port if needed).put, get, update, or exit—are forwarded to the local node.--input-file.Common subcommands once inside the TUI:
help # print instructions
put # publish a fresh contract state
get # retrieve the current contract state
update # apply a delta to the contract state
exit # quit TUI
You can list a node’s open connections:
fdev query
It prints a table of peer identifiers and socket addresses for debugging or analysis.
fdev test orchestrates an entire simulated network of Freenet nodes for end-to-end testing.
Spins up multiple in-memory nodes under one process:
fdev test \
--gateways 2 \
--nodes 10 \
--events 100 \
single-process
fdev test \
--gateways 2 \
--nodes 10 \
network
fdev test ... network --mode supervisor).--mode peer) connecting to the supervisor. This can scale across multiple machines or containers.(See internal documentation or run fdev test --help for more detail.)
fdev network-metrics-server [--log-directory path]
55010) for collecting or pushing network stats and event logs.Here’s a quick look at the major modules in the fdev crate:
fdev
├── src
│ ├── main.rs # CLI entrypoint, top-level subcommands
│ ├── config.rs # Config structs, subcommand definitions
│ ├── commands/ # 'put', 'update', connect to node, etc.
│ ├── build.rs # Builds Rust WASM, web assets, etc.
│ ├── wasm_runtime/ # Local TUI runtime for testing contracts
│ ├── testing/ # Tools for single vs multi-process simulations
│ ├── network_metrics_server # Optional server for collecting network stats
│ └── util.rs # Shared utility helpers
└── Cargo.toml
Below are a few typical steps you might perform:
fdev new contract
fdev build
fdev publish \
--code build/freenet/my_contract.wasm \
contract \
--state initial_state.json
fdev execute update <contract_key> \
--delta path/to/delta.json
fdev inspect code build/freenet/my_contract.wasm
fdev wasm-runtime \
--input-file my_input.json \
--terminal-output \
--deserialization-format json
fdev query
fdev test --nodes 5 --gateways 1 single-process
fdev network-metrics-server --log-directory /path/to/logs
Feel free to run fdev <subcommand> --help for more details on any step. Enjoy building with Freenet!