Today, we are releasing the first version of the GenLayer Simulator, a tool that will enable developers to imagine, prototype, and showcase Intelligent Contracts within a controlled environment.
GenLayer is the first Intelligent Blockchain. It utilizes smart contracts that can natively connect to the Internet and understand Natural Language in order to perform complex decision-making. This new technology is called “Intelligent Contracts”.
You can read more on What is GenLayer?
In this article, we will guide you through the simulator’s installation process, showcase exciting use cases, and provide insights on how to make the most of it.
Enough talk – take me to Github!
The Simulator is an interactive sandbox designed for developers to explore the potential of GenLayer’s Intelligent Contracts. It replicates GenLayer’s development and execution environment and consensus algorithm but offers a controlled and local environment to test different ideas and behaviors. As the network’s development progresses, we will improve it to facilitate the exploration and testing of new ideas, and we invite you to participate by creating your own Intelligent Contracts or prototyping ideas on consensus or economics.
What you can do with the GenLayer Simulator:
Currently, the Simulator does not support token transfers, contract-to-contract interactions, or gas consumption. These features will be added as the platform evolves.
The vision behind the GenLayer Simulator is to empower a community of developers who will build the future of decentralized applications. We aim to give the first demo of Intelligent Contracts’ true potential by providing a sandbox environment for experimentation and innovation. Be one of the first to try out a new class of smart contracts, Intelligent Contracts can natively connect to the Internet and perform complex decision making with Natural Language.
We invite you to join GenLayer’s Discord server and propose new ideas for Intelligent Contracts. Your feedback will play a crucial role in shaping the future of GenLayer, the Intelligence Layer of the Internet.
Let’s create the next generation of AI-powered Smart Contracts.
Here’s a step-by-step guide to get started with the GenLayer Simulator.
Prerequisites:
Installation Steps:
1. Open your terminal or command prompt and enter the following command to install the GenLayer CLI globally on your system:
npm install -g genlayer
2. After installing the CLI, set up your development environment by running:
genlayer init
This command will verify your Docker installation, prompt you to select your preferred LLM provider(s) — Llama3 (no API key required), OpenAI (key required), or Heurist (key required but we offer free credits through our partnership) — and automatically download and configure the necessary Docker containers for the GenLayer environment. Once the setup is complete, you can access the GenLayer Simulator at http://localhost:8080/. The Simulator will be downloaded into your user home folder.
To launch the Simulator with the existing configuration please follow this link to our blog post.
The GenLayer Simulator is designed to facilitate the development and testing of Intelligent Contracts. The primary sections of the simulator’s UI include:
To deploy your Intelligent Contract in the simulator:
1. Navigate to the Your Contracts section and select an existing contract or create a new one by clicking the + or upload icon.
2. Enter your contract code in the text editor and click the Run and Debug icon.
3. The constructor parameters are automatically detected from your code if defined properly.
Alternatively, you can manually write your constructor parameters in JSON format to define the initial conditions of your contract. Ensure that the keys in the JSON object match the variables expected by the contract’s constructor.
4. Click the Deploy Intelligent Contract button to deploy your contract to the simulated blockchain environment.
5. Once your contract is deployed, the UI will display the Intelligent Contract address and any getter function defined in your code in the Current Intelligent Contract State section. The getter function returns the current state of the specified constructor parameter. With the contract now deployed, you can invoke its functions and execute transactions as part of your testing process.
Monitor output during deployment for any execution notes or errors. Review the logs for detailed error messages if you encounter issues during the deployment.
You can find more info on how to deploy a contract here.
After deploying your contract, you can test its functionality by executing transactions:
1. In the Execute transactions section, select the contract method you want to execute.
2. If the method requires input parameters, a field will appear for you to enter the necessary values. For example, the ask_for_coin
method requires a request string.
3. After entering any required parameters, click the button to execute the method. The simulator will process the transaction and return the result.
You can find more info on how to execute a transaction here.
The GenLayer Simulator offers a playground for developers to experiment with various use cases and scenarios involving Intelligent Contracts. Let’s explore some of those use cases:
1. Wizard of Coin: The Wizard of Coin contract demonstrates how Intelligent Contracts can manage assets and interact with users in a blockchain-based environment. In this scenario, you play an adventurer, who meets a wizard. This wizard possesses a magical coin sought after by many adventurers. The contract’s logic ensures that the wizard never gives away the coin.
What is the cool thing about the Wizard of Coin? It has already been battle-proven at the Paris Blockchain Week, where only one Adventurer could trick the Wizard into handing out the coin!
You can already deploy this contract, we have provided instructions in our GenLayer simulator docs.
2. Fight Games: Imagine creating an Intelligent Contract that simulates battles using LLMs for decision-making. Each Fighter’s or Avatar’s stats, abilities, and moves can be stored as state variables within the contract. When you initiate a battle with your Fighter, the contract uses LLMs to determine the outcome based on the Fighters’ attributes and battle strategies.
The simulator allows you to test various scenarios, such as different matchups, move selections, and stat variations. Monitor the battle logs to ensure the LLMs make appropriate decisions and the contract accurately reflects the battle results.
3. Prediction Markets: Leverage the GenLayer Simulator to develop a decentralized prediction market powered by Intelligent Contracts. Traditional prediction markets rely on oracles or manual input. With GenLayer, contracts can directly access and analyze real-world data from the internet.
You could create a contract allowing users to place bets on future events, such as election outcomes or product launch dates. The Intelligent Contract can gather information from news websites, social media, and other relevant sources to determine the results.
4. Parametric Insurance: Develop an Intelligent Contract for parametric insurance, which pays out based on the occurrence of specific events rather than assessed damages. The contract can monitor weather data and news reports to determine if the insured event, like a hurricane or flood, has occurred in the covered area.
Use the GenLayer Simulator to test different scenarios, such as varying disaster intensities and locations.
5. Social Activity Checker: Create an Intelligent Contract that verifies users’ social media activity for on-chain identity or reward systems. The contract can read data from social media to check if a user has posted a specific message, achieved a certain number of followers, or engaged with a particular hashtag.
In the GenLayer Simulator, test the contract by simulating different user activities and social media scenarios. Ensure the contract correctly identifies and validates the required actions.
If things do not go as planned, we will be here to support you every step of the way!
We are here for your questions, feedback, or ideas! Please contact us on our Discord Channel, were we have a dedicated #simulator-support Channel for those requests. Our team is dedicated to helping developers like you use the full potential of Intelligent Contracts and the GenLayer platform. And do not forget to join the GenLayer Community on X.
Be part of the revolution! Join our community of developers, innovators, and enthusiasts to collaborate, learn, and build the future together. By participating in the GenLayer ecosystem, you’ll have access to exclusive opportunities and be at the forefront of Blockchain innovation.
Install the GenLayer CLI, dive into the GenLayer Simulator, and start testing your ideas today.
Join us on our mission!
Website | Blog | Discord | X (prev. Twitter) | Telegram | Simulator | Docs | Whitepaper