---
# System prepended metadata

title: Wallet Integration for Mesa Frontend

---

# Wallet Integration for Mesa Frontend


## Short intro

Mesa is a framework for doing decentralized token sales, a IDO Plattform, on ethereum. We are currently working on a MVP wich has two sales mechanisme, a fixed price sale and a auction called Fairsale. The MVP has a interface for the investors, so people investing in a project/token.


## Code

Mesa Fe: https://github.com/cryptonative-ch/mesa-interface
Mesa SC: https://github.com/cryptonative-ch/mesa-smartcontracts/
Mesa JS SDK: https://github.com/cryptonative-ch/mesa-js
Mesa Subgraph: https://github.com/cryptonative-ch/mesa-subgraph

Deployed Contracts: xdai/rinkeby https://mesa-1.gitbook.io/mesa/developers-1/smart-contracts/deployed-contracts

More Info: https://mesa-1.gitbook.io/

Kontakt: @martinkrung on keybase or mk@cryptonative.ch or @martinkrung on twitter

## To see this running, use this script

```
echo 'This installs a local instance of the mesa-subgraph and add some date to it, this uses docker'
git clone https://github.com/cryptonative-ch/mesa-subgraph
cd mesa-subgraph/
yarn install 
yarn explore-local &
cd ..
echo 'Wait for the interface to be installed..'
git clone https://github.com/cryptonative-ch/mesa-interface
cd mesa-interface/
yarn install
yarn start:subgraph &
echo 'Mesa Interface now running on http://localhost:3000/'
```

## Project State

Dev Team is working on subgraph integration on the FE. What's missing is the communication from the user to the chain. We also work on a Mesa javascript SDK right now. We have a xDai strategy first.


## What has to be done

We need an implementation of a wallet for metamask and wallet connector. We will launch on xDai and think we will add new networks soon. Network switcher should be ready to use.

Best would be to use similar wallet code from swapr (https://swapr.dev  https://swapr.eth.link  code https://github.com/levelkdev/dxswap-dapp/
. Swapr is also a project made by dxDao. 

Design for wallet interaction: 

https://www.figma.com/file/7vH0nZB72tizFbhT7gtizo/Mesa-MVP?node-id=408%3A170


## List of features to implement

### Must have

- Wallet integration with metamask
- Wallet integration with wallet connect
- Follow the UX design from figma (For tx/wallet states, rest is mostly done)
- Standard network is xDai, Contracts here: (https://mesa-1.gitbook.io/mesa/)
- Make rinkeby as a second network which can be configured off/on (Rinkeby is our test network)
- Show/Detect pending tx on low gas tx which may be stuck for some time
- Detection of wrong networks
- Implement interaction on the fixed price sale and FairSale single view
- If you miss a specific design, please make variation of an existing one
- Write test for the written code
- Small documentation which function to call in the FE


### Nice to have, make some options for this in your offer


- Use of Metamask Network Switcher API
- Modular Approach to use the same wallet connector on different products 
- Abstraction layer between wallet connector, design and functionality for specific smart contract on a product
- Use language keys for internationalization (It's integrated, but not used everywhere)


# Functions to call on the smart contracts

There are two sales in the MVP, a fixed price sale and an auction, called FairSale.

In the MVP only with this both contracts has to be interacted. The MVP only covers the need for persons taking part in a sale. For the rest there is no interface yet.


## FixedPrice


Smart Contract for FixedPrice: https://github.com/cryptonative-ch/mesa-smartcontracts/blob/main/contracts/sales/FixedPriceSale.sol

For a FixedPrice Sale there are this 3 function calls to be made from the investor facing interface.


### buyTokens

If an investor buys a token, he makes an order but does not get the token back yet. Only after the sale has closed and the threshold is reached, the investor will be able to claim the token. If the threshold is not reached, the invested amount has to be withdrawn afterwards.

https://github.com/cryptonative-ch/mesa-smartcontracts/blob/26a59272a7014c41dbb88616b9fa0736ef1a94b8/contracts/sales/FixedPriceSale.sol#L171


### claimTokens

This is the function users call to claim the bought token after the sale has finished.

https://github.com/cryptonative-ch/mesa-smartcontracts/blob/26a59272a7014c41dbb88616b9fa0736ef1a94b8/contracts/sales/FixedPriceSale.sol#L231


### releaseTokens

This is the function users call to claim to get the invested token back if the threshold has not been hit.

https://github.com/cryptonative-ch/mesa-smartcontracts/blob/26a59272a7014c41dbb88616b9fa0736ef1a94b8/contracts/sales/FixedPriceSale.sol#L208


This info is also here: https://app.gitbook.com/@mesa-1/s/mesa/developers-1/smart-contracts/fixed-price-sale


## Fairsale

Fairsale interaction is little complex than fixed price:

Smart Contract for Fairsale: https://github.com/cryptonative-ch/mesa-smartcontracts/blob/main/contracts/sales/FairSale.sol


### placeOrders

The investor places a bid at a certain price. One investor can place several order at a different price. At this point it's not clear if he/she will get tokens at the end.

https://github.com/cryptonative-ch/mesa-smartcontracts/blob/26a59272a7014c41dbb88616b9fa0736ef1a94b8/contracts/sales/FairSale.sol#L205


### cancelOrders

A bid can be canceled during the sale. Token are returned to the biders wallet.

https://github.com/cryptonative-ch/mesa-smartcontracts/blob/26a59272a7014c41dbb88616b9fa0736ef1a94b8/contracts/sales/FairSale.sol#L258

### claimFromParticipantOrder


After the auction is finished, the user can withdraw either his unfilled bid or the bought token.

https://github.com/cryptonative-ch/mesa-smartcontracts/blob/26a59272a7014c41dbb88616b9fa0736ef1a94b8/contracts/sales/FairSale.sol#L465

This info is also here: https://app.gitbook.com/@mesa-1/s/mesa/developers-1/smart-contracts/fairsale-auction