The Neon Transfer Module: An Overview

Neon Labs
Neon Labs
Published in
3 min readJun 28, 2022

--

The Neon Transfer Module is a vital part of the Neon EVM ecosystem that allows for easy and convenient transfer of NEON and SPL tokens between Solana and Neon.

NeonPass, as we covered in a previous article, is built on the open-source Neon Transfer Module. Unlike a bridge, which simply connects two separate blockchains, the Neon Transfer Module is a two-way transfer tool that brings assets in and out of the Neon EVM platform. It is geared more towards developers.

In facilitating token transfers, the Neon Transfer Module has four different functionalities, namely:

  1. Transferring NEON tokens from Solana to the Neon EVM
  2. Transferring NEON tokens from the Neon EVM to Solana
  3. Transferring SPL tokens from Solana to the Neon EVM
  4. Transferring SPL tokens from the Neon EVM to Solana

This is accomplished by wrapping SPL tokens on Solana into Neon EVM ERC-20 tokens when sending from Solana to the Neon EVM, and unwrapping Neon EVM ERC-20 wrapper tokens into their underlying SPL tokens when sending from the Neon EVM back to Solana. Unlike other SPL tokens, NEON tokens do not need to be wrapped into an ERC-20 Neon EVM token when sending to the Neon EVM from Solana. This is because NEON tokens will be SPL tokens native to Solana and need to be sent into specialized SPL accounts within the Neon EVM environment to facilitate Neon transactions. As such, it does not have a corresponding ERC-20 wrapper deployed in Neon.

Architecture

The Neon Transfer Module software consists of one superclass, InstructionService, and two classes that inherit from it — NeonPortal and MintPortal. InstructionService contains the functionality that is needed for all transfers, including Ethereum and Solana JavaScript SDKs for building transaction instructions.

This common functionality is then expanded upon in NeonPortal and MintPortal. NeonPortal extends this service for transferring NEON tokens, and MintPortal extends it for transferring ERC-20 tokens.

Installation and Setup

It is possible to use the Neon Transfer Module both in native JavaScript and using ReactJS. Whichever method you choose, it is necessary to first install the neon-portal package with the following npm command:

The following are simple examples of how to use the Neon Transfer Module. For more detailed information, including a full list of settings and parameters, please refer to the README file on the Neon Transfer GitHub repository.

Using Native JavaScript

For native JavaScript clients, Neon provides a ready-made bundle that includes all the dependencies needed to make the Neon Transfer Module work, so you don’t need to build it by your own runtime. This bundle supports two default exports: NeonPortal to transfer NEON tokens, and MintPortal to transfer SPL tokens. To use the bundle, import one of them like so:

When creating a portal, make sure to include mandatory parameters solanaWalletAddress (the Phantom wallet address), neonWalletAddress (currently works only with a MetaMask wallet address), and connection (the connection module of the Solana Web3 framework). Make sure to also include a function for your state changes, here called eventParams, and pass it as a parameter.

Now you can add a button that creates a Neon transfer when clicked:

Using ReactJS

Using the Neon Transfer Module in native JavaScript has its drawbacks — the native bundle is very large, which adds to the loading time. With ReactJS, you can import a hook that comes preconfigured from the neon-portal package. Unlike the native bundle, however, using the ReactJS hook requires the use of the create-react-app bundle. You can use this hook as follows:

This hook applies the event parameters as arguments for the module.. For a cleaner working configuration, it is recommended to create your own hook as a wrapper for the existing useNeonTransfer hook, and customize it to your liking. An example is provided in the Neon Transfer Module README file.

Conclusion

The Neon Transfer Module is an open-source developer tool to get the NEON and SPL tokens you need into and out of the Neon EVM ecosystem. Using this module is what makes NeonPass so convenient for Solana users and developers — with just a simple module to transfer tokens from Solana to an EVM, the possibilities are endless!

--

--