examples/

directory
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: Apache-2.0

README

Synapse Go Examples

Set the environment:

export SYNAPSE_PRIVATE_KEY=0x...
# Optional. Defaults to the public Calibration RPC endpoint.
export SYNAPSE_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
# Optional. Use calibration or mainnet. Empty means auto-detect from RPC.
export SYNAPSE_CHAIN=calibration

Examples default to allowing private / local network downloads so local proxy environments can run retrieval flows. The SDK's normal client default still rejects private-network downloads unless callers explicitly opt in.

Quickstart

Upload, download, and verify a small test payload:

go run ./examples/quickstart

Upload a file instead:

go run ./examples/quickstart --file ./payload.bin

Storage Workflows

Upload a file and print the IDs and retrieval URLs needed by later workflows:

go run ./examples/upload-file --file ./payload.bin --copies 2

Download and validate a piece:

go run ./examples/download-piece --piece-cid <piece-cid> --url <retrieval-url> --out payload.bin

List datasets and the current storage account view:

go run ./examples/list-datasets --managed

Discover active PDP providers:

go run ./examples/list-providers --piece-size 1048576

Local Utilities

Inspect Filecoin piece commitment information without RPC or a private key:

go run ./examples/piece-info --file ./payload.bin

This prints PieceCIDv1, PieceCIDv2 when the payload is large enough, raw size, padded size, and the commitment root.

Full API documentation: https://pkg.go.dev/github.com/strahe/synapse-go.

Directories

Path Synopsis
Download-piece downloads a retrieval URL and verifies it against a PieceCID.
Download-piece downloads a retrieval URL and verifies it against a PieceCID.
internal
List-datasets shows the storage state for the current wallet.
List-datasets shows the storage state for the current wallet.
List-providers shows active PDP storage providers and their capabilities.
List-providers shows active PDP storage providers and their capabilities.
Piece-info calculates Filecoin PieceCID information for a local file.
Piece-info calculates Filecoin PieceCID information for a local file.
Quickstart runs the shortest complete FOC flow on Calibration: prepare funds when needed, upload data, download the first copy, and verify the bytes match.
Quickstart runs the shortest complete FOC flow on Calibration: prepare funds when needed, upload data, download the first copy, and verify the bytes match.
Upload-file uploads a local file to FOC storage.
Upload-file uploads a local file to FOC storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL