token.h 20 KB

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