# EVM Integration for Dapps

Talisman supports EVM networks and all dapps on those networks. \
In order for users to get the benefit of Talisman’s improved UX dapp builders need to make a few small changes to their applications.

## The Talisman injected ethereum provider

Unlike most other browser wallets, Talisman injects its ethereum provider in web pages as `window.talismanEth` (not `window.ethereum`). \
We decided this to allow users to keep Metamask installed & enabled even if they want to use Talisman EVM features. This however requires changes to the dapp, as most are designed to use only `window.ethereum`.

Our injected provider is [EIP 1193](https://eips.ethereum.org/EIPS/eip-1193) compliant and behaves like any other web3 ethereum provider.

### **Networks**

By default only Dotsama ecosystem networks (Moonbeam, Moonriver, Astar, Acala) are registered into the wallet. However other networks (for example Ethereum Mainnet, Polygon, or a local Hardhat blockchain) can be added to the wallet by a dapp. The wallet supports same network adding & switching interface as Metamask (see [EIP 3085](https://eips.ethereum.org/EIPS/eip-3085) and [EIP 3326](https://eips.ethereum.org/EIPS/eip-3326) for message details).

## Integration

### web3react v6

*The below information is for dapps using `web3react`, if you’re using a different framework please see below.*

Web3react requires a different “connector” for each ethereum provider. We provide a TalismanConnector for an easy integration with web3react.

**Integration steps:**

1. Copy paste the TalismanConnector.ts file in your project
2. Instantiate the connector in the same file where you already instantiate InjectedConnector. It takes the same arguments (the connector’s code is actually the same, the only difference is that ours uses `window.talismanEth` instead of `window.ethereum`)
3. Add a “Connect Talisman” button
4. On the button click, call the web3react’s activate method, passing the connector as argument
5. Use web3react as you normally would 😎

You may use the example project below as reference, the TalismanConnector.ts file is inside it :

<https://github.com/TalismanSociety/talisman-web3react-example>

### Other Frameworks

Please contact us if your dapp uses another framework (Wagmi, Web3Modal, Web3Onboard, web3react v8, Rainbowkit, etc.) so we can provide your with guidelines and framework specific connector if needed.

### Vanilla implementations

If your dapp uses window\.ethereum directly, without the help of a web3 framework, then we suggest the following:

* When the users clicks “Connect Wallet”, then display a modal allowing the user to select between wallets, as per the below:

<div align="left"><img src="https://2012041694-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2G9cEppDnwuwiGautnGv%2Fuploads%2FkSHzztiEj6o9JZxhMZ2L%2Fimage.png?alt=media&#x26;token=a8c720ef-62fa-47da-97eb-a33a9d87a697" alt=""></div>

Sample code to use to perform the integration and to display the modal:\
<https://codesandbox.io/s/talisman-connector-modal-d2mt93>

The demo app to test the interaction:\
<https://d2mt93.csb.app/>

#### Implementing the Talisman connect button :

* Implement a modal as described above, allowing user to choose which wallet to connect
* The onClick handler of the “Connect Talisman” button should execute the same code as the original “Connect Wallet” button that connects Metamask, but using `window.talismanEth` instead of `window.ethereum`. More specifically, connecting Talisman can be done by calling `window.talismanEth.request({ method: ”eth_requestAccounts”})` (recommended) or `window.talismanEth.enable()` (legacy approach).
* In this handler, also save in a global variable (or local storage) that the user has selected talisman.
* In the onClick handler of the “Connect Metamask” button, save in the global variable that the user has selected metamask
* Implement a `getProvider()` method that returns either `window.ethereum` or `window.talismanEth` based on the user selection saved in the global variable.
* All around your code base, everywhere `window.ethereum` is called directly, load the provider using `getProvider()` instead.

#### **Example implementation :**

[talisman-noframework-example.zip](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5d38ecbe-db51-4fe5-b35c-f8810a81c6eb/talisman-noframework-example.zip)

Please contact us if you need assistance, we can organise an online pair-programming session and get it done together.

## Testing EVM on Talisman

The current version (v1.5.0+) of the Talisman wallet in the chrome / firefox store contains the EVM support - please add an ETH seed phrase / private key in the `Add account` menu and you’ll be good to go!

## Questions / support

Please message @itsbirdo on Telegram

v 1.1
