Adding a Substrate 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/polkadot/networks
and create a file with the name [network-ticker].ts
.
In your new network file import SubstrateNetwork
and SubstrateNetworkOptions
and create a variable for your network's configuration.
The SubstrateNetworkOptions
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
, prefix
, genesisHash
, 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 SubstrateNetwork
and export it.
And finally in packages/extension/src/providers/polkadot/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 experience. Activity handler is responsible for showing past activity of the user on activity tab We already implemented a activity handler for subscan api. If you already part of subscan
and then add the subscan api link to
packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/configs.ts#L3
However, if you dont have an api compatible with subsca 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/polkadot/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. Specially if you have different tokens in your substrate chain.
For furthen information on how to implement an asset handler, please checkout the Acala ormlHandler
packages/extension/src/providers/polkadot/networks/acala/acala.ts#L32
Last updated