token.h 20 KB

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