mint.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { struct, u32, u8 } from '@solana/buffer-layout';
  2. import { bool, publicKey, u64 } from '@solana/buffer-layout-utils';
  3. import { Commitment, Connection, PublicKey } from '@solana/web3.js';
  4. /** Information about a mint */
  5. export interface Mint {
  6. /** Address of the mint */
  7. address: PublicKey;
  8. /**
  9. * Optional authority used to mint new tokens. The mint authority may only be provided during mint creation.
  10. * If no mint authority is present then the mint has a fixed supply and no further tokens may be minted.
  11. */
  12. mintAuthority: PublicKey | null;
  13. /** Total supply of tokens */
  14. supply: bigint;
  15. /** Number of base 10 digits to the right of the decimal place */
  16. decimals: number;
  17. /** Is this mint initialized */
  18. isInitialized: boolean;
  19. /** Optional authority to freeze token accounts */
  20. freezeAuthority: PublicKey | null;
  21. }
  22. /** Mint as stored by the program */
  23. export interface RawMint {
  24. mintAuthorityOption: 1 | 0;
  25. mintAuthority: PublicKey;
  26. supply: bigint;
  27. decimals: number;
  28. isInitialized: boolean;
  29. freezeAuthorityOption: 1 | 0;
  30. freezeAuthority: PublicKey;
  31. }
  32. /** Buffer layout for de/serializing a mint */
  33. export const MintLayout = struct<RawMint>([
  34. u32('mintAuthorityOption'),
  35. publicKey('mintAuthority'),
  36. u64('supply'),
  37. u8('decimals'),
  38. bool('isInitialized'),
  39. u32('freezeAuthorityOption'),
  40. publicKey('freezeAuthority'),
  41. ]);