This repository is used for the automated importing of blockchain configurations into the Safe Config Service. It includes scripts and configuration files necessary to import chains, features, wallets, and safe apps.
The safe-configs repository contains JSON configuration files and a Django management command script to import blockchain configurations into the Safe Config Service. This service is essential for managing and maintaining blockchain network configurations, including chain details, features, wallets, and safe apps.
To add a new chain to this repository and import it into the Safe Config Service, follow these steps:
Add the new chain's configuration to the configs/chains.json file. Ensure the configuration includes all necessary fields. Here is an example of a chain configuration:
{
"chainId": "12345",
"chainName": "NewChain",
"description": "NewChain Mainnet",
"chainLogoUri": "https://example.com/chains/12345/chain_logo.png",
"l2": false,
"isTestnet": false,
"nativeCurrency": {
"name": "NewCoin",
"symbol": "NC",
"decimals": 18,
"logoUri": "https://example.com/chains/12345/currency_logo.png"
},
"transactionService": "https://newchain-tx.example.com",
"blockExplorerUriTemplate": {
"address": "https://newchainexplorer.com/address/{{address}}",
"txHash": "https://newchainexplorer.com/tx/{{txHash}}",
"api": "https://api.newchainexplorer.com/api?module={{module}}&action={{action}}&address={{address}}&apiKey={{apiKey}}"
},
"ensRegistryAddress": null,
"features": ["CONTRACT_INTERACTION", "ERC1155", "ERC721"],
"gasPrice": [],
"publicRpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://rpc.newchain.com"
},
"rpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://rpc.newchain.com"
},
"safeAppsRpcUri": {
"authentication": "NO_AUTHENTICATION",
"value": "https://rpc.newchain.com"
},
"shortName": "newchain"
}Alternatiely, blockExplorer and RPC can be provided simply as an URL, in which case the script will attempt to autodetect the rest of the data, example:
{
"chainId": "12345",
...
"rpcUri": "https://rpc.newchain.com",
"blockExplorerUri": "https://explorer.newchain.com/"
}Ensure the .env file in your configuration service is set up correctly to import the new chains. Here are the relevant environment variables:
CONFIG_URL=https://raw.githubusercontent.com/protofire/safe-configs/refs/heads/main/
DEFAULT_CHAIN_IDS=1,10,5000
IMPORT_SERVICES=1
IMPORT_FEATURES=1
IMPORT_WALLETS=1
IMPORT_SAFE_APPS=1CONFIG_URL: Url to the configuration files.DEFAULT_CHAIN_IDS: Set toALLto import all chains listed inchains.json. Alternatively, specify a comma-separated list of chain IDs to import specific chains.IMPORT_SERVICES: Set to1to import services.IMPORT_FEATURES: Set to1to import features.IMPORT_WALLETS: Set to1to import wallets.IMPORT_SAFE_APPS: Set to1to import safe apps.
Execute the Django management command to import the configurations:
python manage.py import_default_configThis command will read the configuration files and import the chains, features, wallets, and safe apps into the Safe Config Service.
The import script is located at .internal/import_default_config.py. It handles the loading and importing of JSON data for chains, features, wallets, and safe apps.
load_json_data: Loads JSON data from a file or URL.handle: Main function that orchestrates the import process.import_services: Imports services fromservices.json.import_features: Imports features fromfeatures.json.import_wallets: Imports wallets fromwallets.json.import_safe_apps: Imports safe apps fromsafeApps.json.import_chains: Imports chains fromchains.json.
The script automatically adds default wallets and features to each chain. The default wallets and features are defined within the import_chains function.
- Metamask
- Ledger
- Trezor
- WalletConnect_v2
- WALLET_WEB
- EIP1271
- COUNTERFACTUAL
- DELETE_TX
- SAFE_141
- SAFE_APPS
- SAFE_TX_GAS_OPTIONAL
- SPEED_UP_TX
The script also handles the uploading of chain and currency logos. Ensure the URLs provided in the chain configuration are accessible and return valid image files.
By following the steps outlined in this README, you can add new chains to the safe-configs repository and they will be automatically imported to the Safe Config Service. Ensure all configurations are correctly set up and the import script is executed to reflect the changes.