Saltar al contenido principal

Chain Extensions

Chain extension is a way to extend contracts API to add contracts to runtime pallet interaction. By default, contracts can only do cross-contract calls within their environment (pallet-contracts). Chain extension allows to add custom callable pallet functions.

ink-ce

What chain extensions are available ?

Assets

This chain extension adds call to pallet_assets so that you can use Assets in your contracts. More info in the chain-extensions contracts repo.

Account Unification

This chain extension adds query to pallet_unified_accounts so that you can query Unified addresses. Find usage and tests in ink! XVM SDK repo

Availability in networks

Chain extensionShibuyaShidenAstar
Assets
Account Unification

Implementations

There are two implementations: one in the runtime and one on the ink! side.

Runtine

Implementation of the chain extension on runtime side is available on Astar repository, under chain-extensions folder

ink! implementation

On contract side the implementation is made using ChainExtensionMethod that uses a custom environment (so it can be used with other libraries that use custom environment like OpenBrush). It is implemented as a crate that you can import in you contract. It can be found in chain-extension contracts repository

Contracts examples

Video tutorials

  • dApp Staking Chain Extension on ink! Smart Contracts by @AstarNetwork on Youtube
  • Build a Scheduler Chain Extension by @Parity on Youtube