Home

Awesome

Email Wallet Extensions Guide

The Email Wallet SDK comprises smart contracts that enhance an email wallet's functionality. This SDK enables the creation of custom extensions that can interact with any smart contracts. It supports operations like token swapping via Uniswap, NFT transfer from the email wallet, and more. Third-party developers can build new functionality of email wallet using our SDK for extensions.

Setup

To create an extension using the Email Wallet SDK, follow these steps:

  1. Create a new repository: Start by creating a new repository using our template in the repo.

  2. Clone the repository: Once the repository is created, clone it to your local machine.

  3. Install dependencies: Navigate to the cloned folder and execute yarn to install the necessary dependencies.

Modify MomoExtension.sol

After setting up the repository, the next step is to modify the src/MemoExtension.sol contract for your own implementation.

  1. Rename the contract: Rename the src/MemoExtension.sol to any name that suits your extension.

  2. Create your own extension implementation:

MomoExtension.sol is an example of the extension implementation. Each developer will need to implement actual functionality using the interface as a guide.

These functions MUST be included in your contract.

execute(uint8 templateIndex, bytes[] subjectParams, address wallet, bool hasEmailRecipient, address recipientETHAddr, bytes32 emailNullifier) external virtual

registerUnclaimedState(UnclaimedState memory unclaimedState, bool isInternal) public virtual

claimUnclaimedState(UnclaimedState memory unclaimedState, address wallet) external virtual

voidUnclaimedState(UnclaimedState memory unclaimedState) external virtual

  1. Define Subject Templates: Subject templates are an array of string arrays, i.e., a two-dimensional string array. These are defined by an extension to declare the formats of the subject that will call the extension. Each format can use a fixed string (without spaces) and the following templates.
  1. Compile the Contract: Compile the contract by running:
$ forge build

Modify the Test Codes

After modifying the extension contract, the next step is to modify the test codes.

  1. Rename the test file: Rename the test/MemoExtension.t.sol to any name that suits your extension.

  2. Modify the test codes: Update the test codes to test the functionality of your extension.

  3. Run the tests: You can run the tests by running

$ forge test

Publish the Extension

To publish your extension to our email wallet core contract, run the following command:

    PRIVATE_KEY=0x... EMAIL_WALLET_CORE=0x7A07f282Ebdc033da00EC46D602eCE742825C6dB forge script script/Deploy.s.sol --rpc-url https://arb1.arbitrum.io/rpc --chain-id 42161 --broadcast

Note: PRIVATE_KEY is the hex string of the private key used for the deployment.