Skip to main content

ERC-20 for SPL Tokens

This page describes the ERC-20 SPL interface contract: the ERC-20 Factory Contract. This contract provides access to native Solana tokens, i.e. those registered in the SPL token contract, through the ERC-20 standard interface.

This allows Solana liquidity to be available to EVM bytecode contracts (Solidity, Vyper, etc.), i.e. this ERC-20 SPL interface allows Ethereum wallets such as MetaMask to transact with SPL tokens. The contract is deployed on Devnet and Mainnet:

LocationFactory Contract address
Devnet0xF6b17787154C418d5773Ea22Afc87A95CAA3e957
Mainnet0x6B226a13F5FE3A5cC488084C08bB905533804720
info

To be able to use an SPL token from a Solana account balance, it must be transferred to a Neon EVM account via NeonPass.

ERC-20 Factory Contract

The ERC-20-for-SPL Factory Contract provides a method to access a list of deployed contracts on the Neon EVM and to issue and register a new ERC-20-for-SPL contract. Once registered, these contracts are then deployed to Neon EVM and are available on the system-wide registry.

Depending on the method called and the arguments passed to this contract, two variants of the deployment may be created and registered:

ERC-20-for-SPL

The ERC-20-for-SPL variant works with a precompiled contract within Neon EVM which can call the SPL token program. This enables you to utilize existing SPL tokens e.g. SOL or USDC, as wSOL or USDC tokens on Neon EVM chain, respectively, via the ERC-20 interface.

info

Note that before setting up the ERC-20 Factory Contract to construct an ERC-20-for-SPL, you must register the token's existing Metaplex metadata.

ERC-20-for-SPL-Mintable

The ERC-20-for-SPL-Mintable variant has two additional methods that enable you to use the Neon EVM to mint a new SPL token and register it to the interface to be ERC-20-compatible. When the ERC-20 Factory Contract is constructed to this variant, it creates a new SPL token using Solana's Token Program and provides mint and freeze authority to the Neon account specified in the constructor.

Deploying

Setting up the ERC-20-for-SPL interface could be a 1-step or 2-step process:

  • You already have an existing SPLToken on Solana:
    1. In this case, you only have to submit a transaction on Neon EVM to create the smart contract instance for the SPLToken.
  • You don't have an existing SPLToken and decided to use ERC-20-for-SPL-Mintable to mint a new SPLToken and to create smart contract instance:
    1. Here, you can pass a single transaction to Neon EVM chain.
  • You don't have an existing SPLToken, but you want to be the owner of the token in the context of Solana:
    1. Firstly, you need to deploy the SPLToken on Solana with a Solana transaction.
    2. Next step is a transaction to Neon EVM to create the smart contract instance for the SPLToken you just deployed in the step 1.

Contract signing

Depending on which output you need to construct, you will sign with different accounts, as shown in the table:

ContractUsageRequirementstx signed by
ERC-20-For-SplProvide interface for Solana-minted token1. Neon Account
2. Existing SPL token
3. Solana account & wallet
Signed by the Solana account private key (via linked Phantom wallet)
ERC-20-ForSpl-MintableMint a token on Solana & provide interface1. Neon AccountSigned by the Neon account private key (via linked MetaMask wallet)

Restrictions

According to the SPL token structure, an unsigned 64-bit integer is used to store the balance; in ERC-20, it's an unsigned 256-bit integer. Based on the unsigned 64-bit integer, the maximum balance and transfer amount is (2^64-1)/(10^9), with 9 decimals of accuracy.

Notes on variants in outcome

How you set up the ERC-20 Factory Contract will determine the contract deployed and the constructor's variables:

/// @notice ERC20ForSpl constructor
/// @param _tokenMint The Solana-like address of the Token Mint on Solana in bytes32 format
constructor(bytes32 _tokenMint)
important

It's highly desirable to not place decimals greater than 9. Neglecting this restricion may lead to issues with math operations inside the smart contract.

Notes on usage

The ERC-20 Factory Contract is provided as a basic toolkit under the MIT (X11) license. You are invited to adapt this to your needs as required.

Was this page helpful?