0

pub fn transfer<'info>(ctx: CpiContext<'_, '_, '_, 'info, Transfer<'info>>, amount: u64) -> Result<()>

The above code is the method defenition used in rust to transfer SPL tokens. The amount argument is accepted as u64. What if we want to transfer more than U64_MAX ?

2 Answers 2

1

The maximum amount of tokens for an SPL token mint is u64::MAX. The supply is stored as a u64 at https://github.com/solana-labs/solana-program-library/blob/177a6c94d751e49be0e299b0155823195a21e7fe/token/program/src/state.rs#L25

Since it's impossible to have more than u64::MAX tokens, you'll never need to transfer more than that.

If you want, however, you can fork the SPL token program and modify it to represent amounts as u128 or a custom 256-bit uint type. It just might be difficult to get adoption in the ecosystem for your program.

0

then why not creating multiple instructions in the same transaction ?

3
  • Do you really think this is the practice being to transfer large number of tokens? Nov 22, 2023 at 5:20
  • doesn't look like like a best practice, but if the transfer amount is maxed at u64 max size at solana side, i don't know how it could be made in another way ?
    – Effe2
    Nov 22, 2023 at 9:27
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review Dec 29, 2023 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.