# Example ABCI Applications

[This repo](https://github.com/ConsiderItDone/LandslideCore/blob/0.34.19-lanslide-core/vm/vm.go) contains the ABCI application calls.

1. Sample App Names: There are two sample apps provided in the LandslideCore: `KVStoreApplication` and `PersistentKVStoreApplication`.
2. App Functionality: The `KVStoreApplication` is a simple merkle key-value store that allows transactions of the form `key=value` to be stored as key-value pairs in the tree. Transactions without an `=` sign set the value to the key. The app has no replay protection other than what the mempool provides.
3. Additional Features: The `PersistentKVStoreApplication` wraps the `KVStoreApplication` and provides two additional features: persistence of state across app restarts using Tendermint's ABCI-Handshake mechanism, and validator set changes. The state is persisted in leveldb along with the last block committed, and the Handshake allows any necessary blocks to be replayed. Validator set changes are effected using a specific transaction format: `"val:pubkey1!power1,pubkey2!power2,pubkey3!power3"`. In this format, `pubkeyN` is a base64-encoded 32-byte ed25519 key and `powerN` is a new voting power for the validator with `pubkeyN` (possibly a new one). To remove a validator from the validator set, set `power` to 0. There is no sybil protection against new validators joining.
4. Location: The sample apps can be found in the LandslideCore/abci/example/ directory of the Landslide SDK.

These sample apps provide developers with a starting point for building custom dApps on the Avalanche network using the Landslide SDK. Developers can use these sample apps as a reference for building their own merkle key-value store or for implementing more advanced features like persistence of state and validator set changes.

```
main.go
```

1. Package Name: The package name is `main`.
2. Imported Packages: The following packages are imported:

* `context`: This package provides functions for working with contexts, which carry deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
* `fmt`: This package implements formatted I/O with functions analogous to C's printf and scanf.
* `github.com/consideritdone/landslidecore/abci/example/counter`: This package contains the implementation for the `counter` application used by the Landslide SDK.
* `github.com/consideritdone/landslidecore/vm`: This package contains the implementation for the virtual machine used by the Landslide SDK.
* `github.com/ava-labs/avalanchego/utils/logging`: This package provides logging utilities for the AvalancheGo node.
* `github.com/ava-labs/avalanchego/utils/ulimit`: This package provides utilities for managing file descriptor limits.
* `github.com/ava-labs/avalanchego/vms/rpcchainvm`: This package provides the implementation for the RPC ChainVM.

3. Main Function: The `main` function is the entry point for the LandslideCore executable. It performs the following tasks:

* Sets the file descriptor limit using `ulimit.Set`.
* Creates a new virtual machine using `landslideCoreVM.NewVM`.
* Passes the `counter.NewApplication` as a parameter to `landslideCoreVM.NewVM`.
* Calls `rpcchainvm.Serve` to serve the virtual machine and start the RPC server.

4. Example Usage: An example usage of this code might be to build and deploy a custom dApp, like an [Osmosis](https://osmosis.zone/) outpost, or the [Helix DEX](https://helixapp.com/) on the Avalanche network using the Landslide SDK. The `counter.NewApplication` function can be replaced with a custom application implementation, and the resulting executable can be deployed on the network using `rpcchainvm.Serve`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.landslide.network/product-guides/landslidecore/example-abci-applications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
