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 is a "bridge" for running Bacalhau compute jobs via a smart contracts.
Lilypad is a ‘bridge’ to enable computation jobs from smart contracts. The aim of Lilypad v0 was to create an integration for users to call Bacalhau jobs directly from their solidity smart contracts and hence enable interactions and innovations between on-chain and off-chain compute. Lilypad v0 is a proof of concept bridge which runs off the public (free to use) Bacalhau compute network. As such, the reliability of jobs on this network are not guaranteed.
If you have a need for reliable compute based on this infrastructure - get in touch with us.
A user contract implements the LilypadCaller interface and to call a job, they make a function call to the deployed LilypadEvents contract.
This contract emits an event which the Lilypad bridge daemon listens for and then forwards on to the Bacalhau network for processing.
Once the job is complete, the results are returned back to the originating user contract from the bridge code.
See more about how Bacalhau & Lilypad are related below
Lilypad v0 Quick Start
Deployed Network Details
Lilypad Smart Contracts
Creating your own Jobs
Architecture
Lilypad v0
Lilypad v1
Lilypad Aurora v2
📚 Reference
View Lilypad v0 references
🖼️ Examples
View Lilypad v0 examples
Lilypad v0 Integrated Networks
If you have a use case for another network - please get in touch with us!
The Lilypad Events contract - used for triggering compute jobs on Bacalhau, is currently integrated to the following networks on the address specified:
Chain Name
LilypadEvents Contract Address
RPC
ChainID
BlockExplorer
Faucet
Filecoin Calibration Net (testnet)
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
314159 (0x4cb2f)
,
Filecoin Mainnet
0xc18879C0a781DdFa0258302467687413AaD5a4E6
, ,
314 (0x13a)
, , ,
Requires Filecoin token
Mantle Testnet
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
5001 (0x1389)
Sepolia Testnet
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
, , , see
11155111 (0xaa36a7)
, ,
Polygon Mumbai
0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820
see
80001 (0x13881)
,
Polygon Mainnet (coming soon)
see
137 (0x89)
Requires MATIC tokens
Optimism (coming soon)
see
10(0xa)
Requires OP tokens
Arbitrum One (coming soon)
see
42161 (0xa4b1)
Requires ARB tokens
\
Running a Stable Diffusion Job from a smart contract with Lilypad v0
Open this contract in Remix -> Click here
This example uses the Stable Diffusion Docker image found on the Bacalhau Docs.
For more info on how to create the Stable Diffusion Script and Docker Image see this tutorial or watch the video below.
This example can be found in the Examples folder in the Lilypad Project Github.
To run this example, you can simply deploy it to any supported network and pass in the contact address to the constructor which corresponds to your network. See Deployed Network Details.
Open this example in remix -> click here
In this example the Lilypad Stable Diffusion Job Results are returned as an IPFS v0 CID. You can use Brave browser or an IPFS gateway to see the results.
For example for a given return CID, type the following into your browser url
In Brave: ipfs://[CID]
In Other Browsers: www.w3s.link/ipfs/[CID]
or www.ipfs.io/ipfs/[CID]
A folder of the Outputs will be shown:
You can also access the image directly by navigating to
In Brave: ipfs://[CID]/outputs/image0.png
In Other Browsers: www.w3s.link/ipfs/[CID]
or www.ipfs.io/ipfs/[CID]/outputs/image0.png
Stable Diffusion
Drand Off-chain Voting
Ethereum Address Fraud Detector
Running a fraud detection job with Lilypad
Open this contract in Remix ->
This example uses the Fraud Detection Docker image found on .
Run the Image with Bacalhau using the command bacalhau docker --network=http --domain=api.etherscan.com run hakymulla/hackfs:inference -- python predict.py --address "0x427aE6048C7d2DEd45a07Ea46F2873d0F9ddDb35"
Run Bacalhau get [Job ID] to the format of the spec needed to call runLilypadJob
.
For more info on the dataset, how to create the Fraud Detection Script and Docker Image see .
This example can be found in the Examples folder in the Lilypad-v0 Project Github.
To run this example, you can simply deploy it to any supported network and pass in the contact address to the constructor which corresponds to your network. See deployed-network-details.md
.
Open this example in remix ->
To Deploy on Filecoin Calibration Net, use the LilypadEvents Contract Address deployed on the testnet (0xdC7612fa94F098F1d7BB40E0f4F4db8fF0bC8820).
Call the IsFraudDetector function and add an Ethereum Address as input.
IsFraudDetector is a payable function that calls the the bridge runLilypadJob.
In this example the Lilypad FraudDetection Job Results is returned as a StdOut. You can use the allResult function to see the results.
Let's build on the above example by Creating and Interacting with Tableland table using smart contracts.
During contract deployment, a tableland table is created. The bridge while calling the lilypadFulfilled also saves the results of inference to the table which can be used to monitor the model perfomance.
Storing a reference to the table ID and prefix within your contract is advisable since it enhances ease of reference in different methods, facilitating smoother execution.
The TablelandDeployments contract helps set up the TablelandTables interface by returning ITablelandTables instantiated with the correct registry address, inferred by the chain being used. This is added to the constructor. The table columns includes an id, address and the result.
A insert function is created to write to the above table
notice the onlyBridge modifier, only the bridge can write to the table and happens during the call back.
The above insert function is called in the lilypadFulfilled function
Open this example in remix ->
Query the table on .
📚 Reference
View Lilypad v1 references
🖼️ Examples
View Lilypad v0 examples
Creating Bacalhau Job Spec's
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.
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.
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 JSON job specification for a Stable Diffusion job which runs in a Docker container, requires no verification and publishes to Estuary.
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.
There is a full complement of example jobs you can leverage on the Bacalhau Docs Site
Try out
YOLO
OCR
Video Editing
and many, many more!
Implementing an unbiased off-chain voting process using Lilypad and Bacalhau, with Drand Time-lock encryption
This example illustrates how DeFi Kicks leverages Lilypad, Bacalhau, and Drand to implement an unbiased off-chain voting mechanism. The purpose of using these technologies is to ensure that voting happens in an unbiased, decentralized manner, thus promoting true democracy within the DefiKicks ecosystem.
The contracts and docker images have also been added as an example in Lilypad Github
For more info on DeFi Kicks and their use of Lilypad, see the DefiKicks Github
The DeFi Kicks project utilizes a three-step mechanism to ensure an unbiased voting system. Here's a summarized outline of how it operates:
The voting process is performed off-chain to maintain efficiency and privacy. Users cast their votes by encrypting them on the front end, signing the message for authenticity, and then sending them to be stored. Time-lock encryption is utilized, making the vote only decryptable after a predetermined amount of time, which ensures fairness and protects against any attempts to tamper with the votes.
Once the voting phase for a proposal has ended, anyone can request a vote resolution. This action requires a certain fee and can only be performed if the vote is in the ResolutionToRequest state. This fee covers the usage of Lilypad and Bacalhau for off-chain vote resolution.
Once a vote resolution request has been submitted and the necessary fee paid, Bacalhau, via Lilypad, takes care of the off-chain resolution. It processes the vote data, decrypting the votes when the predetermined time has elapsed, and generates the final voting results. This off-chain resolution ensures a high level of security and accuracy, providing an unbiased outcome for the voting process.
In summary, this mechanism leverages the strengths of off-chain voting and resolution in a decentralized environment, guaranteeing privacy, fairness, and tamper resistance in the voting process, which are all critical to maintaining the trust and integrity of the DeFi Kicks project.
Vote details are packaged into a message object and signed cryptographically. This message is then encrypted using a time-lock mechanism, which ensures decryption only after a certain time. The encrypted vote, along with the user's account details and signature, are stored as a vote object. Lastly, the new vote is stored and the system is notified.
The following code snippet shows how the off-chain voting mechanism is implemented in the frontend of the DefiKicks application. The original code can be found in the DefiKicks Github
Once the off-chain voting phase has ended anyone can request it's resolution by calling the requestVoteResolution
function in the Governor smart contract. This function in turn will trigger a Lilypad job that will fetches all the votes and resolve the voting process.
The Lilypad job is defined as docker image that runs a javascript script that fetches all the votes and resolves the voting process. We will go into the details of the script in a later section.
The Lilypad job spec is dinamically built to send the proposal ID as environment variable together with a node url used to fetch the vote power of each voter. The node url is also used to fetch the proposal details from the chain.
See the original smart contract for more details.
The script run in Bacalhau perform the following steps:
Retrieve all the off-chain votes from a decentralised storage (Ceramic stream or IPFS)
Decrypt the votes using Drand timelock decryption function
Verify the signature of the decrypted vote
Compute the vote power of each voter
Compute the vote result using the vote power of each voter
Compute the inflationary rewards for each voter that voted for the winning option
Put the reward information in a Merkle tree and compute the Merkle root together with the proof for each voter
Encode all the information in a hex string and console.log it as this is the stdout that will be sent back to the Governor smart contract by the Bacalhau operators that run the job.
Here is the vote decryption and verification code, for the full script see the original script
Once the job is picked up by the Bacalhau operators and executed, the resolutions are brought on-chain and the Governor smart contract receives a lilypadFulfilled
callback from Lilypad.
The _result
string contains all the vote resolution information encoded in a hex string. The string is decoded and the resolution information is stored in the smart contract.
For more information on how the result is decoded see the original smart contract
The Lilypad v0 Smart Contracts
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
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 LilypadEvents
in your own contract by passing the public contract address above to the LilypadEvents
constructor. See Deployed Network Detailsfor address details
To make a call to Bacalhau, call runLilypadJob
from your function. You need to pass the following parameters:
_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
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.
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.\
_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 docs for more information on creating a job spec.
_resultType
The type of result that you want to be returned - specified in the LilypadCaller Interface. 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.
Open LilypadEvents Contract in Remix -> Click here
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.
Open the LilypadCaller Interface in Remix -> Click here
Get started with Lilypad v1
The cloud is just somebody else's computer...
This guide will take you through
Setting up Metamask Wallet for the Lilypad Lalechuza (eth) Testnet
Funding your wallet with Lilypad Testnet tokens from the faucet.
Docker & Lilypad, Private Key
Supported platforms: Linux, macOS, WSL2 on both x86_64 and arm64
Docker installed & running
Get your private key from MetaMask: Accounts -> Account Details -> Show private key
Set your private key in terminal
You can verify you have set it with:
How to run a cowsay job from a Smart contract!
Open the Contract
Click this link to open the ExampleClient.sol contract in remix
Alternatively, open the Remix IDE in your browser and copy in the below ExampleClient.sol contract:
Connect to the Testnet
Connect MetaMask to the Lalechuza testnet & ensure you have testnet lilETH funds.
In the deploy tab in remix [fourth tab in the side bar], ensure you set the environment to "Injected Provider - MetaMask"
Deploy the Contact In remix, compile the ExampleClient.sol contract [third tab in the side bar]
Deploy a new contract by pasting in the Modicum contract address (found here) to the constructor
Deploy an existing ExampleClient.sol contract by using the "At Address" with the following pre-deployed contract address: 0x035C7593D3355b9bE0459dF2296053f887d051f1
Call the runCowsay function
The moment of truth! Let's run the cowsay example!!
Then add the string parameter for what you want the cow to say and click the transact button! Your MetaMask wallet should pop up asking you to confirm the transaction.
Wait a couple of minutes for the job to complete on the compute network. Then you will be able to click the fetchAllResults button to get your IPFS CID result.
Open the string starting with "https://ipfs.io/" in your browser which contains the output of the compute job:
The cowsay result is found under "stdout"
Congrats!
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.
_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
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.
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.
A cowsay job
The following is how to run the "Hello, World!" Job from the Lilypad CLI.
To Run from a smart contract skip to the section [Smart Contract] Run "Hello, World!" Job
Start Docker
Open a Terminal window and run the following command:
Ensure your user is in the docker group if necessary on your platform
Results:
Navigate to the IPFS CID result output in the Results -> https://ipfs.io/ipfs/QmNjJUyFZpSg7HC9akujZ6KHWvJbCEytre3NRSMHzCA6NR
Patience! This could take up to a minute to propagate through the IPFS network.
Then click on the stdout folder and you should see the job result!
Connecting to LaLechuza Testnet
Install MetaMask Extension here
Next, add the Lalechuza testnet chain to MetaMask.
Network name: Lilypad Lalechuza testnet
New RPC URL: http://testnet.lilypadnetwork.org:8545
Chain ID: 1337
Currency symbol: lilETH
Block explorer URL: (leave blank)
To do this, open MetaMask then click on the network button at the top left of the popup (in the menu bar):
Then click the "Add Network" Button.
Next, click on "Add a network manually" at the bottom of the page and enter the Lilypad Testnet details:
Trustless Distributed Compute for web3
Lilypad is a powerful trustless distributed compute platform which leverages key features of blockchain to enable developers to call arbitrary verifiable compute jobs directly from their smart contracts! Lilypad's initial focus is on bringing together the current demand for GPUs (from AI & ML) with decentralised physical infrastructure networks like Filecoin which can supply this demand.
The ability to perform off-chain decentralised compute over data from smart contracts opens the door to a multitude of possible applications including:
Inference AI jobs
ML training jobs
Invoking & supporting generic ZK computations
Cross-chain interoperability complement to bridge protocols
Utilising inbuilt storage on IPFS
Federated Learning consensus (with Bacalhau insulated jobs)
IOT & Sensor Data integrations
Providing a platform for Digital twins
Supply chain tracking & analysis
ETL & data preparation jobs
How we see Lilypad network operating on a high level
Lilypad v1 is currently in early testnet phase and is a custom implementation of the ideas & code contained in the paper: "Mechanisms for Outsourcing Computation via a Decentralized Market", which proposed a mediator approach to resolving consensus of deterministic jobs, and also offers insights into running non-deterministic jobs.
See the for more info
Currently, two testnets are functional, both of which allow arbitrary untrusted nodes to join, but use a set of mutually trusted mediators to check jobs using verification by replication (see MODICUM paper for details).
Lalechuza - a testnet built on geth
Larana - a testnet built on Filecoin IPC (an advanced scaling solution for blockchain that implements a subnet pattern)
Lilypad Testnet Architecture
This page is a dynamic work in progress! We're working on some better diagrams!
See the & for further information on how the MODICUM architecture was enhanced in implementation
See for more information on how Bacalhau operates
Ideas and Guides for Contributing to Lilypad
Here's some ideas for what you could build with Lilypad v1!
Contribute a Module to Lilypad!
We're sorry about these docs... we're actively working on it!
Create a gasless transaction pipeline with Bacalhau
Build new features for Waterlily.ai
A cowsay job
Ensure you have installed all requirements
Start Docker
Open a Terminal window and run the following command
Ensure your user is in the docker group if necessary on your platform
Output:
This could take up to a minute to propagate through the IPFS network. Please be patient
Then click on the stdout folder and you should see the job result!
Run a node to provide job services
Currently runs on Linux, macOS, WSL2 - but only x86_64 architectures
To contribute your resources to the network and get paid:
That's it! This will run a Lilypad docker node on your local machine which can accept and run jobs.
As a resource provider:
I register my resource offer and send my deposit against that single offer
The offer is matched with a job and I run the job
if I ran the job properly - I get my deposit back AND the cost of the job
if I was caught cheating - I will lose my deposit
Current State
You can read a much more thorough and academic explanation on these ideas in the and
This page also comes with a warning:
There is currently no verification on smart contract-called Lilypad jobs
Verification DOES exist on the CLI version, however.
How can nodes be trusted to do the compute job?
A resource provider node (compute node), is currently required to put down a deposit of funds before any compute jobs arrive.
On a network of compute nodes, there is also mediator nodes, whose job is to check that nodes in the network are correctly running the submitted jobs (eg. by running the job itself to check for correctness)
While not every job will take the same amount of time or compute resources to run, currently the network prices all jobs at the same amount. This will change in future versions to more accurately calculate and charge for the compute resource requirements of a job as well as compensating the compute nodes appropriately.
Running a Hello, (cow) World! Example
First, ensure you set remix to pay 2 lilETH to the function by setting the "value" field
See the Results
Click Save.
Good first project
Moderate skill needed
God mode!
Build cowsay as a service! -> see
Stable diffusion as a service (text to image) -> see
Use Stable diffusion fine tuning as a service (e.g. give me pics of you and add a beer or whatever, via LoRA) - this is a distributed compute network that triggers from a smart contract and that ACTUALLY CONSUMES DATA FROM IPFS and writes output data as CIDs and consumes them from inference - this is breakthrough computing!
Filecoin data prep: integrate with Filecoin service providers (requires knowledge of Filecoin Storage Market) -> see
Build a Javascript wrapper for the CLI
Advanced: arbitrary WASM - write your own code and compile it to WASM and run it
God Mode: Contribute a module (see below)
See
Peruse the page!
Yay we're rich!
Navigate to the IPFS CID result output in the Results ->
We didn't want to hold back on releasing a testnet build that developers could use straight away to build their awesome ideas on, however, it's worth noting that Lilypad v1 is a minimal modicum-based testnet and the implemented mediation and game theory on this testnet is very much at baby stage - as are many other aspects of the robust compute network that we are working hard to build.
Fun fact: This is also why all jobs on the network currently need to be deterministic!
If a resource node is found to have cheated and not run the job, the penalty for doing so is high & their deposit is significantly slashed. While not every job will be verified for truthiness, a good analogy is to think of a train ticket inspector on a train. You may not always have your ticket checked, but if the fine for not buying a train ticket is high enough (let's say several ether!), then you will more than likely spend a small amount of Gwei buying the ticket, rather than risking the fine and being kicked off the train. Currently, the mediation (or checking that nodes in the network are correctly running submitted jobs) that happens on a smart contract called job is provided by a Lilypad default mediator. However, if you don't trust our mediator then you can run your own mediator and run compute nodes that trust your mediator instead.
Read more about these ideas in the &
Overview
Architecture Diagrams
Get Started
Win Hacks & Contribute to Lilypad
Verification, Mediation & Job Pricing on Lilypad v1
Run in a deterministic environment
Ensure you have installed all requirements [CLI] Install Run Requirements
Lilypad serves as a verifiable, trustless, and decentralized computational network engineered to facilitate mainstream adoption of web3 applications. By extending unrestricted, global access to computational power, Lilypad strategically collaborates with decentralized infrastructure networks, such as Filecoin, to formulate a transparent, efficient, and accessible computational ecosystem. While Lilypad does not specifically resolve issues related to the accessibility of AI models, it significantly alleviates challenges associated with procuring high-performance AI hardware. In this context, Lilypad provides decentralized AI computational services. The network recently unveiled its second version, dubbed Lilypad V2 (Aurora), and is actively laying groundwork for multi-chain integration and the deployment of an incentivized test net.
Lilypad aims to mitigate the challenges predominantly associated with the accessibility of high-performance computational hardware. At present, numerous barriers impede developers and organizations from seamlessly integrating projects that require high-performance computing, such as AI technologies, into their applications. Unlike conventional centralized systems, where access to powerful compute hardware is restricted and costly, Lilypad endeavors to democratize this access. Through its verifiable, trustless, and decentralized computational network, Lilypad extends unrestricted, global access to computational power. By leveraging decentralized infrastructure networks such as Filecoin, Lilypad is strategically positioned to enhance the efficiency, transparency, and accessibility of high-performance computing hardware.
Perform off-chain decentralised compute over data, with on-chain guarantees, and to call this functionality directly from a smart contract, CLI and an easy to use abstraction layer, opens the door to a multitude of possible applications including:
Inference AI jobs
ML training jobs
Invoking & supporting generic ZK computations
Cross-chain interoperability complement to bridge protocols
Utilising inbuilt storage on IPFS
Federated Learning consensus (with Bacalhau insulated jobs)
IOT & Sensor Data integrations
Providing a platform for Digital twins
Supply chain tracking & analysis
ETL & data preparation jobs
Some of the key features of Lilypad include:
Verifiable Trustless Decentralized Compute Network: Lilypad is a decentralized compute network that aims to provide global, permissionless access to compute power. It leverages decentralized physical infrastructure networks like Filecoin to ensure trustlessness and verifiability.
Mainstream Web3 Application Support: Lilypad is designed to enable mainstream web3 applications to use its compute network. It aims to make decentralized AI more accessible, efficient, and transparent for developers and users.
Open Compute Network: Lilypad creates an open compute network that allows users to access and run AI models and jobs. It separates module creators from users and curates a set of deterministic modules for users to run, ensuring determinism in verification systems.
Multichain Support: Lilypad plans to go multichain, which means it will support multiple blockchain networks. This will increase the scalability and interoperability of the network, allowing users to choose the blockchain that best suits their needs.
Incentivized Test Net: Lilypad has plans to launch an incentivized test net, which will provide users with incentives to participate in testing and improving the network. This will help identify and address any issues or challenges before the mainnet launch.
Decentralization of Mediators: The team also aims to decentralize the mediators in the network. This means that the decision-making process and governance of the network will be distributed among multiple participants, ensuring a more decentralized and resilient system.
In the video above, Ally Haire, Co-Founder of Lilypad, will provide an introduction to the project and its goals.
Filecoin Data Prep
Code not tested.
The Filecoin Data Prep Module is designed to chunk data into CAR files from an S3 bucket - hence the name, since it prepares the data to be uploaded to Filecoin. The repo for this module can be found here.
Ensure you have installed all requirements [CLI] Install Run Requirements
Run the module
Execution:
Results:
A Fast Chat LLM Inference Module for Lilypad
This LLM Inference Module is a community-contributed module developed at AugmentHack.xyz The repo for this module can be found here.
See the original AugmentHack entry below:
Usage:
Inputs:
Where "paramsStr" is a question in CID form for the LLM. For example https://ipfs.io/ipfs/QmcPjQwVcJiFge3yNjVL2NoZsTQ3GBpXAZe21S2Ncg16Gt is a bare file CID which contains
To use it you would run:
Outputs:
The output will be an IPFS CID, for example running the above input would result in the following link:
https://ipfs.io/ipfs/QmVNXCAfJgER6U7Z5XT8QaAVFPdwmtSFE6c9sUaAx7ttZs
Under link/output/result.json you will see
Run a Stable Diffusion Text to Image Job
Generically, stable diffusion is what happens when you put a couple of drops of dye into a bucket of water. Given time, the dye randomly disperses and eventually settles into a uniform distribution which colours all the water evenly
In computer science, you define rules for your (dye) particles to follow and the medium this takes place in.
Stable Diffusion is a machine learning model used for text-to-image processing (like Dall-E) and based on a diffusion probabilistic model that uses a transformer to generate images from text. There are several open-source stable diffusion models out there (made famous by Stability.ai) and they continue to improve and become even more fully featured - SDXL0.9 is one of the more recently open-sourced models.
Ensure you have installed all requirements [CLI] Install Run Requirements
To run stable diffusion use the SDXL module like so:
The output will look like this:
Take the ipfs link given in the results and paste it into your browser:
Please be patient! IPFS can take some time to propagate and doesn't always work immediately.
In the /outputs folder, you'll find the image:
Since modules are deterministic, running this command with the same text prompt will produce the same image, since the same seed is also used (the default seed is 0).
See this beginner-friendly article on how seed's work for more info on this
To change the image, you can pass in a different seed number:
Make sure you have connected to the Lalechuza testnet and funded your wallet with testnet lilETH. See Funding your Wallet from Faucet & Setting up Metamask
To trigger the SDXL0.9 module from a smart contract, firstly you need to create your own client contract to call the module from. In order to receive results back from the Lilypad network, you will also need to 1. Connect to the Lilypad Modicum Contract (and create an instance of it in your own contract using the current address found here) 2. Implement the Modicum Contract receiveJobResults() interface.
NB: You could also add the seed as a parameter to run this.
return remoteContractInstance.runModuleWithDefaultMediators{value: msg.value}("sdxl:v0.9-lilypad1",``
params
);
Try it yourself!
Click this link to open the contract in Remix IDE!
Ensure your MetaMask wallet is set to the Lalechuza testnet and has lilETH testnet funds from the faucet.
Set the remix environment to "Injected Provider - MetaMask" (& ensure MetaMask has the lalechuza chain selected)
Then
- Deploy a new contract passing in the Modicum Contract address found here OR
- Open the contract at this example address: 0x31e7bF121EaB1C0B081347D8889863362e9ad53A
Call the runSDXL Module, passing in a prompt and sending 2 lilETH in the value field. Your MetaMask wallet should pop up for you to confirm the payment and transaction.
Give it some time and check the resultCID variable. You can then open this result in your browser with https://ipfs.io/ipfs/<resultCID> or ipfs://<resultCID> in IPFS compatible browsers like Brave.
FYI! You can try all examples in one contract. See [Smart Contract] Run "Hello, World!" Job
Find the SDXL module code here. There's also a generic Stable Diffusion module here.
Contribute your own module to Lilypad
Contributing your own module is currently a non-trivial process. The Lilypad team is aiming to make this DX easier as well as to add tutorials, walkthroughs and approaches to making modules over the next month. In the meantime if you try this and do get stuck - please reach out to us in for help!
Contributing your own module to use on Lilypad is possible and welcome! Essentially modules on Lilypad currently operate like Job Specifications do - take a look at this page on to see more about how this works.
Modules should be either Docker or WASM Images that align to the Bacalhau job specifications (which then have some added metadata that defines the runtime options of the module).
Here is an example of the SDXL module in python:
It's a function that given a "string" will return a docker job spec. That string can be whatever you want, JSON, csv, raw LLM prompt etc. In terms of output directories - you can see the SDXL example linked above names the "/outputs" folder and then will use that path in the command inside the Docker container. Any named folders like this that the Docker image can write files into - will be included as part of the results Lilypad gets back out of the job (and will change the result hash)
It's currently advisable to develop your module with first (because it's FAR easier to get setup as a development environment than Lilypad is currently). If you can get a function like the one shown above that will, given a string, write a bacalhau job spec that you can test with the bacalhau CLI - then you have already done 98% of the Lilypad module
To add this to Lilypad, submit a PR which also includes this file .
From Lilypad incentivised testnet [Q4 2023] onwards (and perhaps even earlier), its probable modules contributed by community members will be eligible for a % fee of jobs that run these modules in order to encourage the growth of the module ecosystem on the Lilypad Network.
Lilypad Aurora Architecture
This page is a dynamic work in progress! We're working on some better diagrams!
See the for further information on how the MODICUM architecture was enhanced in implementation
See for more information on how Bacalhau operates
The architecture of Lilypad is inspired by the research paper titled "Mechanisms for Outsourcing Computation via a Decentralized Market." The paper introduces MODiCuM, a decentralized system that allows for computational outsourcing in an open market. Just like MODiCuM, Lilypad aims to create an open market of computational resources by introducing various decentralized services like solver, resource provider, job creator, mediator, and directory services. MODiCuM's unique approach to deterring misbehavior in a decentralized environment through dedicated mediators and enforceable fines has influenced Lilypad's own design, particularly in the areas of dispute resolution and system integrity.
Abstract of the paper: Mechanisms for Outsourcing Computation via a Decentralized Market As the number of personal computing and IoT devices grows rapidly, so does the amount of computational power that is available at the edge. Since many of these devices are often idle, there is a vast amount of computational power that is currently untapped, and which could be used for outsourcing computation. Existing solutions for harnessing this power, such as volunteer computing (e.g., BOINC), are centralized platforms in which a single organization or company can control participation and pricing. By contrast, an open market of computational resources, where resource owners and resource users trade directly with each other, could lead to greater participation and more competitive pricing. To provide an open market, we introduce MODiCuM, a decentralized system for outsourcing computation. MODiCuM deters participants from misbehaving-which is a key problem in decentralized systems-by resolving disputes via dedicated mediators and by imposing enforceable fines. However, unlike other decentralized outsourcing solutions, MODiCuM minimizes computational overhead since it does not require global trust in mediation results. We provide analytical results proving that MODiCuM can deter misbehavior, and we evaluate the overhead of MODiCuM using experimental results based on an implementation of our platform.
In this insightful presentation, Luke Marsden, a core member of the Lilypad project, delves into the complex relationship between determinism and developer experience. He highlights the necessity for determinism in verification systems and discusses the challenges of implementing it during runtime. The talk also covers the project's strategy to separate module creators from end-users and to provide a curated list of deterministic modules. Key points in the roadmap like improving user experience, decentralizing mediators, and automating determinism checks are also touched upon. The presentation concludes with a live demo of running AI jobs on Lilypad V2.
Lilypad setup
Supported platforms: only supports x86_64 Linux
You may then need to set:
You may then need to set:
Verifying if the install is successful. Execute lilypad
on your terminal and it should produce the following response.
Running the most important Hello World on lilypad
Fine-tuning models from inputs.
LoRA stands for Low Rank Adaptation and is a mathematical technique to reduce the number of parameters that are trained in a model - so instead of fine-tuning all the weights that constitute the weight matrix of the pre-trained large language model, two smaller matrices that approximate this larger matrix are fine-tuned.
What this means in practice is that instead of needing to build a custom model off all the original input data material (and needed many many GPUs to do so), LoRA means you can fine-tune an existing model (such as SDXL 0.9 Stable Diffusion) to be biased towards a certain result on just one GPU.
For example, an open source Stable Diffusion model can be fine-tuned to produce images in the style of Claude Monet paintings using LoRA. Fun fact: This is how trains artist models - look how good the results are even without an up to date Stable Diffusion model like SDXL0.9!
A Claude Monet data set is available in zip form on IPFS here: ipfs://bafybeiglwmvudxxethpi46el3o5m44lrki2sjzgs7whvb6xaz6e65wm7am One of the easiest ways to upload a dataset to IPFS is to use web3.storage.
To run a LoRA fine-tuning job, just provide the training data for the job to the command:
NB: the params above should be yaml eg. {seed: 42, 'images_cid': 'Qm...'}
where images_cid contains an images.zip with training images in it.
This will output a result model CID, which can then be used to generate new images in this particular style:
Run a Stable Diffusion Text to Image Job
Generically, stable diffusion is what happens when you put a couple of drops of dye into a bucket of water. Given time, the dye randomly disperses and eventually settles into a uniform distribution which colours all the water evenly
In computer science, you define rules for your (dye) particles to follow and the medium this takes place in.
Stable Diffusion is a machine learning model used for text-to-image processing (like Dall-E) and based on a diffusion probabilistic model that uses a transformer to generate images from text. There are several open-source stable diffusion models out there (made famous by Stability.ai) and they continue to improve and become even more fully featured - SDXL0.9 is one of the more recently open-sourced models.
To run stable diffusion use the sdxl module like so:
The output will look like this:
Take the ipfs link given in the results and paste it into your browser:
Please be patient! IPFS can take some time to propagate and doesn't always work immediately.
You could also check the output folder that would have been downloaded at the end of running the job
In the /outputs folder, you'll find the image:
Since modules are deterministic, running this command with the same text prompt will produce the same image, since the same seed is also used (the default seed is 0).
To change the image, you can pass in a different seed number:
In this video, Sam demos the use of SDXL in the Lilypad network.
Try this to start!
A cowsay job on Sepolia
To acquire LilyPad tokens, follow these steps:
Visit the Lilypad Faucet at
Enter your wallet address.
Receive some LP tokens.
Set the environment variables as shown below:
Note: Ensure that you have Lilypad installed before proceeding.
To execute cowsay, use the following command:
Output:
This could take up to a minute to propagate through the IPFS network. Please be patient
by navigating to the local folder
Here, you can view the stdout
and stderr
as well as the outputs
folder for the run
Pssst... here's a question on Claude Monet you could try too ;) bafybeihu62yl76fcypidaiz35gq3yjguxawy5zzwadzvlcgpnfkuy2do3i
See more in this guide on contributing to the Lilypad project:
For an in-depth understanding, you can read the paper .
Setting up for the Lilypad v2 Aurora testnet
Funding your wallet with Lilypad Testnet tokens from the .
Running a Hello, (cow) World! Example
Ensure you have installed all requirements
Ensure you have set up your Metamask for Lalechuza Network and have funded your wallet. &
See the code repo
Yay we're rich!
Ensure you have installed all requirements
See this on how seed's work for more info on this
Note: You will need to set up your own Infura account and get your infura Api Key. You can follow the instructions
see the results by navigating to the IPFS CID Navigate to the IPFS CID result output in the Results ->
A cowsay job
Ensure you have installed all requirements Installation (CLI)
Start Docker
Open a Terminal window and run the following command
Make sure to have the following env in your shell session
Run lilypad
(ensure your user is in the docker group if necessary on your platform) Output:
see the results by navigating to the IPFS CID Navigate to the IPFS CID result output in the Results -> https://ipfs.io/ipfs/QmNjJUyFZpSg7HC9akujZ6KHWvJbCEytre3NRSMHzCA6NR
This could take up to a minute to propagate through the IPFS network. Please be patient
by navigating to the local folder
Here, you can view the stdout
and stderr
as well as the outputs
folder for the run
A cowsay job on Mumbai
To acquire LilyPad tokens, follow these steps:
Visit the Lilypad Faucet at here
Enter your wallet address.
Receive some LP tokens.
Set the environment variables as shown below:
Note: You will need to set up your own Infura account and get your infura Api Key. You can follow the instructions here
Note: Ensure that you have Lilypad installed before proceeding.
To execute cowsay, use the following command:
Output:
see the results by navigating to the IPFS CID Navigate to the IPFS CID result output in the Results -> https://ipfs.io/ipfs/QmNjJUyFZpSg7HC9akujZ6KHWvJbCEytre3NRSMHzCA6NR
This could take up to a minute to propagate through the IPFS network. Please be patient
by navigating to the local folder
Here, you can view the stdout
and stderr
as well as the outputs
folder for the run
Run an Opensource LLM!
Leonardo da Vinci
Michelangelo
Raphael
Titian
Albrecht Dürer
Sandro Botticelli
Jan van Eyck
Leon Battista Alberti
Johannes Gutenberg
Andrea Mantegna
Connecting to Lilypad v2 Aurora Testnet
Install metamask Extension here
Next, add the Lilypad Testnet chain to metamask.
Network name: Lilypad v2 Aurora testnet
New RPC URL: http://testnet.lilypad.tech:8545
Chain ID: 1337
Currency symbol: ETH
Block explorer URL: (leave blank)
To do this, open metamask then click on the network button at the top left of the popup (in the menu bar):
Then click the "Add Network" Button.
Next, click on "Add a network manually" at the bottom of the page and enter the Lilypad Testnet details:
This module is contributed by Fabri from Dub3
This module takes a voice sample as an input and can then output another voice sample for a given text prompt - in multiple languages.
The OSS Model is based on this model: https://github.com/coqui-ai/TTS
First upload a voice .wav file to IPFS
Use https://web3.storage is an easy way to upload files to IPFS. Use https://cloudconvert.com/ to convert recordings to .wav files
Here's are two voice recording examples:
Then use the command below to run the module. Note the parameters for changing the language and adding a prompt.
You should see Lilypad run something like this:
You'll find your results under the output folder:
Click Save.
Hello, (cow) World!
Hello, (cow) World! on Sepolia
Hello, (cow) World! on Mumbai
Stable Diffusion (SDXL0.9)
Mistral (LLM)
Voice Sample & Text to Voice [Dub3]
LoRA Fine Tuning
DuckDB
Arbitrary WASM
Filecoin Data Prep