Check our Demo Github repo for Fungible SPL Token creation with Metaplex Foundation Umi framework

Follow these steps:

  1. Create SPL token and Metaplex metadata for it (Clone the Demo repo and follow the instructions from the README.md). In this repository, we also provide instructions on how to update metadata for an existing token or create metadata if the token lacks it.
  2. Register new token in system factory contract:

Important: package version should not be changed!

**README.md** from Demo repo:

# Examples of Fungible SPL token creation with Metaplex Foundation Umi framework

**NOTE**

The package uses

[Metaplex Foundation](<https://github.com/metaplex-foundation>) library.

[Umi](<https://github.com/metaplex-foundation/umi>) A JavaScript framework to build Solana clients.

Please check [Metaplex docs](<https://docs.metaplex.com/>) for more information.

---

## Installation and setup

Firstly, install all necessary packages:

```sh
yarn install
#or
npm install

Add .env file with the following content in env directory:

SOLANA_URL='XXXXXXXXXXXXXXXXX'

Signer wallet configuration

You can use the following command to create a signer wallet:

yarn ts-node wallet.ts

With this, a new wallet will be created, and your private key will be saved in the secret.json file. Afterward, you can utilize this wallet for additional operations and import it into the wallet of your choice (ex.Phantom).

Alternatively, you can export your existing private key and place it in the secret.json file that you've created yourself.

Usage

To create and mint your own token, you'll need a token icon and metadata that are publicly accessible. You can use IPFS for this purpose or another publicly accessible storage solution.

Create a new metadata JSON file (token.json) following Metaplex's Fungible Standard

{
  "name": "Your Token Name",
  "symbol": "Your Token Symbol",
  "description": "Your Token Description",
  "image": "Public Token Icon Image URL"
}

Upload this file to IPFS and save the CID - (your publicly accessible URL will be like this: https://ipfs.io/ipfs/CID). Or choose your own publicly accessible storage solution. Your token icon image also should be uploaded on publicly accessible storage.

Afterward, you need to put your metadata URL in the mint.ts file.

const metadata = {
  name: 'Your Token Name',
  symbol: 'Your Token Symbol',
  uri: 'Your Metadata URL'
};

Update the values of createAndMint function from mint.ts file with your own values:

createAndMint(umi, {
mint,
authority: umi.identity,
name:metadata.name,
symbol:metadata.symbol,
uri:metadata.uri,
sellerFeeBasisPoints: percentAmount(0),
decimals: 8, //Choose the number of decimals
amount: 1000000_00000000, //Choose the amount of tokens you want to mint
tokenOwner: userWallet.publicKey,
tokenStandard:TokenStandard.Fungible,
})

To mint a new token, use the following command:

yarn ts-node mint.ts

Add you created token mint address to the .env file

TOKEN_MINT='XXXXXXXXXXXXXXXXX'

You will need it further to create an ERC20ForSPL token address.

Create token metadata

If you already have your own token but lack metadata, you can create it using the following command:

yarn ts-node createTokenMetadata.ts

See the example from the createTokenMetadata.ts file.

Update token metadata

If you want to update your token metadata, you can use the following command:

yarn ts-node updateTokenMetadata.ts

See the example from the updateTokenMetadata.ts file. Ensure that the isMutable field of the metadata is set to true; otherwise, you won't be able to update it. Once it's set to false, it can't be reverted anymore.

ERC20ForSPL token creation

In order to register a new token in the system factory contract, you will need to follow these steps:

Or you can use an external service https://incoherency.co.uk/base58