Docs
Tangle Network
Pallets and Precompiles
Overview

Overview of Precompiles and Pallets

Introduction to Precompiles

On Tangle Network, a precompiled contract refers to native Substrate code that possesses an Ethereum-like address and can be engaged through the Ethereum API, as with any other smart contract. These precompiles enable you to directly interact with the Substrate runtime, a functionality that is usually inaccessible from the Ethereum aspect of Tangle Network.

The Substrate code that oversees the implementation of precompiles is located within the EVM pallet. This EVM pallet comprises the standard precompiles existing on Ethereum along with some other precompiles that aren't unique to Ethereum. It further offers the capacity to form and execute custom precompiles through the versatile Precompiles trait. A range of custom Tangle Network-specific precompiles have been developed and can be found within the Tangle Network codebase.

The Ethereum precompiled contracts encompass complex functions that require substantial computational resources, including hashing and encryption. On Tangle Network, the custom precompiled contracts allow access to Substrate-based features such as staking, governance, XCM-related operations, and more.

These Tangle Network-specific precompiles can be accessed through familiar and user-friendly Solidity interfaces utilizing the Ethereum API, which ultimately interact with the underlying Substrate interface.

Ethereum Mainnet Precompiles

See the repositories for these at the Parity Github. (opens in a new tab)

ContractAddress
ECRECOVER0x0000000000000000000000000000000000000001
SHA2560x0000000000000000000000000000000000000002
RIPEMD1600x0000000000000000000000000000000000000003
Identity0x0000000000000000000000000000000000000004
Modular Exponentiation0x0000000000000000000000000000000000000005
BN128Add0x0000000000000000000000000000000000000006
BN128Mul0x0000000000000000000000000000000000000007
BN128Pairing0x0000000000000000000000000000000000000008
Blake20x0000000000000000000000000000000000000009
SHA3FIPS2560x0000000000000000000000000000000000000400
Dispatch0x0000000000000000000000000000000000000401
ECRecoverPublicKey0x0000000000000000000000000000000000000402

General Precompiles

ContractAddress
Democracy0x0000000000000000000000000000000000000803
Batch0x0000000000000000000000000000000000000808
Call Permit0x000000000000000000000000000000000000080a
Preimage0x0000000000000000000000000000000000000813
Precompile Registry0x0000000000000000000000000000000000000815
Pallet Staking0x0000000000000000000000000000000000000800

Introduction to Pallets

In the Substrate ecosystem, a pallet refers to a distinct, reusable piece of code which contributes a specific piece of functionality to a runtime. Think of pallets as modules that are utilized to construct Substrate-based blockchains. The Tangle Network, like any Substrate-based chain, employs a variety of these pallets to accomplish the network's overall functionalities.

The repository of each pallet consists of a set of related functionalities, which collectively contribute to the overall operation of the Substrate runtime. From managing balances and transaction fees to handling governance and staking processes, pallets essentially serve as the backbone of the Substrate infrastructure.

The flexibility and modularity of Substrate pallets contribute significantly to the customization and upgradeability of the Tangle Network. They provide for easy runtime upgrades without needing to fork the entire network, ensuring a seamless evolution of the network's capabilities.

Amongst the Substrate standard pallets, Tangle Network also incorporates several custom pallets specifically tailored to meet its unique requirements. These custom pallets encapsulate Tangle Network's unique features and functions that extend beyond the conventional Substrate offerings.

Just as with precompiles, these custom pallets can be interacted with through familiar interfaces, this time using the Substrate API. This ensures that developers can make the most out of the rich functionalities offered by the Tangle Network without having to navigate through the complex underlying logic of the pallets themselves.

In essence, pallets form the building blocks of the Tangle Network, contributing to its robustness, customization, and scalability. The beauty of this modular architecture lies in its adaptability and expandability, allowing the Tangle Network to continuously grow and adapt to meet the changing needs of its community.