Examples
This page shares several simple examples in different programming languages that showcase how to interact with Walrus through the various interfaces. They are located at https://github.com/MystenLabs/walrus/tree/main/docs/examples and described below.
There are also actual applications built on top of Walrus, the primary example being Walrus Sites, a framework for deploying websites and hosting them through Walrus blobs. The code is available in the Walrus Sites repository.
For an example of how to build a static website and store it as a Walrus Site with GitHub actions, look at the CI workflow used to publish this documentation site. There is also a Walrus Sites GitHub action created by the community. This action is not created or officially supported by the Walrus team.
Python
The Python examples folder contains a number of examples:
- How to use the HTTP API to store and read a blob.
hello_walrus_webapi.pyFile not found in manifest:documentation/examples/python/hello_walrus_webapi.py. You probably need to run `pnpm prebuild` and restart the site. - How to use the JSON API to store, read, and check the availability of a blob. Checking the certification of a blob illustrates reading the blob's corresponding Sui object.
hello_walrus_jsonapi.pyFile not found in manifest:documentation/examples/python/hello_walrus_jsonapi.py. You probably need to run `pnpm prebuild` and restart the site. - How to track Walrus related events.
track_walrus_events.pyFile not found in manifest:documentation/examples/python/track_walrus_events.py. You probably need to run `pnpm prebuild` and restart the site.
JavaScript
A JavaScript example is provided showing how to upload and download a blob through a web form using the HTTP API.
Move
For more complex applications, you might want to interact with Walrus on-chain objects. For that purpose, deployed Walrus contracts are included in the Walrus GitHub repository.
A basic example contract showcases how to import and use the Walrus objects.