token.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. * Instructions supported by the token program.
  20. */
  21. typedef enum Token_TokenInstruction_Tag {
  22. /**
  23. * Initializes a new mint and optionally deposits all the newly minted tokens in an account.
  24. *
  25. * The `InitializeMint` instruction requires no signers and MUST be included within
  26. * the same Transaction as the system program's `CreateInstruction` that creates the account
  27. * being initialized. Otherwise another party can acquire ownership of the uninitialized account.
  28. *
  29. * Accounts expected by this instruction:
  30. *
  31. * 0. `[writable]` The mint to initialize.
  32. * 1.
  33. * * If supply is non-zero: `[writable]` The account to hold all the newly minted tokens.
  34. * * If supply is zero: `[]` The owner/multisignature of the mint.
  35. * 2. `[]` (optional) The owner/multisignature of the mint if supply is non-zero, if
  36. * present then further minting is supported.
  37. *
  38. */
  39. Token_TokenInstruction_InitializeMint,
  40. /**
  41. * Initializes a new account to hold tokens. If this account is associated with the native mint
  42. * then the token balance of the initialized account will be equal to the amount of SOL in the account.
  43. *
  44. * The `InitializeAccount` instruction requires no signers and MUST be included within
  45. * the same Transaction as the system program's `CreateInstruction` that creates the account
  46. * being initialized. Otherwise another party can acquire ownership of the uninitialized account.
  47. *
  48. * Accounts expected by this instruction:
  49. *
  50. * 0. `[writable]` The account to initialize.
  51. * 1. `[]` The mint this account will be associated with.
  52. * 2. `[]` The new account's owner/multisignature.
  53. */
  54. Token_TokenInstruction_InitializeAccount,
  55. /**
  56. * Initializes a multisignature account with N provided signers.
  57. *
  58. * Multisignature accounts can used in place of any single owner/delegate accounts in any
  59. * token instruction that require an owner/delegate to be present. The variant field represents the
  60. * number of signers (M) required to validate this multisignature account.
  61. *
  62. * The `InitializeMultisig` instruction requires no signers and MUST be included within
  63. * the same Transaction as the system program's `CreateInstruction` that creates the account
  64. * being initialized. Otherwise another party can acquire ownership of the uninitialized account.
  65. *
  66. * Accounts expected by this instruction:
  67. *
  68. * 0. `[writable]` The multisignature account to initialize.
  69. * 1. ..1+N. `[]` The signer accounts, must equal to N where 1 <= N <= 11.
  70. */
  71. Token_TokenInstruction_InitializeMultisig,
  72. /**
  73. * Transfers tokens from one account to another either directly or via a delegate. If this
  74. * account is associated with the native mint then equal amounts of SOL and Tokens will be
  75. * transferred to the destination account.
  76. *
  77. * Accounts expected by this instruction:
  78. *
  79. * * Single owner/delegate
  80. * 0. `[writable]` The source account.
  81. * 1. `[writable]` The destination account.
  82. * 2. '[signer]' The source account's owner/delegate.
  83. *
  84. * * Multisignature owner/delegate
  85. * 0. `[writable]` The source account.
  86. * 1. `[writable]` The destination account.
  87. * 2. '[]' The source account's multisignature owner/delegate.
  88. * 3. ..3+M '[signer]' M signer accounts.
  89. */
  90. Token_TokenInstruction_Transfer,
  91. /**
  92. * Approves a delegate. A delegate is given the authority over
  93. * tokens on behalf of the source account's owner.
  94. * Accounts expected by this instruction:
  95. *
  96. * * Single owner
  97. * 0. `[writable]` The source account.
  98. * 1. `[]` The delegate.
  99. * 2. `[signer]` The source account owner.
  100. *
  101. * * Multisignature owner
  102. * 0. `[writable]` The source account.
  103. * 1. `[]` The delegate.
  104. * 2. '[]' The source account's multisignature owner.
  105. * 3. ..3+M '[signer]' M signer accounts
  106. */
  107. Token_TokenInstruction_Approve,
  108. /**
  109. * Revokes the delegate's authority.
  110. *
  111. * Accounts expected by this instruction:
  112. *
  113. * * Single owner
  114. * 0. `[writable]` The source account.
  115. * 1. `[signer]` The source account owner.
  116. *
  117. * * Multisignature owner
  118. * 0. `[writable]` The source account.
  119. * 1. '[]' The source account's multisignature owner.
  120. * 2. ..2+M '[signer]' M signer accounts
  121. */
  122. Token_TokenInstruction_Revoke,
  123. /**
  124. * Sets a new owner of a mint or account.
  125. *
  126. * Accounts expected by this instruction:
  127. *
  128. * * Single owner
  129. * 0. `[writable]` The mint or account to change the owner of.
  130. * 1. `[]` The new owner/delegate/multisignature.
  131. * 2. `[signer]` The owner of the mint or account.
  132. *
  133. * * Multisignature owner
  134. * 0. `[writable]` The mint or account to change the owner of.
  135. * 1. `[]` The new owner/delegate/multisignature.
  136. * 2. `[]` The mint's or account's multisignature owner.
  137. * 3. ..3+M '[signer]' M signer accounts
  138. */
  139. Token_TokenInstruction_SetOwner,
  140. /**
  141. * Mints new tokens to an account. The native mint does not support minting.
  142. *
  143. * Accounts expected by this instruction:
  144. *
  145. * * Single owner
  146. * 0. `[writable]` The mint.
  147. * 1. `[writable]` The account to mint tokens to.
  148. * 2. `[signer]` The mint's owner.
  149. *
  150. * * Multisignature owner
  151. * 0. `[writable]` The mint.
  152. * 1. `[writable]` The account to mint tokens to.
  153. * 2. `[]` The mint's multisignature owner.
  154. * 3. ..3+M '[signer]' M signer accounts.
  155. */
  156. Token_TokenInstruction_MintTo,
  157. /**
  158. * Burns tokens by removing them from an account. `Burn` does not support accounts
  159. * associated with the native mint, use `CloseAccount` instead.
  160. *
  161. * Accounts expected by this instruction:
  162. *
  163. * * Single owner/delegate
  164. * 0. `[writable]` The account to burn from.
  165. * 1. `[signer]` The account's owner/delegate.
  166. *
  167. * * Multisignature owner/delegate
  168. * 0. `[writable]` The account to burn from.
  169. * 1. `[]` The account's multisignature owner/delegate.
  170. * 2. ..2+M '[signer]' M signer accounts.
  171. */
  172. Token_TokenInstruction_Burn,
  173. /**
  174. * Close an account by transferring all its SOL to the destination account.
  175. * Non-native accounts may only be closed if its token amount is zero.
  176. *
  177. * Accounts expected by this instruction:
  178. *
  179. * * Single owner
  180. * 0. `[writable]` The account to close.
  181. * 1. '[writable]' The destination account.
  182. * 2. `[signer]` The account's owner.
  183. *
  184. * * Multisignature owner
  185. * 0. `[writable]` The account to close.
  186. * 1. '[writable]' The destination account.
  187. * 2. `[]` The account's multisignature owner.
  188. * 3. ..3+M '[signer]' M signer accounts.
  189. */
  190. Token_TokenInstruction_CloseAccount,
  191. } Token_TokenInstruction_Tag;
  192. typedef struct Token_TokenInstruction_Token_InitializeMint_Body {
  193. /**
  194. * Initial amount of tokens to mint.
  195. */
  196. uint64_t amount;
  197. /**
  198. * Number of base 10 digits to the right of the decimal place.
  199. */
  200. uint8_t decimals;
  201. } Token_TokenInstruction_Token_InitializeMint_Body;
  202. typedef struct Token_TokenInstruction_Token_InitializeMultisig_Body {
  203. /**
  204. * The number of signers (M) required to validate this multisignature account.
  205. */
  206. uint8_t m;
  207. } Token_TokenInstruction_Token_InitializeMultisig_Body;
  208. typedef struct Token_TokenInstruction_Token_Transfer_Body {
  209. /**
  210. * The amount of tokens to transfer.
  211. */
  212. uint64_t amount;
  213. } Token_TokenInstruction_Token_Transfer_Body;
  214. typedef struct Token_TokenInstruction_Token_Approve_Body {
  215. /**
  216. * The amount of tokens the delegate is approved for.
  217. */
  218. uint64_t amount;
  219. } Token_TokenInstruction_Token_Approve_Body;
  220. typedef struct Token_TokenInstruction_Token_MintTo_Body {
  221. /**
  222. * The amount of new tokens to mint.
  223. */
  224. uint64_t amount;
  225. } Token_TokenInstruction_Token_MintTo_Body;
  226. typedef struct Token_TokenInstruction_Token_Burn_Body {
  227. /**
  228. * The amount of tokens to burn.
  229. */
  230. uint64_t amount;
  231. } Token_TokenInstruction_Token_Burn_Body;
  232. typedef struct Token_TokenInstruction {
  233. Token_TokenInstruction_Tag tag;
  234. union {
  235. Token_TokenInstruction_Token_InitializeMint_Body initialize_mint;
  236. Token_TokenInstruction_Token_InitializeMultisig_Body initialize_multisig;
  237. Token_TokenInstruction_Token_Transfer_Body transfer;
  238. Token_TokenInstruction_Token_Approve_Body approve;
  239. Token_TokenInstruction_Token_MintTo_Body mint_to;
  240. Token_TokenInstruction_Token_Burn_Body burn;
  241. };
  242. } Token_TokenInstruction;
  243. typedef uint8_t Token_Pubkey[32];
  244. /**
  245. * A C representation of Rust's `std::option::Option`
  246. */
  247. typedef enum Token_COption_Pubkey_Tag {
  248. /**
  249. * No value
  250. */
  251. Token_COption_Pubkey_None_Pubkey,
  252. /**
  253. * Some value `T`
  254. */
  255. Token_COption_Pubkey_Some_Pubkey,
  256. } Token_COption_Pubkey_Tag;
  257. typedef struct Token_COption_Pubkey_Token_Some_Body_Pubkey {
  258. Token_Pubkey _0;
  259. } Token_COption_Pubkey_Token_Some_Body_Pubkey;
  260. typedef struct Token_COption_Pubkey {
  261. Token_COption_Pubkey_Tag tag;
  262. union {
  263. Token_COption_Pubkey_Token_Some_Body_Pubkey some;
  264. };
  265. } Token_COption_Pubkey;
  266. /**
  267. * Mint data.
  268. */
  269. typedef struct Token_Mint {
  270. /**
  271. * Optional owner, used to mint new tokens. The owner may only
  272. * be provided during mint creation. If no owner is present then the mint
  273. * has a fixed supply and no further tokens may be minted.
  274. */
  275. Token_COption_Pubkey owner;
  276. /**
  277. * Number of base 10 digits to the right of the decimal place.
  278. */
  279. uint8_t decimals;
  280. /**
  281. * Is `true` if this structure has been initialized
  282. */
  283. bool is_initialized;
  284. } Token_Mint;
  285. /**
  286. * Account data.
  287. */
  288. typedef struct Token_Account {
  289. /**
  290. * The mint associated with this account
  291. */
  292. Token_Pubkey mint;
  293. /**
  294. * The owner of this account.
  295. */
  296. Token_Pubkey owner;
  297. /**
  298. * The amount of tokens this account holds.
  299. */
  300. uint64_t amount;
  301. /**
  302. * If `delegate` is `Some` then `delegated_amount` represents
  303. * the amount authorized by the delegate
  304. */
  305. Token_COption_Pubkey delegate;
  306. /**
  307. * Is `true` if this structure has been initialized
  308. */
  309. bool is_initialized;
  310. /**
  311. * Is this a native token
  312. */
  313. bool is_native;
  314. /**
  315. * The amount delegated
  316. */
  317. uint64_t delegated_amount;
  318. } Token_Account;
  319. /**
  320. * Multisignature data.
  321. */
  322. typedef struct Token_Multisig {
  323. /**
  324. * Number of signers required
  325. */
  326. uint8_t m;
  327. /**
  328. * Number of valid signers
  329. */
  330. uint8_t n;
  331. /**
  332. * Is `true` if this structure has been initialized
  333. */
  334. bool is_initialized;
  335. /**
  336. * Signer public keys
  337. */
  338. Token_Pubkey signers[Token_MAX_SIGNERS];
  339. } Token_Multisig;