Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Lilypad v0 Integrated Networks
Chain Name
LilypadEvents Contract Address
RPC
ChainID
BlockExplorer
Faucet
Filecoin Calibration Net (testnet)
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
314159 (0x4cb2f)
Filecoin Mainnet
0xc18879C0a781DdFa0258302467687413AaD5a4E6
314 (0x13a)
Requires Filecoin token See docs
Mantle Testnet
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
5001 (0x1389)
Sepolia Testnet
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
11155111 (0xaa36a7)
Polygon Mumbai
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
80001 (0x13881)
Polygon Mainnet (coming soon)
137 (0x89)
Requires MATIC tokens
Optimism (coming soon)
10(0xa)
Requires OP tokens
Arbitrum One (coming soon)
42161 (0xa4b1)
Requires ARB tokens
📚 Reference
View Lilypad v0 references
🖼️ Examples
View Lilypad v0 examples
Lilypad v0 Quick Start
Deployed Network Details
Lilypad Smart Contracts
Creating your own Jobs
Architecture
Lilypad v0
Lilypad v1
Lilypad Aurora v2
Get Started with Lilypad v0 - Call off-chain distributed compute from your smart contract!
Note: Since this video was released some changes have been made to the underlying code, but the process and general architecture remains the same.
The Lilypad Contracts are not currently importable via npm (though this is in progress), so to import them to you own project, you'll need to use their github links
Using Lilypad in your own solidity smart contract requires the following steps
Create a contract that implements the LilypadCaller interface.
As part of this interface you need to implement 2 functions:
lilypadFulfilled
- a callback function that will be called when the job completes successfully
lilypadCancelled
- a callback function that will be called when the job fails
Provide a public Docker Spec compatible for use on Bacalhau in JSON format to the contract.
To trigger a job from your contract, you need to call the LilypadEvents
contract which the Lilypad bridge is listening to and which connects to the Bacalhau public network. Create an instance of LilypadEvents
by passing the public contract address on the network you are using (see Deployed Network Details) to the LilypadEvents
constructor.
Call the LilypadEvents contract function runLilypadJob()
passing in the following parameters.
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 successfully
lilypadCancelled
- a callback function that will be called when the job fails
There are several public examples you can try out without needing to know anything about Docker or WASM specification jobs -> see the Bacalhau Docs. The full specification for Bacalhau jobs can be seen here.
Bacalhau operates by executing jobs within containers. This means it is able to run any arbitrary Docker jobs or WASM images
We'll use the public Stable Diffusion Docker Container located here for this example.
Here's an example JSON job specification for the Stable Diffusion job:
Here's an example of using this JSON specification in solidity:
Note that since we need to be able to add the user prompt input to the spec, it's been split into 2 parts.
See more about how to onboard your Docker Workloads for Bacalhau, Onboard WebAssembly Workloads or Work with Custom Containers in the Bacalhau Docs.
You can do this by either passing it into your constructor or setting it as a variable
Using the LilypadEvents Instance, we can now send jobs to the Bacalhau Network via our contract using the runLilypadJob()
function.
In this example we'll use the Stable Diffusion Spec shown above in #add-a-spec-compatible-with-bacalhau
Note that calling the runLilypadJob() function requires a network fee. While the Bacalhau public Network is currently free to use, gas fees are still needed to return the results of the job performed. This is the payable fee in the contract.
Creating Bacalhau Job Spec's
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
.
What can I do with Bacalhau now? You can:
read from IPFS, Filecoin, or URLs
write into Estuary or IPFS
Bacalhau operates by executing jobs within containers. This means it is able to run any arbitrary Docker jobs or WASM images
Here's an example of using this JSON specification in a solidity smart contract:
Note that since we need to be able to add the user prompt input to the middle of the spec (in the Docker entrypoint), it's been split into 2 parts.
Try out
YOLO
OCR
Video Editing
and many, many more!
The Lilypad v0 Smart Contracts
lilypadFulfilled
- a callback function that will be called when the job completes successfully
lilypadCancelled
- a callback function that will be called when the job fails
To make a call to Bacalhau, call runLilypadJob
from your function. You need to pass the following parameters:
This contract is the bridge between the Bacalhau network and smart contracts & does all the heavy lifting.
Note - you cannot deploy your own version of this contract. It will not trigger Bacalhau jobs to run on its own and requires the Lilypad GO Daemon integration. You need to use the address of the deployed LilypadEvents contract within your own smart contract.
To use Lilypad, you only need to take note of one function in this events contract - the runLilypadJob(address _from, string memory _spec, uint8 _resultType)
function which takes the following parameters.\
This interface ensures that the results of a job run on the Bacalhau network via Lilypad can be returned to the originating contract. This interface needs to be implemented by a smart contract for Lilypad to run.
Name | Type | Purpose |
---|---|---|
There are several public examples you can try out without needing to know anything about Docker or WASM specification jobs -> see the . The full specification for Bacalhau jobs can be .
Bacalhau is language-agnostic, and supports or workloads. As long as you can run your executable in a container, you can run it in Bacalhau.
Writing a job spec by hand, by using our as a guide.
Here's an example JSON job specification for a Stable Diffusion job which runs in a Docker container, requires no verification and publishes to .
There is a full complement of example jobs you can leverage on the
Create a contract that implements . As part of this interface you need to implement 2 functions:
To trigger a job from your contract, you need to call the LilypadEvents
contract which the bridge is listening to. You will connect to Bacalhau network via this bridge. Create an instance of in your own contract by passing the public contract address above to the LilypadEvents
constructor. See for address details
Name | Type | Purpose |
---|
Name | Type | Purpose |
---|
Open LilypadEvents Contract in Remix ->
Open the LilypadCaller Interface in Remix ->