A simple and lightweight FVM "oracle" using Bacalhau. We're enabling calling Bacalhau jobs from smart contracts!
This project harnesses the power of onchain compute with off-chain computations including tradional Oracle jobs, AI, ML and well any Docker or WASM job you can run on Bacalhau.
The work is primarily initially focussed on FEVM contract target.
YouTube Video Link
Contract Address: 0x75B01cAeFF294f10d21ff3429C683230e3d8C9B6
See it on Block Explorer here
Open it in Remix here
See the examples folder for how to use this in your own contracts!
Get help: FilecoinProject Slack #bacalhau or #bacalhau-lilypad channel
-
Create a contract that implements
LilypadCallerInterface
. As part of this interface you need to implement 2 functions:lilypadFulfilled
- a callback function that will be called when the job completes successfullylilypadCancelled
- a callback function that will be called when the job fails
-
To trigger a job from your contract, you need to call our
LilypadEvents
contract which the bridge is listening to. You will connect to Bacalhau network via this bridge. Create an instance ofLilypadEvents
by passing the public contract address above to theLilypadEvents
constructor. See our example. -
To make a call to Bacalhau, call
runBacalhauJob
from your function. You need to pass the following parameters:Name Type Purpose _from
address
The address of the calling contract, to which success or failure will be passed back. You should probably use address(this) from your contract. _spec
string
A Bacalhau job spec in JSON format. See below for more information on creating a job spec. _resultType
LilypadResultType
The type of result that you want to be returned. If you specify CID, the result tree will come back as a retrievable IPFS CID. If you specify StdOut, StdErr or ExitCode, those raw values output from the job will be returned.
- Bacalhau is language-agnostic, and supports Docker or WASM workloads. As long as you can run your executable in a container, you can run it in Bacalhau.
- You need to supply a Bacalhau job spec. To create a job spec, you can:
- Run a Bacalhau job successfully, and then get the job spec back using
bacalhau describe <job_id> --format=json
. - Generate a job spec without running anything, using
bacalhau docker run --dry-run
. - Writing a job spec by hand, by using our schema as a guide.
- Run a Bacalhau job successfully, and then get the job spec back using
- What can I do with Bacalhau now? You can:
- read from IPFS, Filecoin, or URLs
- write into Estuary or IPFS
We have a full complement of example jobs you can leverage on the Bacalhau Docs Site
Try out
- YOLO
- OCR
- Video Editing
- and many, many more!
See a video of this project in action here
Read more and see the presentation slides here
We've created Waterlily - an AI-Art generator that pays royalties to artists (or donations to art foundations for public works).
See it live in action waterlily.ai
We'd also LOVE to hear about what use cases you have - contact us in the FilecoinProject Slack #bacalhau or #bacalhau-lilypad channel
Contributions to this repo would also earn you many 5/5 Stable Diffusion Rainbow Unicorns (and be gratefully recieved)!
❤️ Bacalhau team: off-chain filecoin-native decentralised compute ❤️
#buildwithbacalhau