Wasmer Engine

Wasmer Engine implementation in Landslide

Overview

The WasmerEngine is an important component of the CosmosSDK's support for CosmWasm, a smart contract execution environment for the Cosmos ecosystem. It is a Go implementation of the CosmWasm's WasmVM interface, which provides an API for executing WebAssembly-based smart contracts.

The WasmerEngine is responsible for handling various aspects of contract execution, such as instantiating contract instances, executing contract code, and querying contract state. It is also responsible for analyzing contract code, and providing information about the contract's capabilities and resource requirements.

In short, the WasmerEngine is a key component in allowing developers to build and execute smart contracts within the Cosmos ecosystem, enabling a wide range of decentralized applications to be built on top of the network.

Methods explained

As a user of the LandslideSDK, you can now utilize the CosmWasm WasmerEngine through the WasmerEngine interface. With the support of the WasmerEngine, you can easily create, analyze, instantiate, execute, query, migrate, sudo, reply, get code, pin and unpin your CosmWasm smart contracts in your LandslideSDK application.

To make this possible, our developers have implemented the following methods in the WasmerEngine interface:

  1. Create(code wasmvm.WasmCode) (wasmvm.Checksum, error): This method takes a WasmCode object as input and returns a checksum and an error. It is responsible for creating a new instance of a WebAssembly module from the given code.

  2. AnalyzeCode(checksum wasmvm.Checksum) (*wasmvmtypes.AnalysisReport, error): This method takes a checksum as input and returns an analysis report and an error. It is responsible for analyzing the given WasmCode to determine whether it is compatible with the CosmWasm module.

  3. Instantiate: This method creates a new instance of the CosmWasm module with the specified environment variables and returns an instance object.

  4. Execute: This method takes an instance object and an input message as input and returns the output of executing the message on the module.

  5. Query: This method takes an instance object and an input query as input and returns the result of the query on the module.

  6. Migrate: This method takes an instance object and a migration message as input and returns the result of migrating the module to a new version.

  7. Sudo: This method takes an instance object and a sudo message as input and returns the result of executing the message as a privileged operation.

  8. Reply: This method takes an instance object and an output message as input and returns the result of the reply operation.

  9. GetCode: This method takes a checksum as input and returns the code associated with the given checksum.

  10. Pin: This method takes a checksum as input and pins the associated code in memory.

  11. Unpin: This method takes a checksum as input and unpins the associated code from memory.

With these methods, you can enjoy seamless integration of the CosmWasm WasmerEngine in your LandslideSDK application, making it easier to deploy and manage your smart contracts.

Last updated

©2023 Gaia Labs LTD