payer_annotation.sol 1.5 KB

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