---
title: "Testing Contracts in GenLayer Studio"
description: "Test contracts and dApps interactively using GenLayer Studio and the local development environment."
source: https://docs.genlayer.com/developers/decentralized-applications/testing
last_updated: 2026-06-11
---

# Testing Contracts in GenLayer Studio

Testing Intelligent Contracts on GenLayer involves deploying contracts, sending transactions, validating their behavior, and identifying issues. Here is some guidance on how to test using the tools provided in the local development environment and GenLayer Studio.

## Testing Workflow in the Local Environment

For a more advanced and controlled testing setup, you can leverage the GenLayer Project Boilerplate and the provided test helpers.
> **Note:**
> Please note that you need the Studio running to run the tests by sending requests to it.

### 1. Create Accounts

Use the `create_new_account` helper to generate accounts for testing. These accounts simulate users interacting with the contract.

```python
from tools.request import create_new_account

account = create_new_account()
```

### 2. Set Up Validators

Validators are essential for processing transactions in GenLayer. Use the `sim_createRandomValidators` method to initialize them.

```python
from tools.request import payload, post_request_localhost

nb_validators = 5
min_stake = 8
max_stake = 12
providers = ["openai"]
models = ["gpt-4o"]
validators_response = post_request_localhost(
    payload("sim_createRandomValidators", nb_validators, min_stake, max_stake, providers, models)
).json()
```

### 3. Deploy the Contract

Deploy your Intelligent Contract using the `deploy_intelligent_contract` helper:

```python
from tools.request import deploy_intelligent_contract

contract_code = open("contracts/my_contract.py", "r").read()
contract_address, deploy_response = deploy_intelligent_contract(account, contract_code, "{}")
```

### 4. Interact with the Contract

Use `send_transaction` for writing data to the contract and `call_contract_method` for reading data:

```python
from tools.request import send_transaction, call_contract_method

# Write data
send_transaction(account, contract_address, "method_name", [arg1, arg2])

# Read data
result = call_contract_method(contract_address, account, "get_state", [])
```

### 5. Assertions

Validate the responses using provided assertion helpers:

```python
from tools.response import assert_dict_struct, has_success_status

assert has_success_status(result)
assert_dict_struct(result, expected_structure)
```

### 6. Clean Up

After completing the tests, delete the validators or reset the environment:

```python
delete_response = post_request_localhost(payload("sim_deleteAllValidators")).json()
```
