Skip to content

hbulgarini/pallet-contracts-uniques

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSP22 Chain Extension Example

What is this example about?

It is an example implementation of the PSP22 Fungible Token Standard as a chain extension, supporting a multi-token system provided by the FRAME assets pallet. It effectively allows ink! contracts (L2) to interact with native assets (L1) from the chain runtime in a standardized way.

See this chapter in our ink! documentation for more details about chain extensions.

There are two parts to this example:

  • Defining and calling the extension in ink!.
  • Defining the extension in Substrate.

Chain-side Integration

To integrate this example into Substrate you need to do two things:

  • In your runtime, use the code in psp22-extension-example.rs as an implementation for the trait ChainExtension in Substrate. You can just copy/paste that file as a new module, e.g. runtime/src/chain_extension.rs.

  • In your runtime, use the implementation as the associated type ChainExtension of the trait pallet_contracts::Config:

    impl pallet_contracts::Config for Runtime {type ChainExtension = Psp22Extension;}

ink! Integration

See the example contract in lib.rs.

Disclaimer

⚠️ This is not a feature-complete or production-ready PSP22 implementation. This example currently lacks proper error management, precise weight accounting, tests (these all might be added at a later point).

About

Chain Extension for Uniques Pallet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages