🖥️Networks

Overview of how switching networks operates

Preface

Amity allows switching between all Ethereum-compatible networks (avax, harmony, fantom, etc.), with base support for Harmony, Ethereum, Polygon, and Avalanche.

Switching between networks will change all bot interactions to reflect the network of choice; for example, viewing transactions, addresses, etc. for example, Harmony will only reflect data on the Harmony blockchain and vice-versa.

How it works

Similar to registration, when a user chooses a network it saves that information to a database to be fetched later (code snippet), this command is the following:

/network *('ethereum', 'rinkeby', 'harmony', etc.) 
*optional field, if left blank will return the current connected network.

This unique choice will be saved and be fetched in the commands that depend on a network. Each network-bound command features an opening script that reads the database and cycles through the requires changes needed to move the command over to the chosen network.

Code Snippet:

if [lis[1] for lis in networks][0] == "Rinkeby":
      web3 = Web3(Web3.HTTPProvider("https://rinkeby.infura.io/v3/123456789abc"))

Adding Custom Networks

Amity, as of Beta v5, supports custom networks; expanding support from just four networks to all EVM networks.

Adding a custom network can be accessed via:

/addnetwork

The bot will send you a DM asking you some questions about the network you're adding, (RPC url, name, symbol, etc.) and will be testing the information you provide it with as you answer the questions to ensure a quality connection.

Once a custom network is added, it can be accessed the same way as all of the base networks; the opening script referenced earlier has a conditional that checks to see if the network selected is an outlier from the default networks, if so, it'll load network information from the individual "custom network" database and populate required variables with that information; essentially doing the same thing as a default network, but through user-chosen variables.

As was referenced, users cannot import invalid endpoints or endpoints that are slow, as Amity will actively test responses to!addnetworkand will reject any entries that fail to meet standards; the most impactful of those standards being endpoint speed, in which endpoints that are too slow will be rejected to prevent long processing times.

Last updated