WebAssembly (Wasm) is used in Polkadot and Substrate as the compilation target for the runtime, but it's also a new smart contract platform built as an alternative to the Ethereum Virtual Machine (EVM). It's written in C, C++, or Rust and provides substantial improvements in execution speed, and the ability to use other languages than Solidity.
SubQuery has a goal of providing support for all execution environments in Substrate/Polkadot, including on chain data, smart contracts in EVM, and smart contracts in WebAssembly (Wasm). This will allow all application developers to leverage the same excellent infrastructure tools across the ecosystem to build the next generation of applications.
You will create a new instance of a data processor similar to the existing Substrate Frontier EVM processor. It must connect to to Gear Wasm contract pallet (and ideally also work on other Wasm contracts pallets) and process the messages from the Wasm execution in a similar way to how messages from the Substrate Frontier EVM processor are processed. You should then be able to use these in a handlers just like how a traditional SubQuery project works
A working project manifest might look like the following:
dataSources:
- kind: substrate/Wasm
startBlock: 1
processor:
file: "./node_modules/@subql/contract-processors/dist/substrateWasm.js"options:
# Any options relating to the smart contract we are executing
mapping:
file: "./dist/index.js"handlers:
- handler: handleWasmEvent
kind: substrate/SubstrateWasmEvent
filter:
# Any filters that make sense
- handler: handleWasmMessage
kind: substrate/SubstrateWasmMessage
filter:
# Any filters that make sense
Useful links:
Develop a DApp using a Moonbeam precompile that allows applications or Solidity smart contracts to interact with Substrate functions through a Solidity interface.