Koniverse / SubConnect

Note: We have stopped further development of this version and replaced it with a new and more complete version here
https://github.com/Koniverse/SubConnect-v2
Apache License 2.0
43 stars 14 forks source link

Support WASM dApps #22

Open hieudd opened 1 year ago

hieudd commented 1 year ago

Overview

The goal is to add support for WebAssembly (WASM) dApps to SubConnect. An example of a WASM dApp is available at https://github.com/AstarNetwork/wasm-showcase-dapps.

Tasks

  1. Research the differences between a WASM dApp and a traditional dApp when connected to a Substrate or EVM wallet. Consider the following questions:
    • How do they interact with the account list?
    • How do they use signer objects published by the wallet?
  2. Implement a connector to enable WASM dApps to connect to Substrate or EVM wallets in the same way as traditional dApps.
  3. Fork the Astar dApps repository and move it into the examples folder of SubConnect.
  4. Ensure that the Astar dApp can interact with the wallet via packages/wallet-connect.
  5. Test and verify that the following features work correctly:
    • Connecting to the wallet
    • Signing data
    • Sending transactions in the EVM interface
minhtri9111199 commented 1 year ago

Researching:

  1. WASM dApps:
  1. Traditional dApps:
    • Traditional dApps typically use the Ethereum Virtual Machine (EVM) as their runtime environment, and often use the web3.js library to interact with the blockchain and wallet. The web3.js library provides a standardized way to interact with a Ethereum node and access blockchain data such as the account list, block information, and transaction data.
    • When a traditional dApp is connected to an EVM wallet, it can use the web3.js library to interact with the blockchain and query the account list. The dApp can also use the library to sign transactions and send them to the blockchain.
    • The signer object published by the wallet is used to sign transactions and prove ownership of the account. This object contains the user's private key and is typically accessed through the web3.js library.

In summary, both types of dApps use different runtime environments and libraries to interact with the blockchain and wallet. WASM dApps typically use the Substrate API and signer objects published by the wallet, while traditional dApps typically use the Ethereum Virtual Machine and the web3.js library. However, the end result is similar: both types of dApps can interact with the account list and use signer objects to sign transactions and send them to the blockchain.