1

SPL_Token program contains lots of features, but I want to add more additional checks as per customer requirement. So I want to create custom spl_token program by extending original spl_token code

e.g. Lets say, I want to limit maximum token that can be transferred to any account in single transaction.

Also I want program_id of my custom program, to be used in assigned_program_id(as shown in solana explorer) of any account which is created.

Any help is appreciated.

1 Answers1

0

If you want your custom program id to be used, you simply need to fork the SPL token code to add your changes.

The code for the base token program exists at https://github.com/solana-labs/solana-program-library/tree/master/token/program, and if you're making small changes, it'll be easiest to change and deploy that.

If the changes are more involved, you can add a new extension to the token-2022 program, found at https://github.com/solana-labs/solana-program-library/tree/master/token/program-2022

To add a new extension, you need to add the state and instructions required for the extension, and whether it exists on a mint or account. Here is a sample pull request to add an extension allowing for mints to be closed: https://github.com/solana-labs/solana-program-library/pull/2754

Note that wallets and dapps will not be compatible with another program id, and it will take some time before they can accept more than one token program id.

Jon C
  • 7,019
  • 10
  • 17
  • Hi Jon, lets consider a scenario that I have created a token mint using spl-token-program and this token is distributed in many accounts. Now I want that for every transfer of my token I get a 10% commission. So how can I achieve this ? – Saurabh Suman Apr 20 '22 at 18:15
  • You can't currently "add" new things to existing tokens. To do this, you'd need to create a a new mint with token-2022 that contains a transfer fee, and then have another on-chain program which burns your old token and mints the new one – Jon C Apr 20 '22 at 19:16