token.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /* Autogenerated SPL Token program C Bindings */
  2. #pragma once
  3. #include <stdarg.h>
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include <stdlib.h>
  7. /**
  8. * Minimum number of multisignature signers (min N)
  9. */
  10. #define Token_MIN_SIGNERS 1
  11. /**
  12. * Maximum number of multisignature signers (max N)
  13. */
  14. #define Token_MAX_SIGNERS 11
  15. /**
  16. * Account state.
  17. */
  18. enum Token_AccountState
  19. #ifdef __cplusplus
  20. : uint8_t
  21. #endif // __cplusplus
  22. {
  23. /**
  24. * Account is not yet initialized
  25. */
  26. Token_AccountState_Uninitialized,
  27. /**
  28. * Account is initialized; the account owner and/or delegate may perform permitted operations
  29. * on this account
  30. */
  31. Token_AccountState_Initialized,
  32. /**
  33. * Account has been frozen by the mint freeze authority. Neither the account owner nor
  34. * the delegate are able to perform operations on this account.
  35. */
  36. Token_AccountState_Frozen,
  37. };
  38. #ifndef __cplusplus
  39. typedef uint8_t Token_AccountState;
  40. #endif // __cplusplus
  41. /**
  42. * Specifies the authority type for SetAuthority instructions
  43. */
  44. enum Token_AuthorityType
  45. #ifdef __cplusplus
  46. : uint8_t
  47. #endif // __cplusplus
  48. {
  49. /**
  50. * Authority to mint new tokens
  51. */
  52. Token_AuthorityType_MintTokens,
  53. /**
  54. * Authority to freeze any account associated with the Mint
  55. */
  56. Token_AuthorityType_FreezeAccount,
  57. /**
  58. * Owner of a given token account
  59. */
  60. Token_AuthorityType_AccountOwner,
  61. /**
  62. * Authority to close a token account
  63. */
  64. Token_AuthorityType_CloseAccount,
  65. };
  66. #ifndef __cplusplus
  67. typedef uint8_t Token_AuthorityType;
  68. #endif // __cplusplus
  69. typedef uint8_t Token_Pubkey[32];
  70. /**
  71. * A C representation of Rust's `std::option::Option`
  72. */
  73. typedef enum Token_COption_Pubkey_Tag {
  74. /**
  75. * No value
  76. */
  77. Token_COption_Pubkey_None_Pubkey,
  78. /**
  79. * Some value `T`
  80. */
  81. Token_COption_Pubkey_Some_Pubkey,
  82. } Token_COption_Pubkey_Tag;
  83. typedef struct Token_COption_Pubkey {
  84. Token_COption_Pubkey_Tag tag;
  85. union {
  86. struct {
  87. Token_Pubkey some;
  88. };
  89. };
  90. } Token_COption_Pubkey;
  91. /**
  92. * Instructions supported by the token program.
  93. */
  94. typedef enum Token_TokenInstruction_Tag {
  95. /**
  96. * Initializes a new mint and optionally deposits all the newly minted
  97. * tokens in an account.
  98. *
  99. * The `InitializeMint` instruction requires no signers and MUST be
  100. * included within the same Transaction as the system program's
  101. * `CreateAccount` instruction that creates the account being initialized.
  102. * Otherwise another party can acquire ownership of the uninitialized
  103. * account.
  104. *
  105. * Accounts expected by this instruction:
  106. *
  107. * 0. `[writable]` The mint to initialize.
  108. * 1. `[]` Rent sysvar
  109. *
  110. */
  111. Token_TokenInstruction_InitializeMint,
  112. /**
  113. * Initializes a new account to hold tokens. If this account is associated
  114. * with the native mint then the token balance of the initialized account
  115. * will be equal to the amount of SOL in the account. If this account is
  116. * associated with another mint, that mint must be initialized before this
  117. * command can succeed.
  118. *
  119. * The `InitializeAccount` instruction requires no signers and MUST be
  120. * included within the same Transaction as the system program's
  121. * `CreateAccount` instruction that creates the account being initialized.
  122. * Otherwise another party can acquire ownership of the uninitialized
  123. * account.
  124. *
  125. * Accounts expected by this instruction:
  126. *
  127. * 0. `[writable]` The account to initialize.
  128. * 1. `[]` The mint this account will be associated with.
  129. * 2. `[]` The new account's owner/multisignature.
  130. * 3. `[]` Rent sysvar
  131. */
  132. Token_TokenInstruction_InitializeAccount,
  133. /**
  134. * Initializes a multisignature account with N provided signers.
  135. *
  136. * Multisignature accounts can used in place of any single owner/delegate
  137. * accounts in any token instruction that require an owner/delegate to be
  138. * present. The variant field represents the number of signers (M)
  139. * required to validate this multisignature account.
  140. *
  141. * The `InitializeMultisig` instruction requires no signers and MUST be
  142. * included within the same Transaction as the system program's
  143. * `CreateAccount` instruction that creates the account being initialized.
  144. * Otherwise another party can acquire ownership of the uninitialized
  145. * account.
  146. *
  147. * Accounts expected by this instruction:
  148. *
  149. * 0. `[writable]` The multisignature account to initialize.
  150. * 1. `[]` Rent sysvar
  151. * 2. ..2+N. `[]` The signer accounts, must equal to N where 1 <= N <=
  152. * 11.
  153. */
  154. Token_TokenInstruction_InitializeMultisig,
  155. /**
  156. * Transfers tokens from one account to another either directly or via a
  157. * delegate. If this account is associated with the native mint then equal
  158. * amounts of SOL and Tokens will be transferred to the destination
  159. * account.
  160. *
  161. * Accounts expected by this instruction:
  162. *
  163. * * Single owner/delegate
  164. * 0. `[writable]` The source account.
  165. * 1. `[writable]` The destination account.
  166. * 2. `[signer]` The source account's owner/delegate.
  167. *
  168. * * Multisignature owner/delegate
  169. * 0. `[writable]` The source account.
  170. * 1. `[writable]` The destination account.
  171. * 2. `[]` The source account's multisignature owner/delegate.
  172. * 3. ..3+M `[signer]` M signer accounts.
  173. */
  174. Token_TokenInstruction_Transfer,
  175. /**
  176. * Approves a delegate. A delegate is given the authority over tokens on
  177. * behalf of the source account's owner.
  178. *
  179. * Accounts expected by this instruction:
  180. *
  181. * * Single owner
  182. * 0. `[writable]` The source account.
  183. * 1. `[]` The delegate.
  184. * 2. `[signer]` The source account owner.
  185. *
  186. * * Multisignature owner
  187. * 0. `[writable]` The source account.
  188. * 1. `[]` The delegate.
  189. * 2. `[]` The source account's multisignature owner.
  190. * 3. ..3+M `[signer]` M signer accounts
  191. */
  192. Token_TokenInstruction_Approve,
  193. /**
  194. * Revokes the delegate's authority.
  195. *
  196. * Accounts expected by this instruction:
  197. *
  198. * * Single owner
  199. * 0. `[writable]` The source account.
  200. * 1. `[signer]` The source account owner.
  201. *
  202. * * Multisignature owner
  203. * 0. `[writable]` The source account.
  204. * 1. `[]` The source account's multisignature owner.
  205. * 2. ..2+M `[signer]` M signer accounts
  206. */
  207. Token_TokenInstruction_Revoke,
  208. /**
  209. * Sets a new authority of a mint or account.
  210. *
  211. * Accounts expected by this instruction:
  212. *
  213. * * Single authority
  214. * 0. `[writable]` The mint or account to change the authority of.
  215. * 1. `[signer]` The current authority of the mint or account.
  216. *
  217. * * Multisignature authority
  218. * 0. `[writable]` The mint or account to change the authority of.
  219. * 1. `[]` The mint's or account's current multisignature authority.
  220. * 2. ..2+M `[signer]` M signer accounts
  221. */
  222. Token_TokenInstruction_SetAuthority,
  223. /**
  224. * Mints new tokens to an account. The native mint does not support
  225. * minting.
  226. *
  227. * Accounts expected by this instruction:
  228. *
  229. * * Single authority
  230. * 0. `[writable]` The mint.
  231. * 1. `[writable]` The account to mint tokens to.
  232. * 2. `[signer]` The mint's minting authority.
  233. *
  234. * * Multisignature authority
  235. * 0. `[writable]` The mint.
  236. * 1. `[writable]` The account to mint tokens to.
  237. * 2. `[]` The mint's multisignature mint-tokens authority.
  238. * 3. ..3+M `[signer]` M signer accounts.
  239. */
  240. Token_TokenInstruction_MintTo,
  241. /**
  242. * Burns tokens by removing them from an account. `Burn` does not support
  243. * accounts associated with the native mint, use `CloseAccount` instead.
  244. *
  245. * Accounts expected by this instruction:
  246. *
  247. * * Single owner/delegate
  248. * 0. `[writable]` The account to burn from.
  249. * 1. `[writable]` The token mint.
  250. * 2. `[signer]` The account's owner/delegate.
  251. *
  252. * * Multisignature owner/delegate
  253. * 0. `[writable]` The account to burn from.
  254. * 1. `[writable]` The token mint.
  255. * 2. `[]` The account's multisignature owner/delegate.
  256. * 3. ..3+M `[signer]` M signer accounts.
  257. */
  258. Token_TokenInstruction_Burn,
  259. /**
  260. * Close an account by transferring all its SOL to the destination account.
  261. * Non-native accounts may only be closed if its token amount is zero.
  262. *
  263. * Accounts expected by this instruction:
  264. *
  265. * * Single owner
  266. * 0. `[writable]` The account to close.
  267. * 1. `[writable]` The destination account.
  268. * 2. `[signer]` The account's owner.
  269. *
  270. * * Multisignature owner
  271. * 0. `[writable]` The account to close.
  272. * 1. `[writable]` The destination account.
  273. * 2. `[]` The account's multisignature owner.
  274. * 3. ..3+M `[signer]` M signer accounts.
  275. */
  276. Token_TokenInstruction_CloseAccount,
  277. /**
  278. * Freeze an Initialized account using the Mint's freeze_authority (if
  279. * set).
  280. *
  281. * Accounts expected by this instruction:
  282. *
  283. * * Single owner
  284. * 0. `[writable]` The account to freeze.
  285. * 1. `[]` The token mint.
  286. * 2. `[signer]` The mint freeze authority.
  287. *
  288. * * Multisignature owner
  289. * 0. `[writable]` The account to freeze.
  290. * 1. `[]` The token mint.
  291. * 2. `[]` The mint's multisignature freeze authority.
  292. * 3. ..3+M `[signer]` M signer accounts.
  293. */
  294. Token_TokenInstruction_FreezeAccount,
  295. /**
  296. * Thaw a Frozen account using the Mint's freeze_authority (if set).
  297. *
  298. * Accounts expected by this instruction:
  299. *
  300. * * Single owner
  301. * 0. `[writable]` The account to freeze.
  302. * 1. `[]` The token mint.
  303. * 2. `[signer]` The mint freeze authority.
  304. *
  305. * * Multisignature owner
  306. * 0. `[writable]` The account to freeze.
  307. * 1. `[]` The token mint.
  308. * 2. `[]` The mint's multisignature freeze authority.
  309. * 3. ..3+M `[signer]` M signer accounts.
  310. */
  311. Token_TokenInstruction_ThawAccount,
  312. /**
  313. * Transfers tokens from one account to another either directly or via a
  314. * delegate. If this account is associated with the native mint then equal
  315. * amounts of SOL and Tokens will be transferred to the destination
  316. * account.
  317. *
  318. * This instruction differs from Transfer in that the token mint and
  319. * decimals value is checked by the caller. This may be useful when
  320. * creating transactions offline or within a hardware wallet.
  321. *
  322. * Accounts expected by this instruction:
  323. *
  324. * * Single owner/delegate
  325. * 0. `[writable]` The source account.
  326. * 1. `[]` The token mint.
  327. * 2. `[writable]` The destination account.
  328. * 3. `[signer]` The source account's owner/delegate.
  329. *
  330. * * Multisignature owner/delegate
  331. * 0. `[writable]` The source account.
  332. * 1. `[]` The token mint.
  333. * 2. `[writable]` The destination account.
  334. * 3. `[]` The source account's multisignature owner/delegate.
  335. * 4. ..4+M `[signer]` M signer accounts.
  336. */
  337. Token_TokenInstruction_TransferChecked,
  338. /**
  339. * Approves a delegate. A delegate is given the authority over tokens on
  340. * behalf of the source account's owner.
  341. *
  342. * This instruction differs from Approve in that the token mint and
  343. * decimals value is checked by the caller. This may be useful when
  344. * creating transactions offline or within a hardware wallet.
  345. *
  346. * Accounts expected by this instruction:
  347. *
  348. * * Single owner
  349. * 0. `[writable]` The source account.
  350. * 1. `[]` The token mint.
  351. * 2. `[]` The delegate.
  352. * 3. `[signer]` The source account owner.
  353. *
  354. * * Multisignature owner
  355. * 0. `[writable]` The source account.
  356. * 1. `[]` The token mint.
  357. * 2. `[]` The delegate.
  358. * 3. `[]` The source account's multisignature owner.
  359. * 4. ..4+M `[signer]` M signer accounts
  360. */
  361. Token_TokenInstruction_ApproveChecked,
  362. /**
  363. * Mints new tokens to an account. The native mint does not support
  364. * minting.
  365. *
  366. * This instruction differs from MintTo in that the decimals value is
  367. * checked by the caller. This may be useful when creating transactions
  368. * offline or within a hardware wallet.
  369. *
  370. * Accounts expected by this instruction:
  371. *
  372. * * Single authority
  373. * 0. `[writable]` The mint.
  374. * 1. `[writable]` The account to mint tokens to.
  375. * 2. `[signer]` The mint's minting authority.
  376. *
  377. * * Multisignature authority
  378. * 0. `[writable]` The mint.
  379. * 1. `[writable]` The account to mint tokens to.
  380. * 2. `[]` The mint's multisignature mint-tokens authority.
  381. * 3. ..3+M `[signer]` M signer accounts.
  382. */
  383. Token_TokenInstruction_MintToChecked,
  384. /**
  385. * Burns tokens by removing them from an account. `BurnChecked` does not
  386. * support accounts associated with the native mint, use `CloseAccount`
  387. * instead.
  388. *
  389. * This instruction differs from Burn in that the decimals value is checked
  390. * by the caller. This may be useful when creating transactions offline or
  391. * within a hardware wallet.
  392. *
  393. * Accounts expected by this instruction:
  394. *
  395. * * Single owner/delegate
  396. * 0. `[writable]` The account to burn from.
  397. * 1. `[writable]` The token mint.
  398. * 2. `[signer]` The account's owner/delegate.
  399. *
  400. * * Multisignature owner/delegate
  401. * 0. `[writable]` The account to burn from.
  402. * 1. `[writable]` The token mint.
  403. * 2. `[]` The account's multisignature owner/delegate.
  404. * 3. ..3+M `[signer]` M signer accounts.
  405. */
  406. Token_TokenInstruction_BurnChecked,
  407. } Token_TokenInstruction_Tag;
  408. typedef struct Token_TokenInstruction_Token_InitializeMint_Body {
  409. /**
  410. * Number of base 10 digits to the right of the decimal place.
  411. */
  412. uint8_t decimals;
  413. /**
  414. * The authority/multisignature to mint tokens.
  415. */
  416. Token_Pubkey mint_authority;
  417. /**
  418. * The freeze authority/multisignature of the mint.
  419. */
  420. struct Token_COption_Pubkey freeze_authority;
  421. } Token_TokenInstruction_Token_InitializeMint_Body;
  422. typedef struct Token_TokenInstruction_Token_InitializeMultisig_Body {
  423. /**
  424. * The number of signers (M) required to validate this multisignature
  425. * account.
  426. */
  427. uint8_t m;
  428. } Token_TokenInstruction_Token_InitializeMultisig_Body;
  429. typedef struct Token_TokenInstruction_Token_Transfer_Body {
  430. /**
  431. * The amount of tokens to transfer.
  432. */
  433. uint64_t amount;
  434. } Token_TokenInstruction_Token_Transfer_Body;
  435. typedef struct Token_TokenInstruction_Token_Approve_Body {
  436. /**
  437. * The amount of tokens the delegate is approved for.
  438. */
  439. uint64_t amount;
  440. } Token_TokenInstruction_Token_Approve_Body;
  441. typedef struct Token_TokenInstruction_Token_SetAuthority_Body {
  442. /**
  443. * The type of authority to update.
  444. */
  445. Token_AuthorityType authority_type;
  446. /**
  447. * The new authority
  448. */
  449. struct Token_COption_Pubkey new_authority;
  450. } Token_TokenInstruction_Token_SetAuthority_Body;
  451. typedef struct Token_TokenInstruction_Token_MintTo_Body {
  452. /**
  453. * The amount of new tokens to mint.
  454. */
  455. uint64_t amount;
  456. } Token_TokenInstruction_Token_MintTo_Body;
  457. typedef struct Token_TokenInstruction_Token_Burn_Body {
  458. /**
  459. * The amount of tokens to burn.
  460. */
  461. uint64_t amount;
  462. } Token_TokenInstruction_Token_Burn_Body;
  463. typedef struct Token_TokenInstruction_Token_TransferChecked_Body {
  464. /**
  465. * The amount of tokens to transfer.
  466. */
  467. uint64_t amount;
  468. /**
  469. * Expected number of base 10 digits to the right of the decimal place.
  470. */
  471. uint8_t decimals;
  472. } Token_TokenInstruction_Token_TransferChecked_Body;
  473. typedef struct Token_TokenInstruction_Token_ApproveChecked_Body {
  474. /**
  475. * The amount of tokens the delegate is approved for.
  476. */
  477. uint64_t amount;
  478. /**
  479. * Expected number of base 10 digits to the right of the decimal place.
  480. */
  481. uint8_t decimals;
  482. } Token_TokenInstruction_Token_ApproveChecked_Body;
  483. typedef struct Token_TokenInstruction_Token_MintToChecked_Body {
  484. /**
  485. * The amount of new tokens to mint.
  486. */
  487. uint64_t amount;
  488. /**
  489. * Expected number of base 10 digits to the right of the decimal place.
  490. */
  491. uint8_t decimals;
  492. } Token_TokenInstruction_Token_MintToChecked_Body;
  493. typedef struct Token_TokenInstruction_Token_BurnChecked_Body {
  494. /**
  495. * The amount of tokens to burn.
  496. */
  497. uint64_t amount;
  498. /**
  499. * Expected number of base 10 digits to the right of the decimal place.
  500. */
  501. uint8_t decimals;
  502. } Token_TokenInstruction_Token_BurnChecked_Body;
  503. typedef struct Token_TokenInstruction {
  504. Token_TokenInstruction_Tag tag;
  505. union {
  506. Token_TokenInstruction_Token_InitializeMint_Body initialize_mint;
  507. Token_TokenInstruction_Token_InitializeMultisig_Body initialize_multisig;
  508. Token_TokenInstruction_Token_Transfer_Body transfer;
  509. Token_TokenInstruction_Token_Approve_Body approve;
  510. Token_TokenInstruction_Token_SetAuthority_Body set_authority;
  511. Token_TokenInstruction_Token_MintTo_Body mint_to;
  512. Token_TokenInstruction_Token_Burn_Body burn;
  513. Token_TokenInstruction_Token_TransferChecked_Body transfer_checked;
  514. Token_TokenInstruction_Token_ApproveChecked_Body approve_checked;
  515. Token_TokenInstruction_Token_MintToChecked_Body mint_to_checked;
  516. Token_TokenInstruction_Token_BurnChecked_Body burn_checked;
  517. };
  518. } Token_TokenInstruction;
  519. /**
  520. * Mint data.
  521. */
  522. typedef struct Token_Mint {
  523. /**
  524. * Optional authority used to mint new tokens. The mint authority may only be provided during
  525. * mint creation. If no mint authority is present then the mint has a fixed supply and no
  526. * further tokens may be minted.
  527. */
  528. struct Token_COption_Pubkey mint_authority;
  529. /**
  530. * Total supply of tokens.
  531. */
  532. uint64_t supply;
  533. /**
  534. * Number of base 10 digits to the right of the decimal place.
  535. */
  536. uint8_t decimals;
  537. /**
  538. * Is `true` if this structure has been initialized
  539. */
  540. bool is_initialized;
  541. /**
  542. * Optional authority to freeze token accounts.
  543. */
  544. struct Token_COption_Pubkey freeze_authority;
  545. } Token_Mint;
  546. /**
  547. * A C representation of Rust's `std::option::Option`
  548. */
  549. typedef enum Token_COption_u64_Tag {
  550. /**
  551. * No value
  552. */
  553. Token_COption_u64_None_u64,
  554. /**
  555. * Some value `T`
  556. */
  557. Token_COption_u64_Some_u64,
  558. } Token_COption_u64_Tag;
  559. typedef struct Token_COption_u64 {
  560. Token_COption_u64_Tag tag;
  561. union {
  562. struct {
  563. uint64_t some;
  564. };
  565. };
  566. } Token_COption_u64;
  567. /**
  568. * Account data.
  569. */
  570. typedef struct Token_Account {
  571. /**
  572. * The mint associated with this account
  573. */
  574. Token_Pubkey mint;
  575. /**
  576. * The owner of this account.
  577. */
  578. Token_Pubkey owner;
  579. /**
  580. * The amount of tokens this account holds.
  581. */
  582. uint64_t amount;
  583. /**
  584. * If `delegate` is `Some` then `delegated_amount` represents
  585. * the amount authorized by the delegate
  586. */
  587. struct Token_COption_Pubkey delegate;
  588. /**
  589. * The account's state
  590. */
  591. Token_AccountState state;
  592. /**
  593. * If is_some, this is a native token, and the value logs the rent-exempt reserve. An Account
  594. * is required to be rent-exempt, so the value is used by the Processor to ensure that wrapped
  595. * SOL accounts do not drop below this threshold.
  596. */
  597. struct Token_COption_u64 is_native;
  598. /**
  599. * The amount delegated
  600. */
  601. uint64_t delegated_amount;
  602. /**
  603. * Optional authority to close the account.
  604. */
  605. struct Token_COption_Pubkey close_authority;
  606. } Token_Account;
  607. /**
  608. * Multisignature data.
  609. */
  610. typedef struct Token_Multisig {
  611. /**
  612. * Number of signers required
  613. */
  614. uint8_t m;
  615. /**
  616. * Number of valid signers
  617. */
  618. uint8_t n;
  619. /**
  620. * Is `true` if this structure has been initialized
  621. */
  622. bool is_initialized;
  623. /**
  624. * Signer public keys
  625. */
  626. Token_Pubkey signers[Token_MAX_SIGNERS];
  627. } Token_Multisig;