Adding an EVM Network
This page walks you through the process of adding a new EVM network to Enkrypt
Getting Started
Set up your development environment
Create a fork of the repository
Clone the fork locally
In the root directory run the following:
You will now have your fork ready to go and your project is watching for changes to Enkrypt.
Add your network's name and platform
Navigate to packages/types/src/networks.ts
and add your network's name to the NetworkNames
enum.
If your network has a Coingecko platform ID you can add that to CoingeckoPlatform
as well. To find your network's coingecko platform run the following in your teminal:
Note: After adding your network to networks.ts you will need to run
yarn build:all
again.
Create a network file
Navigate to packages/extension/src/providers/ethereum/networks
and create a file with the name [network-ticker].ts
.
In your new network file import EvmNetwork
and EvmNetworkOptions
and create a variable for your network's configuration.
The EvmNetworkOptions
interface takes this form:
For a basic network integration the only required fields are name
, name_long
, homePage
, blockExplorerTX
, blockExplorerAddr
, chainID
, currencyName
, node
, icon
, isTestNetwork
, and activityHandler
.
For further customization take a look at other networks that are already added to Enkrypt.
For
node
use a wss URL when possible.
For
blockExplorerTx
, andblockExplorerAddr
you should put the URL with the template string[[txHash]]
and[[address]]
where they would go in the URL respectively.
Then create a new EvmNetwork
and export it.
And finally in packages/extension/src/providers/ethereum/networks/index.ts
add your network to the exported networks.
Your network should now show up in the manage networks screen!
Adding Activity Handler
Having an activity handler for your network is mandatory and will give users a good experiance. Activity handler is responsible for showing past activity of the user on activity tab We already implemented a activity handler for etherscan/blockscout api. If you already have a block explorer that is compatible with either etherscan or blockscout, all you need to do is set
and then add the blockexplorer api link to
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts
However, if you dont have an api compatible with etherscan you have to manually create one that can return transaction history for the user, it should follow the following type.
Some sample handlers are located at
packages/extension/src/providers/ethereum/libs/activity-handlers/providers
if you dont have any api to get all user assets, you can simply return and empty array. That way Enkrypt will only display user activity happened inside the Enkrypt
Adding an Asset Handler
Having an asset handler for your network is optional but better to have it since it'll give an amazing experience to the user. Asset handler is responsible for showing all of user assets under specific account.
We already implemented a asset handler for debank api, if your chain is part of debank api (check here
) all you need to do
and then add your chain id to
packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts#L30
If it is not part of debank api, we still highly recommend for you to do a custom implementation it should follow the following type
Adding an NFT Handler
Having an NFT handler for your network is optional but better to have it since it'll give an amazing experience to the user. NFT handler is responsible for showing all of user NFTs under specific account. We already implemented a NFT handler for simplehash and rarible api, if your chain is compatible with either of those you can add the respective one to
or
and add the chain configs to either
packages/extension/src/libs/nft-handlers/rarible.ts or packages/extension/src/libs/nft-handlers/simplehash.ts
If the chain is not part of simplehash or raribl, we still highly recommend for you to do a custom implementation it should follow the following type
Last updated