▣ WALLIT lite

Note: This project is a simplified and minimalistic implementation inspired by Lit Protocol and is intended for educational purposes only. For the complete implementation of Wallit Lite using Lit Protocol, please refer to the wallit-monorepo repository.

Wallit Lite is a lightweight wallet application built using Scaffold-eth. It allows users to create public-private key pairs and securely store their private keys on the blockchain. The private keys are encrypted using the user's Metamask address and a password known only to the user.

Contract - KEYRegistry.sol

The main contract of the Wallit Lite project is called KEYRegistry.sol. It is an ERC721-compliant contract that extends the ERC721 and Ownable contracts from the OpenZeppelin library. The contract includes the following important functions:

  • registerKey: Allows a user to register a new key pair. Each registered key pair corresponds to a unique non-transferable ERC721 token.

  • changeName: Allows the owner of a key token to change the name associated with that token.

  • getKeyPair: Retrieves the key pair associated with a given token ID.

  • getTokenIds: Returns an array of token IDs owned by a specific address.

Frontend Functions

Wallet Management

Wallet Creation and Encryption

  • createWallet: Generates a new random wallet.

  • encodeBase64: Encodes data into Base64 format.

  • decodeBase64: Decodes Base64 data.

  • hexToUint8Array: Converts a hexadecimal string to a Uint8Array.

  • encryptWallet: Encrypts the wallet using the provided password.

Wallet Operations

  • fetchKeys: Retrieves the registered key pairs associated with the user's address.

  • loadWallet: Loads a wallet by decrypting the encrypted key using the provided password.

Transaction Handling

ETH Transactions

  • sendETH: Sends ETH from the wallet to a specified receiver address.

ERC20 Transactions

  • sendERC20: Transfers an ERC20 token from the wallet to a specified receiver address.

  • approveERC20: Approves the transfer of an ERC20 token from the wallet to a specified receiver address.

Custom Transactions

  • sendCustomTxWith: Sends a custom transaction with the specified data.

Flows

Wallet Creation and Encryption Flow

  1. User accesses the Wallit Lite application.

  2. User selects "Create Wallet" from the frontend.

  3. Frontend generates a new random wallet using the createWallet function.

  4. The new wallet is displayed to the user.

  5. User selects "Encrypt Wallet" and enters a password for encryption.

  6. Frontend encrypts the wallet using the encryptWallet function and saves the encrypted wallet and nonce.

  7. The encrypted wallet is registered on the blockchain by calling the registerKey function of the KEYRegistry.sol contract.

  8. The encrypted wallet is associated with a unique non-transferable ERC721 token generated by the contract.

  9. Frontend displays a confirmation message that the wallet has been successfully registered.

Wallet Loading Flow

  1. User accesses the Wallit Lite application.

  2. User selects "Load Wallet" from the frontend.

  3. User enters the password used to encrypt the wallet.

  4. Frontend decrypts the wallet using the loadWallet function and displays the decrypted wallet to the user.

  5. User can perform operations on the wallet, such as sending ETH or transferring ERC20 tokens.

Deployment Instructions

To deploy the Wallit Lite project, follow these steps:

  1. Run yarn chain to start the local development blockchain.

  2. Run yarn deploy to deploy the KEYRegistry.sol contract to the local development blockchain.

  3. Run yarn next:start to start the frontend application.

Make sure you have all the necessary dependencies installed and configured before running the deployment commands.

Last updated