payer_annotation.sol 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'solana';
  2. @program_id("SoLDxXQ9GMoa15i4NavZc61XGkas2aom4aNiWT6KUER")
  3. contract Builder {
  4. function build_this() external {
  5. // When calling a constructor from an external function, the data account for the contract
  6. // 'BeingBuilt' should be passed as the 'BeingBuilt_dataAccount' in the client code.
  7. BeingBuilt.new("my_seed");
  8. }
  9. function build_that(address data_account, address payer_account) public {
  10. // In non-external functions, developers need to manually create the account metas array.
  11. // The order of the accounts must match the order from the BeingBuilt IDL file for the "new"
  12. // instruction.
  13. AccountMeta[3] metas = [
  14. AccountMeta({
  15. pubkey: data_account,
  16. is_signer: true,
  17. is_writable: true
  18. }),
  19. AccountMeta({
  20. pubkey: payer_account,
  21. is_signer: true,
  22. is_writable: true
  23. }),
  24. AccountMeta({
  25. pubkey: address"11111111111111111111111111111111",
  26. is_writable: false,
  27. is_signer: false
  28. })
  29. ];
  30. BeingBuilt.new{accounts: metas}("my_seed");
  31. // No accounts are needed in this call, so we pass an empty vector.
  32. BeingBuilt.say_this{accounts: []}("It's summertime!");
  33. }
  34. }
  35. @program_id("SoLGijpEqEeXLEqa9ruh7a6Lu4wogd6rM8FNoR7e3wY")
  36. contract BeingBuilt {
  37. @space(1024)
  38. @payer(payer_account)
  39. constructor(@seed bytes my_seed) {}
  40. function say_this(string text) public pure {
  41. print(text);
  42. }
  43. }