create_contract_with_metas.sol 1017 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import 'solana';
  2. contract creator {
  3. Child public c;
  4. Child public c_metas;
  5. function create_with_metas(address data_account_to_initialize, address payer) public {
  6. AccountMeta[3] metas = [
  7. AccountMeta({
  8. pubkey: data_account_to_initialize,
  9. is_signer: true,
  10. is_writable: true}),
  11. AccountMeta({
  12. pubkey: payer,
  13. is_signer: true,
  14. is_writable: true}),
  15. AccountMeta({
  16. pubkey: address"11111111111111111111111111111111",
  17. is_writable: false,
  18. is_signer: false})
  19. ];
  20. c_metas = new Child{accounts: metas}(payer);
  21. c_metas.use_metas();
  22. }
  23. }
  24. @program_id("Chi1d5XD6nTAp2EyaNGqMxZzUjh6NvhXRxbGHP3D1RaT")
  25. contract Child {
  26. @payer(payer)
  27. constructor(address payer) {
  28. print("In child constructor");
  29. }
  30. function use_metas() pure public {
  31. print("I am using metas");
  32. }
  33. }