How to Add an EVM Compatible Chain to Trust Wallet Core

·

Trust Wallet Core is a powerful, open-source library that provides the foundational tools for developers to build robust cryptocurrency wallet applications. One of its key features is the ability to integrate with various blockchain networks, particularly those compatible with the Ethereum Virtual Machine (EVM). This guide will walk you through the process of adding an EVM-compatible chain to a project built with Wallet Core, helping you expand your wallet's functionality and user reach.

Understanding EVM Compatibility and Wallet Core

The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts on the Ethereum blockchain. An EVM-compatible chain is any blockchain network that can execute these same smart contracts, allowing for interoperability with the vast Ethereum ecosystem. Examples of popular EVM chains include Binance Smart Chain (BSC), Polygon (MATIC), Avalanche (AVAX), and Fantom Opera.

Trust Wallet Core is the underlying software development kit (SDK) that handles all the complex cryptographic operations, key management, and blockchain interactions. It is the "engine" that powers the Trust Wallet application and is available for other developers to use in their own projects. By learning to add new chains, you are effectively teaching this engine how to communicate with a new network.

Prerequisites for Adding a New EVM Chain

Before you begin the integration process, ensure you have the following:

Step-by-Step Guide to Integration

The process involves defining the new chain's parameters within the Wallet Core structure. Here is a generalized overview.

Step 1: Define the Chain Parameters

The first step is to create a new chain definition. This involves specifying all the necessary network information in the codebase. You will need to locate the appropriate configuration files within the Wallet Core project, often where other chains are already defined.

You will create a structure that encapsulates the chain's ID, name, and other core identifiers. This tells Wallet Core that a new network exists.

Step 2: Configure the RPC Endpoint

An RPC (Remote Procedure Call) endpoint is your gateway to interacting with the blockchain. You must provide the URL of a reliable, synced node for the network you are adding. This allows Wallet Core to query balances, broadcast transactions, and fetch blockchain data.

👉 Explore reliable node providers for your project

Step 3: Add the Native Currency Information

Every blockchain has a native currency used to pay for transaction fees (gas). You must define this currency's properties—its name (e.g., "Binance Chain Native Token"), symbol (e.g., "BNB"), and the number of decimals it uses (e.g., 18). This ensures the wallet can correctly display balances and values.

Step 4: Implement Chain-Specific Derivation Paths

Wallet Core uses the BIP44 standard to generate addresses from a recovery phrase. The derivation path includes the coin_type field, which is unique to each network. You must ensure the correct SLIP44 number is used for your new chain so that it generates the correct addresses.

Step 5: Rebuild and Test

After adding the new chain's configuration, you must recompile the Wallet Core library. Once rebuilt, rigorous testing is crucial. You should test core functionalities like:

Contributing to the Open-Source Project

Trust Wallet Core is an open-source project, meaning community contributions are welcome. If you have successfully added a well-known EVM chain, you can consider contributing your code back to the main project repository on GitHub. This involves:

  1. Forking the official repository.
  2. Creating a new branch for your feature.
  3. Committing your changes with clear, descriptive messages.
  4. Submitting a pull request for the maintainers to review.
  5. Addressing any feedback and collaborating to get your contribution merged.

This process helps improve the library for all developers in the community.

Frequently Asked Questions

What is the difference between Trust Wallet the app and Wallet Core?
Trust Wallet is the end-user application available on iOS and Android. Wallet Core is the open-source SDK that provides the underlying cryptographic and blockchain functionality. The app is built using the Wallet Core library.

Can I add any EVM-compatible chain using this method?
Yes, in theory, any blockchain network that is fully EVM-compatible can be integrated into a project using Wallet Core by providing its correct network parameters, including Chain ID, RPC URL, and currency details.

Do I need to run my own blockchain node to add a chain?
While you can run your own node for maximum reliability, it is not strictly necessary for development. Many blockchain networks and third-party services provide public RPC endpoints or affordable dedicated services that you can use for testing and integration.

What is a Chain ID and where can I find it?
A Chain ID is a unique integer that identifies a specific blockchain network. You can usually find a network's Chain ID in its official documentation, on chain exploration websites, or community-run resources that list network parameters.

Is it safe to add a custom EVM chain?
When adding a chain to your own development project, the safety is dependent on the accuracy of the information you provide. Using incorrect RPC URLs or Chain IDs can lead to failed transactions or loss of funds. Always double-check all parameters against official sources.

How can I test the new chain integration without spending real money?
Most EVM-compatible chains have public testnets (e.g., BSC Testnet, Polygon Mumbai). You can obtain free testnet coins from faucets and use them to thoroughly test all wallet functionalities—sending, receiving, and transaction history—without any financial risk.