token.h 20 KB

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