entrypoint.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. /**
  3. * @brief Solana program entrypoint
  4. */
  5. #include <sol/constants.h>
  6. #include <sol/types.h>
  7. #include <sol/pubkey.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**
  12. * Keyed Account
  13. */
  14. typedef struct {
  15. SolPubkey *key; /** Public key of the account */
  16. uint64_t *lamports; /** Number of lamports owned by this account */
  17. uint64_t data_len; /** Length of data in bytes */
  18. uint8_t *data; /** On-chain data within this account */
  19. SolPubkey *owner; /** Program that owns this account */
  20. uint64_t rent_epoch; /** The epoch at which this account will next owe rent */
  21. bool is_signer; /** Transaction was signed by this account's key? */
  22. bool is_writable; /** Is the account writable? */
  23. bool executable; /** This account's data contains a loaded program (and is now read-only) */
  24. } SolAccountInfo;
  25. /**
  26. * Structure that the program's entrypoint input data is deserialized into.
  27. */
  28. typedef struct {
  29. SolAccountInfo* ka; /** Pointer to an array of SolAccountInfo, must already
  30. point to an array of SolAccountInfos */
  31. uint64_t ka_num; /** Number of SolAccountInfo entries in `ka` */
  32. const uint8_t *data; /** pointer to the instruction data */
  33. uint64_t data_len; /** Length in bytes of the instruction data */
  34. const SolPubkey *program_id; /** program_id of the currently executing program */
  35. } SolParameters;
  36. /**
  37. * Program instruction entrypoint
  38. *
  39. * @param input Buffer of serialized input parameters. Use sol_deserialize() to decode
  40. * @return 0 if the instruction executed successfully
  41. */
  42. uint64_t entrypoint(const uint8_t *input);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. /**@}*/