EVM Integration for Dapps
This document will describe how to integrate Talisman into your EVM dapp
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 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 and 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:
Copy paste the TalismanConnector.ts file in your project
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 ofwindow.ethereum
)Add a “Connect Talisman” button
On the button click, call the web3react’s activate method, passing the connector as argument
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:
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 ofwindow.ethereum
. More specifically, connecting Talisman can be done by callingwindow.talismanEth.request({ method: ”eth_requestAccounts”})
(recommended) orwindow.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 eitherwindow.ethereum
orwindow.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 usinggetProvider()
instead.
Example implementation :
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
Last updated