Pārlūkot izejas kodu

Merge pull request #53 from LucasSte/solang-release

Update examples according to use the annotation syntax
John 1 gadu atpakaļ
vecāks
revīzija
e77b1dc1c4
37 mainītis faili ar 537 papildinājumiem un 755 dzēšanām
  1. 7 13
      basics/checking-accounts/solang/solidity/checking-accounts.sol
  2. 4 13
      basics/checking-accounts/solang/tests/checking-accounts.ts
  3. 5 4
      basics/cross-program-invocation/solang/solidity/hand.sol
  4. 10 28
      basics/cross-program-invocation/solang/tests/test.ts
  5. 2 2
      basics/hello-solana/solang/solidity/hello-solana.sol
  6. 7 5
      basics/pda-rent-payer/solang/solidity/pda-rent-payer.sol
  7. 4 8
      basics/pda-rent-payer/solang/tests/pda-rent-payer.ts
  8. 5 3
      basics/rent/solang/solidity/rent.sol
  9. 4 15
      basics/rent/solang/tests/rent.ts
  10. 9 5
      basics/transfer-sol/solang/solidity/transfer-sol.sol
  11. 12 38
      basics/transfer-sol/solang/tests/transfer-sol.ts
  12. 1 1
      compression/cnft-solang/Anchor.toml
  13. 0 2
      compression/cnft-solang/app/contexts/WalletContextProvider.tsx
  14. 167 113
      compression/cnft-solang/app/idl/compressed_nft.ts
  15. 1 0
      compression/cnft-solang/app/package.json
  16. 11 44
      compression/cnft-solang/app/pages/api/mintCnft.ts
  17. 21 18
      compression/cnft-solang/solidity/compressed-nft.sol
  18. 11 49
      compression/cnft-solang/tests/compressed-nft.ts
  19. 4 4
      tokens/create-token/solang/libraries/mpl_metadata.sol
  20. 1 1
      tokens/create-token/solang/libraries/spl_token.sol
  21. 18 14
      tokens/create-token/solang/solidity/create-token.sol
  22. 16 42
      tokens/create-token/solang/tests/create-token.ts
  23. 3 3
      tokens/nft-minter/solang/libraries/mpl_metadata.sol
  24. 1 1
      tokens/nft-minter/solang/libraries/spl_token.sol
  25. 32 24
      tokens/nft-minter/solang/solidity/nft-minter.sol
  26. 15 48
      tokens/nft-minter/solang/tests/nft-minter.ts
  27. 1 1
      tokens/pda-mint-authority/solang/libraries/spl_token.sol
  28. 49 35
      tokens/pda-mint-authority/solang/solidity/pda-mint-authority.sol
  29. 16 49
      tokens/pda-mint-authority/solang/tests/pda-mint-authority.ts
  30. 3 3
      tokens/spl-token-minter/solang/libraries/mpl_metadata.sol
  31. 1 1
      tokens/spl-token-minter/solang/libraries/spl_token.sol
  32. 25 18
      tokens/spl-token-minter/solang/solidity/spl-token-minter.sol
  33. 13 45
      tokens/spl-token-minter/solang/tests/spl-token-minter.ts
  34. 3 3
      tokens/transfer-tokens/solang/libraries/mpl_metadata.sol
  35. 1 1
      tokens/transfer-tokens/solang/libraries/spl_token.sol
  36. 36 30
      tokens/transfer-tokens/solang/solidity/transfer-tokens.sol
  37. 18 71
      tokens/transfer-tokens/solang/tests/transfer-tokens.ts

+ 7 - 13
basics/checking-accounts/solang/solidity/checking-accounts.sol

@@ -8,21 +8,15 @@ contract checking_accounts {
     @payer(payer) // "payer" is the account that pays to create the dataAccount
     constructor() {}
 
-    function checkAccounts(address accountToChange, address accountToCreate) public view {
+    @account(accountToChange)
+    @mutableSigner(accountToCreate)
+    function checkAccounts(address accountToChange, address accountToCreate) external view {
         print("Number of Accounts Provided: {:}".format(tx.accounts.length));
 
-        // Find the accounts we are looking for and perform checks on them
-        for (uint64 i = 0; i < tx.accounts.length; i++) {
-            if (tx.accounts[i].key == accountToChange) {
-                print("Found Account To Change");
-                programOwnerCheck(tx.accounts[i]);
-            }
-            if (tx.accounts[i].key == accountToCreate) {
-                print("Found Account To Create");
-                notInitializedCheck(tx.accounts[i]);
-                signerCheck(tx.accounts[i]);
-            }
-        }
+        // Perform checks on the account
+        programOwnerCheck(tx.accounts.accountToChange);
+        notInitializedCheck(tx.accounts.accountToCreate);
+        signerCheck(tx.accounts.accountToCreate);
 
         // (Create account...) (unimplemented)
         // (Change account...) (unimplemented)

+ 4 - 13
basics/checking-accounts/solang/tests/checking-accounts.ts

@@ -55,19 +55,10 @@ describe("checking-accounts", () => {
     // Invoke the checkAccounts instruction on our program, passing in the account we want to "check"
     const tx = await program.methods
       .checkAccounts(accountToChange.publicKey, accountToCreate.publicKey)
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: accountToChange.publicKey,
-          isWritable: true,
-          isSigner: false,
-        },
-        {
-          pubkey: accountToCreate.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-      ])
+      .accounts({ 
+        accountToCreate: accountToCreate.publicKey,
+        accountToChange: accountToChange.publicKey,
+    })
       .signers([accountToCreate])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);

+ 5 - 4
basics/cross-program-invocation/solang/solidity/hand.sol

@@ -2,7 +2,7 @@
 import "solana";
 
 // Interface to the lever program.
-leverInterface constant leverProgram = leverInterface(address'4wFN9As94uDgcBK9umEi6DNjRLi8gq7jaHwSw3829xq8');
+@program_id("4wFN9As94uDgcBK9umEi6DNjRLi8gq7jaHwSw3829xq8")
 interface leverInterface {
     function switchPower(string name) external;
 }
@@ -16,17 +16,18 @@ contract hand {
     constructor() {}
 
     // "Pull the lever" by calling the switchPower instruction on the lever program via a Cross Program Invocation.
-    function pullLever(address dataAccount, string name) public {
+    @mutableAccount(leverData)
+    function pullLever(string name) external {
         // The account required by the switchPower instruction.
         // This is the data account created by the lever program (not this program), which stores the state of the switch.
         AccountMeta[1] metas = [
-            AccountMeta({pubkey: dataAccount, is_writable: true, is_signer: false})
+            AccountMeta({pubkey: tx.accounts.leverData.key, is_writable: true, is_signer: false})
         ];
 
         // The data required by the switchPower instruction.
         string instructionData = name;
 
         // Invoke the switchPower instruction on the lever program.
-        leverProgram.switchPower{accounts: metas}(instructionData);
+        leverInterface.switchPower{accounts: metas}(instructionData);
     }
 }

+ 10 - 28
basics/cross-program-invocation/solang/tests/test.ts

@@ -47,20 +47,11 @@ describe("cross-program-invocation", () => {
 
     // Call the pullLever instruction on the hand program, which invokes the lever program via CPI
     const tx2 = await handProgram.methods
-      .pullLever(dataAccountLever.publicKey, "Chris")
-      .accounts({ dataAccount: dataAccountHand.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: dataAccountLever.publicKey, // The lever program's data account, which stores the state
-          isWritable: true,
-          isSigner: false,
-        },
-        {
-          pubkey: leverProgram.programId, // The lever program's program ID
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .pullLever("Chris")
+      .accounts({ 
+        leverData: dataAccountLever.publicKey, // The lever program's data account, which stores the state
+        leverInterface_programId: leverProgram.programId // The lever program's program ID
+        })
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx2);
 
@@ -76,20 +67,11 @@ describe("cross-program-invocation", () => {
   it("Pull it again!", async () => {
     // Call the pullLever instruction on the hand program, which invokes the lever program via CPI
     const tx = await handProgram.methods
-      .pullLever(dataAccountLever.publicKey, "Ashley")
-      .accounts({ dataAccount: dataAccountHand.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: dataAccountLever.publicKey, // The lever program's data account, which stores the state
-          isWritable: true,
-          isSigner: false,
-        },
-        {
-          pubkey: leverProgram.programId, // The lever program's program ID
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .pullLever("Ashley")
+      .accounts({ 
+        leverData: dataAccountLever.publicKey, // The lever program's data account, which stores the state
+        leverInterface_programId: leverProgram.programId, // The lever program's program ID
+       })
       .rpc({ skipPreflight: true });
 
     console.log("Your transaction signature", tx);

+ 2 - 2
basics/hello-solana/solang/solidity/hello-solana.sol

@@ -5,8 +5,8 @@ contract hello_solana {
     // Here we create a new account that stores no data and only prints messages to the program logs when the constructor is called.
     @payer(payer) // The "payer" pays for the account creation
     constructor() {
-        // We get the program ID by calling 'type(hello_solana).program_id', where "hello_solana" is the name of the contract.
-        address programId = type(hello_solana).program_id;
+        // We get the program ID by calling 'this';
+        address programId = address(this);
 
         // Print messages to the program logs
         print("Hello, Solana!");

+ 7 - 5
basics/pda-rent-payer/solang/solidity/pda-rent-payer.sol

@@ -8,7 +8,7 @@ contract pda_rent_payer {
     @seed("rent_vault") // hardcoded seed
     constructor(@bump bytes1 bump, uint64 fundLamports) {
         // Independently derive the PDA address from the seeds, bump, and programId
-        (address pda, bytes1 _bump) = try_find_program_address(["rent_vault"], type(pda_rent_payer).program_id);
+        (address pda, bytes1 _bump) = try_find_program_address(["rent_vault"], address(this));
 
         // Verify that the bump passed to the constructor matches the bump derived from the seeds and programId
         // This ensures that only the canonical pda address can be used to create the account (first bump that generates a valid pda address)
@@ -17,14 +17,16 @@ contract pda_rent_payer {
         // Fund the pda account with additional lamports
         SystemInstruction.transfer(
             tx.accounts.payer.key, // from
-            address(this), // to (the address of the account being created)
+            tx.accounts.dataAccount.key, // to (the address of the account being created)
             fundLamports // amount of lamports to transfer
         );
     }
 
-    function createNewAccount(uint64 lamports) public {
-        AccountInfo from = tx.accounts[0]; // first account must be an account owned by the program
-        AccountInfo to = tx.accounts[1]; // second account must be the intended recipient
+    @mutableAccount(ownedByProgram)
+    @mutableAccount(intendedRecipient)
+    function createNewAccount(uint64 lamports) external {
+        AccountInfo from = tx.accounts.ownedByProgram; // an account owned by the program
+        AccountInfo to = tx.accounts.intendedRecipient; // second account must be the intended recipient
 
         print("From: {:}".format(from.key));
         print("To: {:}".format(to.key));

+ 4 - 8
basics/pda-rent-payer/solang/tests/pda-rent-payer.ts

@@ -44,14 +44,10 @@ describe("pda-rent-payer", () => {
     // Invoke the createNewAccount instruction on our program
     const tx = await program.methods
       .createNewAccount(new anchor.BN(lamports))
-      .accounts({ dataAccount: dataAccountPDA })
-      .remainingAccounts([
-        {
-          pubkey: newAccount.publicKey, // account to create by directly transferring lamports
-          isWritable: true,
-          isSigner: false,
-        },
-      ])
+      .accounts({ 
+        ownedByProgram: dataAccountPDA,
+        intendedRecipient: newAccount.publicKey, // account to create by directly transferring lamports
+    })
       .rpc();
     console.log("Your transaction signature", tx);
 

+ 5 - 3
basics/rent/solang/solidity/rent.sol

@@ -8,13 +8,15 @@ contract rent {
     @payer(payer) // The "payer" pays for the data account creation
     constructor() {}
 
-    function createSystemAccount(address payer, address newAccount, uint64 space) public {
+    @mutableSigner(payer)
+    @mutableSigner(newAccount)
+    function createSystemAccount(uint64 space) external {
         // The minimum lamports required for the amount of space allocated to the account
         uint64 lamports = minimum_balance(space);
 
         SystemInstruction.create_account(
-            payer,        // lamports sent from this account (payer)
-            newAccount, // lamports sent to this account (account to be created)
+            tx.accounts.payer.key,        // lamports sent from this account (payer)
+            tx.accounts.newAccount.key, // lamports sent to this account (account to be created)
             lamports,      // lamport amount (minimum lamports required)
             space,          // space required for the account
             SystemInstruction.systemAddress // program owner (system program)

+ 4 - 15
basics/rent/solang/tests/rent.ts

@@ -33,24 +33,13 @@ describe("rent", () => {
     // Create a new account via a Cross Program Invocation to the system program
     const tx = await program.methods
       .createSystemAccount(
-        wallet.publicKey, // payer
-        newAccount.publicKey, // new account
         new anchor.BN(space) // space
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
+      .accounts({ 
+        payer: wallet.publicKey,
+        newAccount: newAccount.publicKey,
+       })
       .signers([newAccount]) // new account keypair required as signer
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        {
-          pubkey: newAccount.publicKey, // new account
-          isWritable: true,
-          isSigner: true,
-        },
-      ])
       .rpc();
     console.log("Your transaction signature", tx);
   });

+ 9 - 5
basics/transfer-sol/solang/solidity/transfer-sol.sol

@@ -10,16 +10,20 @@ contract transfer_sol {
     }
 
     // Transfer SOL from one account to another using CPI (Cross Program Invocation) to the System program
-    function transferSolWithCpi(address from, address to, uint64 lamports) public {
+    @mutableSigner(sender)
+    @mutableAccount(recipient)
+    function transferSolWithCpi(uint64 lamports) external {
         // CPI to transfer SOL using "system_instruction" library
-        SystemInstruction.transfer(from, to, lamports);
+        SystemInstruction.transfer(tx.accounts.sender.key, tx.accounts.recipient.key, lamports);
     }
 
     // Transfer SOL from program owned account to another address by directly modifying the account data lamports
     // This approach only works for accounts owned by the program itself (ex. the dataAccount created in the constructor)
-    function transferSolWithProgram(uint64 lamports) public {
-        AccountInfo from = tx.accounts[0]; // first account must be an account owned by the program
-        AccountInfo to = tx.accounts[1]; // second account must be the intended recipient
+    @mutableAccount(sender)
+    @mutableAccount(recipient)
+    function transferSolWithProgram(uint64 lamports) external {
+        AccountInfo from = tx.accounts.sender; // first account must be an account owned by the program
+        AccountInfo to = tx.accounts.recipient; // second account must be the intended recipient
 
         print("From: {:}".format(from.key));
         print("To: {:}".format(to.key));

+ 12 - 38
basics/transfer-sol/solang/tests/transfer-sol.ts

@@ -37,23 +37,12 @@ describe("transfer-sol", () => {
 
     const tx = await program.methods
       .transferSolWithCpi(
-        wallet.publicKey, // sender
-        recipient.publicKey, // recipient
         new anchor.BN(transferAmount) // amount in lamports
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey, // sender
-          isWritable: true,
-          isSigner: true,
-        },
-        {
-          pubkey: recipient.publicKey, // recipient
-          isWritable: true,
-          isSigner: false,
-        },
-      ])
+      .accounts({
+        sender: wallet.publicKey,
+        recipient: recipient.publicKey
+       })
       .rpc();
 
     await getBalances(wallet.publicKey, recipient.publicKey, "Resulting");
@@ -66,23 +55,12 @@ describe("transfer-sol", () => {
 
     const tx = await program.methods
       .transferSolWithCpi(
-        wallet.publicKey, // sender
-        dataAccount.publicKey, // recipient
         new anchor.BN(transferAmount) // amount in lamports
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey, // sender
-          isWritable: true,
-          isSigner: true,
-        },
-        {
-          pubkey: dataAccount.publicKey, // recipient
-          isWritable: true,
-          isSigner: false,
-        },
-      ])
+      .accounts({ 
+        sender: wallet.publicKey,
+        recipient: dataAccount.publicKey,
+       })
       .rpc();
 
     await getBalances(wallet.publicKey, dataAccount.publicKey, "Resulting");
@@ -97,14 +75,10 @@ describe("transfer-sol", () => {
       .transferSolWithProgram(
         new anchor.BN(transferAmount) // amount in lamports
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey, // recipient
-          isWritable: true,
-          isSigner: true,
-        },
-      ])
+      .accounts({ 
+        sender: dataAccount.publicKey,
+        recipient: wallet.publicKey,
+       })
       .rpc();
 
     await getBalances(dataAccount.publicKey, wallet.publicKey, "Resulting");

+ 1 - 1
compression/cnft-solang/Anchor.toml

@@ -2,7 +2,7 @@
 seeds = false
 skip-lint = false
 [programs.devnet]
-compressed_nft = "BhDH6TLEnf4dLq9hLn2gLwm5rJdj8Cbdc9ZrsjUpL7kB"
+compressed_nft = "BvgEJTPXfriGPopjJr1nLc4vADXm7A7TqjLFVztpd19Q"
 
 [registry]
 url = "https://api.apr.dev"

+ 0 - 2
compression/cnft-solang/app/contexts/WalletContextProvider.tsx

@@ -8,7 +8,6 @@ import { WalletModalProvider } from "@solana/wallet-adapter-react-ui"
 import {
   PhantomWalletAdapter,
   SolflareWalletAdapter,
-  BackpackWalletAdapter,
 } from "@solana/wallet-adapter-wallets"
 import { clusterApiUrl } from "@solana/web3.js"
 require("@solana/wallet-adapter-react-ui/styles.css")
@@ -19,7 +18,6 @@ const WalletContextProvider: FC<{ children: ReactNode }> = ({ children }) => {
 
   const wallets = useMemo(
     () => [
-      new BackpackWalletAdapter(),
       new PhantomWalletAdapter(),
       new SolflareWalletAdapter(),
     ],

+ 167 - 113
compression/cnft-solang/app/idl/compressed_nft.ts

@@ -1,175 +1,229 @@
 export type CompressedNft = {
-  version: "0.3.1";
-  name: "compressed_nft";
-  instructions: [
+  "version": "0.0.1",
+  "name": "compressed_nft",
+  "instructions": [
     {
-      name: "new";
-      accounts: [
+      "name": "new",
+      "accounts": [
         {
-          name: "dataAccount";
-          isMut: true;
-          isSigner: false;
-          isOptional: false;
+          "name": "dataAccount",
+          "isMut": true,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "payer";
-          isMut: true;
-          isSigner: true;
-          isOptional: false;
+          "name": "payer",
+          "isMut": true,
+          "isSigner": true,
+          "isOptional": false
         },
         {
-          name: "systemProgram";
-          isMut: false;
-          isSigner: false;
-          isOptional: false;
+          "name": "systemProgram",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         }
-      ];
-      args: [
-        {
-          name: "bump";
-          type: {
-            array: ["u8", 1];
-          };
+      ],
+      "args": [
+        {
+          "name": "bump",
+          "type": {
+            "array": [
+              "u8",
+              1
+            ]
+          }
         }
-      ];
+      ]
     },
     {
-      name: "mint";
-      accounts: [
+      "name": "mint",
+      "accounts": [
         {
-          name: "dataAccount";
-          isMut: true;
-          isSigner: false;
-          isOptional: false;
+          "name": "tree_authority",
+          "isMut": true,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "systemProgram";
-          isMut: false;
-          isSigner: false;
-          isOptional: false;
-        }
-      ];
-      args: [
+          "name": "leaf_owner",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
+        },
+        {
+          "name": "leaf_delegate",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
+        },
         {
-          name: "treeAuthority";
-          type: "publicKey";
+          "name": "merkle_tree",
+          "isMut": true,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "leafOwner";
-          type: "publicKey";
+          "name": "payer",
+          "isMut": true,
+          "isSigner": true,
+          "isOptional": false
         },
         {
-          name: "leafDelegate";
-          type: "publicKey";
+          "name": "tree_delegate",
+          "isMut": true,
+          "isSigner": true,
+          "isOptional": false
         },
         {
-          name: "merkleTree";
-          type: "publicKey";
+          "name": "noop_address",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "payer";
-          type: "publicKey";
+          "name": "compression_pid",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "treeDelegate";
-          type: "publicKey";
+          "name": "bubblegum_pid",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "uri";
-          type: "string";
+          "name": "systemProgram",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         }
-      ];
+      ],
+      "args": [
+        {
+          "name": "uri",
+          "type": "string"
+        }
+      ]
     }
-  ];
-  metadata: {
-    address: "BhDH6TLEnf4dLq9hLn2gLwm5rJdj8Cbdc9ZrsjUpL7kB";
-  };
+  ],
+  "metadata": {
+    "address": "BvgEJTPXfriGPopjJr1nLc4vADXm7A7TqjLFVztpd19Q"
+  }
 };
 
 export const IDL: CompressedNft = {
-  version: "0.3.1",
-  name: "compressed_nft",
-  instructions: [
+  "version": "0.0.1",
+  "name": "compressed_nft",
+  "instructions": [
     {
-      name: "new",
-      accounts: [
+      "name": "new",
+      "accounts": [
         {
-          name: "dataAccount",
-          isMut: true,
-          isSigner: false,
-          isOptional: false,
+          "name": "dataAccount",
+          "isMut": true,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "payer",
-          isMut: true,
-          isSigner: true,
-          isOptional: false,
+          "name": "payer",
+          "isMut": true,
+          "isSigner": true,
+          "isOptional": false
         },
         {
-          name: "systemProgram",
-          isMut: false,
-          isSigner: false,
-          isOptional: false,
-        },
-      ],
-      args: [
-        {
-          name: "bump",
-          type: {
-            array: ["u8", 1],
-          },
-        },
+          "name": "systemProgram",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
+        }
       ],
+      "args": [
+        {
+          "name": "bump",
+          "type": {
+            "array": [
+              "u8",
+              1
+            ]
+          }
+        }
+      ]
     },
     {
-      name: "mint",
-      accounts: [
+      "name": "mint",
+      "accounts": [
         {
-          name: "dataAccount",
-          isMut: true,
-          isSigner: false,
-          isOptional: false,
+          "name": "tree_authority",
+          "isMut": true,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "systemProgram",
-          isMut: false,
-          isSigner: false,
-          isOptional: false,
+          "name": "leaf_owner",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
-      ],
-      args: [
         {
-          name: "treeAuthority",
-          type: "publicKey",
+          "name": "leaf_delegate",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "leafOwner",
-          type: "publicKey",
+          "name": "merkle_tree",
+          "isMut": true,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "leafDelegate",
-          type: "publicKey",
+          "name": "payer",
+          "isMut": true,
+          "isSigner": true,
+          "isOptional": false
         },
         {
-          name: "merkleTree",
-          type: "publicKey",
+          "name": "tree_delegate",
+          "isMut": true,
+          "isSigner": true,
+          "isOptional": false
         },
         {
-          name: "payer",
-          type: "publicKey",
+          "name": "noop_address",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "treeDelegate",
-          type: "publicKey",
+          "name": "compression_pid",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
         {
-          name: "uri",
-          type: "string",
+          "name": "bubblegum_pid",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
         },
+        {
+          "name": "systemProgram",
+          "isMut": false,
+          "isSigner": false,
+          "isOptional": false
+        }
       ],
-    },
+      "args": [
+        {
+          "name": "uri",
+          "type": "string"
+        }
+      ]
+    }
   ],
-  metadata: {
-    address: "BhDH6TLEnf4dLq9hLn2gLwm5rJdj8Cbdc9ZrsjUpL7kB",
-  },
+  "metadata": {
+    "address": "BvgEJTPXfriGPopjJr1nLc4vADXm7A7TqjLFVztpd19Q"
+  }
 };

+ 1 - 0
compression/cnft-solang/app/package.json

@@ -11,6 +11,7 @@
   "dependencies": {
     "@chakra-ui/next-js": "^2.1.3",
     "@chakra-ui/react": "^2.6.1",
+    "@coral-xyz/anchor": "^0.29.0",
     "@emotion/react": "^11.11.0",
     "@emotion/styled": "^11.11.0",
     "@metaplex-foundation/mpl-bubblegum": "^0.7.0",

+ 11 - 44
compression/cnft-solang/app/pages/api/mintCnft.ts

@@ -61,52 +61,19 @@ async function buildTransaction(account: PublicKey, reference: PublicKey) {
   // Initialize the dataAccount.
   const instruction = await program.methods
     .mint(
-      treeAuthority, // treeAuthority
-      account, // leafOwner
-      account, // leafDelegate
-      treeAddress, // merkleTree
-      account, // payer
-      account, // treeDelegate, public tree (no delegate check, just require signer)
       randomUri // uri
     )
-    .accounts({ dataAccount: dataAccount })
-    .remainingAccounts([
-      {
-        pubkey: account,
-        isWritable: true,
-        isSigner: true,
-      },
-      {
-        pubkey: treeAuthority,
-        isWritable: true,
-        isSigner: false,
-      },
-      {
-        pubkey: treeAddress,
-        isWritable: true,
-        isSigner: false,
-      },
-      {
-        pubkey: SPL_NOOP_PROGRAM_ID,
-        isWritable: false,
-        isSigner: false,
-      },
-      {
-        pubkey: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
-        isWritable: false,
-        isSigner: false,
-      },
-      {
-        pubkey: BUBBLEGUM_PROGRAM_ID,
-        isWritable: false,
-        isSigner: false,
-      },
-      {
-        pubkey: SystemProgram.programId,
-        isWritable: false,
-        isSigner: false,
-      },
-    ])
+    .accounts({ 
+        tree_authority: treeAuthority, // treeAuthority
+        leaf_owner: account, // leafOwner
+        leaf_delegate: account, // leafDelegate
+        merkle_tree: account, // merkleTree
+        payer: account, // payer
+        tree_delegate: account, // treeDelegate, public tree (no delegate check, just require signer)
+        noop_address: SPL_NOOP_PROGRAM_ID,
+        compression_pid: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
+        bubblegum_pid: BUBBLEGUM_PROGRAM_ID,
+    })
     .instruction()
 
   // Add the reference account to the instruction

+ 21 - 18
compression/cnft-solang/solidity/compressed-nft.sol

@@ -1,7 +1,7 @@
 
 import "solana";
 
-@program_id("BhDH6TLEnf4dLq9hLn2gLwm5rJdj8Cbdc9ZrsjUpL7kB")
+@program_id("BvgEJTPXfriGPopjJr1nLc4vADXm7A7TqjLFVztpd19Q")
 contract compressed_nft {
 
     @payer(payer) // payer address
@@ -16,22 +16,25 @@ contract compressed_nft {
     // Mint a compressed NFT to an existing merkle tree, via a cross-program invocation to the Bubblegum program
     // Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/bubblegum/program/src/lib.rs#L922
     // Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/bubblegum/program/src/lib.rs#L67
+    @mutableAccount(tree_authority) // authority of the merkle tree
+    @account(leaf_owner) // owner of the new compressed NFT
+    @account(leaf_delegate) // delegate of the new compressed NFT (can be the same as leaf_owner)
+    @mutableAccount(merkle_tree)  // address of the merkle tree
+    @mutableSigner(payer) // payer
+    @mutableSigner(tree_delegate) // delegate of the merkle tree
+    @account(noop_address)
+    @account(compression_pid)
+    @account(bubblegum_pid)
     function mint(
-        address tree_authority, // authority of the merkle tree
-        address leaf_owner, // owner of the new compressed NFT
-        address leaf_delegate, // delegate of the new compressed NFT (can be the same as leaf_owner)
-        address merkle_tree, // address of the merkle tree
-        address payer, // payer
-        address tree_delegate, // delegate of the merkle tree
         string uri // uri of the new compressed NFT (metadata)
-    ) public {
+    ) external {
         print("Minting Compressed NFT");
 
         // Create a creator array with a single creator
         Creator[] memory creators = new Creator[](1);
         // Set the creator to the payer
         creators[0] = Creator({
-            creatorAddress: payer,
+            creatorAddress: tx.accounts.payer.key,
             verified: false,
             share: 100
         });
@@ -67,14 +70,14 @@ contract compressed_nft {
         });
 
         AccountMeta[9] metas = [
-            AccountMeta({pubkey: tree_authority, is_writable: true, is_signer: false}),
-            AccountMeta({pubkey: leaf_owner, is_writable: false, is_signer: false}),
-            AccountMeta({pubkey: leaf_delegate, is_writable: false, is_signer: false}),
-            AccountMeta({pubkey: merkle_tree, is_writable: true, is_signer: false}),
-            AccountMeta({pubkey: payer, is_writable: true, is_signer: true}),
-            AccountMeta({pubkey: tree_delegate, is_writable: true, is_signer: true}),
-            AccountMeta({pubkey: address"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV", is_writable: false, is_signer: false}),
-            AccountMeta({pubkey: address"cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK", is_writable: false, is_signer: false}),
+            AccountMeta({pubkey: tx.accounts.tree_authority.key, is_writable: true, is_signer: false}),
+            AccountMeta({pubkey: tx.accounts.leaf_owner.key, is_writable: false, is_signer: false}),
+            AccountMeta({pubkey: tx.accounts.leaf_delegate.key, is_writable: false, is_signer: false}),
+            AccountMeta({pubkey: tx.accounts.merkle_tree.key, is_writable: true, is_signer: false}),
+            AccountMeta({pubkey: tx.accounts.payer.key, is_writable: true, is_signer: true}),
+            AccountMeta({pubkey: tx.accounts.tree_delegate.key, is_writable: true, is_signer: true}),
+            AccountMeta({pubkey: tx.accounts.noop_address.key, is_writable: false, is_signer: false}),
+            AccountMeta({pubkey: tx.accounts.compression_pid.key, is_writable: false, is_signer: false}),
             AccountMeta({pubkey: address"11111111111111111111111111111111", is_writable: false, is_signer: false})
         ];
 
@@ -83,7 +86,7 @@ contract compressed_nft {
         bytes instructionData = abi.encode(discriminator, args);
 
         // Invoking the Bubblegum program
-        address'BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'.call{accounts: metas}(instructionData);
+        tx.accounts.bubblegum_pid.key.call{accounts: metas}(instructionData);
     }
 
     // Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/bubblegum/program/src/state/metaplex_adapter.rs#L81

+ 11 - 49
compression/cnft-solang/tests/compressed-nft.ts

@@ -131,57 +131,19 @@ describe("compressed-nft", () => {
 
     const tx = await program.methods
       .mint(
-        treeAuthority, // treeAuthority
-        receiver, // leafOwner
-        receiver, // leafDelegate
-        treeKeypair.publicKey, // merkleTree
-        wallet.publicKey, // payer
-        wallet.publicKey, // treeDelegate
         randomUri // uri
       )
-      .accounts({ dataAccount: dataAccount }) // dataAccount required by Solang even though its unused.
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey, // payer (and tree delegate in this example)
-          isWritable: true,
-          isSigner: true,
-        },
-        {
-          pubkey: receiver, // new leaf owner
-          isWritable: false,
-          isSigner: false,
-        },
-        {
-          pubkey: treeAuthority, // tree authority
-          isWritable: true,
-          isSigner: false,
-        },
-        {
-          pubkey: treeKeypair.publicKey, // tree account address
-          isWritable: true,
-          isSigner: false,
-        },
-        {
-          pubkey: SPL_NOOP_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-        {
-          pubkey: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-        {
-          pubkey: BUBBLEGUM_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-        {
-          pubkey: SystemProgram.programId,
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .accounts({ 
+        tree_authority: treeAuthority,
+        leaf_owner: receiver,
+        leaf_delegate: receiver,
+        merkle_tree: treeKeypair.publicKey,
+        payer: wallet.publicKey,
+        tree_delegate: wallet.publicKey,
+        noop_address: SPL_NOOP_PROGRAM_ID,
+        compression_pid: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
+        bubblegum_pid: BUBBLEGUM_PROGRAM_ID,
+       })
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
   });

+ 4 - 4
tokens/create-token/solang/libraries/mpl_metadata.sol

@@ -6,10 +6,8 @@ import 'solana';
 // If bool for Option<> type is false, comment out the corresponding struct field otherwise instruction fails with "invalid account data"
 // TODO: figure out better way to handle Option<> types
 library MplMetadata {
-	address constant metadataProgramId = address"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
 	address constant systemAddress = address"11111111111111111111111111111111";
-    address constant rentAddress = address"SysvarRent111111111111111111111111111111111";
-
+    
 	// Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/token-metadata/program/src/instruction/metadata.rs#L31
 	struct CreateMetadataAccountArgsV3 {
         DataV2 data;
@@ -76,7 +74,9 @@ library MplMetadata {
 		address updateAuthority,
 		string name,
 		string symbol,
-		string uri
+		string uri,
+        address metadataProgramId,
+        address rentAddress
 	) public {
         // // Example of how to add a Creator[] array to the DataV2 struct
 		// Creator[] memory creators = new Creator[](1);

+ 1 - 1
tokens/create-token/solang/libraries/spl_token.sol

@@ -1,5 +1,5 @@
 import 'solana';
-import 'system_instruction.sol';
+import './system_instruction.sol';
 
 library SplToken {
 	address constant tokenProgramId = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";

+ 18 - 14
tokens/create-token/solang/solidity/create-token.sol

@@ -10,38 +10,42 @@ contract create_token {
     @payer(payer) // payer account
     constructor() {}
 
+    @mutableSigner(payer) // payer account
+    @mutableSigner(mint) // mint account to be created
+    @mutableAccount(metadata) // metadata account to be created
+    @signer(mintAuthority) // mint authority for the mint account
+    @account(rentAddress)
+    @account(metadataProgramId)
     function createTokenMint(
-        address payer, // payer account
-        address mint, // mint account to be created
-        address mintAuthority, // mint authority for the mint account
         address freezeAuthority, // freeze authority for the mint account
-        address metadata, // metadata account to be created
         uint8 decimals, // decimals for the mint account
         string name, // name for the metadata account
         string symbol, // symbol for the metadata account
         string uri // uri for the metadata account
-    ) public {
+    ) external {
         // Invoke System Program to create a new account for the mint account and,
         // Invoke Token Program to initialize the mint account
         // Set mint authority, freeze authority, and decimals for the mint account
         SplToken.create_mint(
-            payer,            // payer account
-            mint,            // mint account
-            mintAuthority,   // mint authority
+            tx.accounts.payer.key,            // payer account
+            tx.accounts.mint.key,            // mint account
+            tx.accounts.mintAuthority.key,   // mint authority
             freezeAuthority, // freeze authority
             decimals         // decimals
         );
 
         // Invoke Metadata Program to create a new account for the metadata account
         MplMetadata.create_metadata_account(
-            metadata, // metadata account
-            mint,  // mint account
-            mintAuthority, // mint authority
-            payer, // payer
-            payer, // update authority (of the metadata account)
+            tx.accounts.metadata.key, // metadata account
+            tx.accounts.mint.key,  // mint account
+            tx.accounts.mintAuthority.key, // mint authority
+            tx.accounts.payer.key, // payer
+            tx.accounts.payer.key, // update authority (of the metadata account)
             name, // name
             symbol, // symbol
-            uri // uri (off-chain metadata json)
+            uri, // uri (off-chain metadata json)
+            tx.accounts.metadataProgramId.key,
+            tx.accounts.rentAddress.key
         );
     }
 }

+ 16 - 42
tokens/create-token/solang/tests/create-token.ts

@@ -43,33 +43,20 @@ describe("create-token", () => {
 
     const tx = await program.methods
       .createTokenMint(
-        wallet.publicKey, // payer
-        mintKeypair.publicKey, // mint
         wallet.publicKey, // freeze authority
-        wallet.publicKey, // mint authority
-        metadataAddress, // metadata address
         9, // decimals for the mint
         tokenTitle, // token name
         tokenSymbol, // token symbol
         tokenUri // token uri (off-chain metadata)
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: true },
-        {
-          pubkey: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), // Metadata program id
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: metadataAddress, isWritable: true, isSigner: false },
-        { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
-        { pubkey: SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
-      ])
+      .accounts({ 
+        payer: wallet.publicKey, //payer
+        mint: mintKeypair.publicKey, // mint
+        metadata: metadataAddress, // metadata address
+        mintAuthority: wallet.publicKey, // mint authority
+        rentAddress: SYSVAR_RENT_PUBKEY,
+        metadataProgramId: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
+      })
       .signers([mintKeypair])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
@@ -89,32 +76,19 @@ describe("create-token", () => {
     const tx = await program.methods
       .createTokenMint(
         wallet.publicKey,
-        mintKeypair.publicKey,
-        wallet.publicKey,
-        wallet.publicKey,
-        metadataAddress,
         0, // decimals for the mint, 0 for NFTs "non-fungible"
         tokenTitle,
         tokenSymbol,
         tokenUri
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: true },
-        {
-          pubkey: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), // Metadata program id
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: metadataAddress, isWritable: true, isSigner: false },
-        { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
-        { pubkey: SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
-      ])
+      .accounts({ 
+        payer: wallet.publicKey, //payer
+        mint: mintKeypair.publicKey, // mint
+        metadata: metadataAddress, // metadata address
+        mintAuthority: wallet.publicKey, // mint authority
+        rentAddress: SYSVAR_RENT_PUBKEY,
+        metadataProgramId: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
+      })
       .signers([mintKeypair])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);

+ 3 - 3
tokens/nft-minter/solang/libraries/mpl_metadata.sol

@@ -6,9 +6,7 @@ import 'solana';
 // If bool for Option<> type is false, comment out the corresponding struct field otherwise instruction fails with "invalid account data"
 // TODO: figure out better way to handle Option<> types
 library MplMetadata {
-	address constant metadataProgramId = address"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
 	address constant systemAddress = address"11111111111111111111111111111111";
-    address constant rentAddress = address"SysvarRent111111111111111111111111111111111";
 
 	// Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/token-metadata/program/src/instruction/metadata.rs#L31
 	struct CreateMetadataAccountArgsV3 {
@@ -76,7 +74,9 @@ library MplMetadata {
 		address updateAuthority,
 		string name,
 		string symbol,
-		string uri
+		string uri,
+        address metadataProgramId,
+        address rentAddress
 	) public {
         // // Example of how to add a Creator[] array to the DataV2 struct
 		// Creator[] memory creators = new Creator[](1);

+ 1 - 1
tokens/nft-minter/solang/libraries/spl_token.sol

@@ -1,5 +1,5 @@
 import 'solana';
-import 'system_instruction.sol';
+import './system_instruction.sol';
 
 library SplToken {
 	address constant tokenProgramId = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";

+ 32 - 24
tokens/nft-minter/solang/solidity/nft-minter.sol

@@ -8,62 +8,70 @@ contract nft_minter {
     @payer(payer)
     constructor() {}
 
+    @mutableSigner(payer) // payer account
+    @mutableSigner(mint) // mint account to be created
+    @mutableAccount(metadata) // metadata account to be created
+    @signer(mintAuthority) // mint authority for the mint account
+    @account(metadataProgramId)
+    @account(rentAddress)
     function createTokenMint(
-        address payer, // payer account
-        address mint, // mint account to be created
-        address mintAuthority, // mint authority for the mint account
         address freezeAuthority, // freeze authority for the mint account
-        address metadata, // metadata account to be created
         uint8 decimals, // decimals for the mint account
         string name, // name for the metadata account
         string symbol, // symbol for the metadata account
         string uri // uri for the metadata account
-    ) public {
+    ) external {
         // Invoke System Program to create a new account for the mint account and,
         // Invoke Token Program to initialize the mint account
         // Set mint authority, freeze authority, and decimals for the mint account
         SplToken.create_mint(
-            payer,            // payer account
-            mint,            // mint account
-            mintAuthority,   // mint authority
+            tx.accounts.payer.key,            // payer account
+            tx.accounts.mint.key,            // mint account
+            tx.accounts.mintAuthority.key,   // mint authority
             freezeAuthority, // freeze authority
             decimals         // decimals
         );
 
         // Invoke Metadata Program to create a new account for the metadata account
         MplMetadata.create_metadata_account(
-            metadata, // metadata account
-            mint,  // mint account
-            mintAuthority, // mint authority
-            payer, // payer
-            payer, // update authority (of the metadata account)
+            tx.accounts.metadata.key, // metadata account
+            tx.accounts.mint.key,  // mint account
+            tx.accounts.mintAuthority.key, // mint authority
+            tx.accounts.payer.key, // payer
+            tx.accounts.payer.key, // update authority (of the metadata account)
             name, // name
             symbol, // symbol
-            uri // uri (off-chain metadata json)
+            uri, // uri (off-chain metadata json)
+            tx.accounts.metadataProgramId.key,
+            tx.accounts.rentAddress.key
         );
     }
 
-    function mintTo(address payer, address tokenAccount, address mint, address owner) public {
+    @mutableSigner(payer)
+    @mutableAccount(tokenAccount)
+    @account(owner)
+    @mutableAccount(mint)
+    function mintTo() external {
         // Create an associated token account for the owner to receive the minted token
         SplToken.create_associated_token_account(
-            payer, // payer account
-            tokenAccount, // associated token account address
-            mint, // mint account
-            owner // owner account
+            tx.accounts.payer.key, // payer account
+            tx.accounts.tokenAccount.key, // associated token account address
+            tx.accounts.mint.key, // mint account
+            tx.accounts.owner.key // owner account
         );
 
         // Mint 1 token to the associated token account
         SplToken.mint_to(
-            mint, // mint account
-            tokenAccount, // token account
-            payer, // mint authority
+            tx.accounts.mint.key, // mint account
+            tx.accounts.tokenAccount.key, // token account
+            tx.accounts.payer.key, // mint authority
             1 // amount
         );
 
         // Remove mint authority from mint account
         SplToken.remove_mint_authority(
-            mint, // mint
-            payer // mint authority
+            tx.accounts.mint.key, // mint
+            tx.accounts.payer.key // mint authority
         );
     }
 }

+ 15 - 48
tokens/nft-minter/solang/tests/nft-minter.ts

@@ -50,33 +50,20 @@ describe("nft-minter", () => {
 
     const tx = await program.methods
       .createTokenMint(
-        wallet.publicKey, // payer
-        mintKeypair.publicKey, // mint
-        wallet.publicKey, // mint authority
         wallet.publicKey, // freeze authority
-        metadataAddress, // metadata address
         0, // 0 decimals for NFT
         nftTitle, // NFT name
         nftSymbol, // NFT symbol
         nftUri // NFT URI
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: true },
-        {
-          pubkey: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), // Metadata program id
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: metadataAddress, isWritable: true, isSigner: false },
-        { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
-        { pubkey: SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
-      ])
+      .accounts({ 
+        payer: wallet.publicKey,
+        mint: mintKeypair.publicKey,
+        metadata: metadataAddress,
+        mintAuthority: wallet.publicKey,
+        metadataProgramId: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
+        rentAddress: SYSVAR_RENT_PUBKEY,
+      })
       .signers([mintKeypair])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
@@ -90,33 +77,13 @@ describe("nft-minter", () => {
     );
 
     const tx = await program.methods
-      .mintTo(
-        wallet.publicKey, // payer
-        tokenAccount, // associated token account address
-        mintKeypair.publicKey, // mint
-        wallet.publicKey // owner of token account
-      )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: tokenAccount, isWritable: true, isSigner: false },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: false },
-        {
-          pubkey: SystemProgram.programId,
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
-        {
-          pubkey: ASSOCIATED_TOKEN_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .mintTo()
+      .accounts({ 
+        payer: wallet.publicKey, // payer
+        tokenAccount: tokenAccount, // associated token account address
+        mint: mintKeypair.publicKey, // mint
+        owner: wallet.publicKey, // owner of token account
+       })
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
   });

+ 1 - 1
tokens/pda-mint-authority/solang/libraries/spl_token.sol

@@ -1,5 +1,5 @@
 import 'solana';
-import 'system_instruction.sol';
+import './system_instruction.sol';
 
 library SplToken {
 	address constant tokenProgramId = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";

+ 49 - 35
tokens/pda-mint-authority/solang/solidity/pda-mint-authority.sol

@@ -21,38 +21,43 @@ contract pda_mint_authority {
         bump = _bump;
     }
 
-   function createTokenMint(
-        address payer, // payer account
-        address mint, // mint account to be created
-        address mintAuthority, // mint authority for the mint account
+
+    @mutableSigner(payer) // payer account
+    @mutableSigner(mint) // mint account to be created
+    @mutableAccount(metadata) // metadata account to be created
+    @account(mintAuthority) // mint authority for the mint account
+    @account(rentAddress)
+    @account(metaplexId)
+    function createTokenMint(
         address freezeAuthority, // freeze authority for the mint account
-        address metadata, // metadata account to be created
         uint8 decimals, // decimals for the mint account
         string name, // name for the metadata account
         string symbol, // symbol for the metadata account
         string uri // uri for the metadata account
-    ) public {
+    ) external {
         // Invoke System Program to create a new account for the mint account and,
         // Invoke Token Program to initialize the mint account
         // Set mint authority, freeze authority, and decimals for the mint account
         SplToken.create_mint(
-            payer,            // payer account
-            mint,            // mint account
-            mintAuthority,   // mint authority
-            freezeAuthority, // freeze authority
-            decimals         // decimals
+            tx.accounts.payer.key,           // payer account
+            tx.accounts.mint.key,            // mint account
+            tx.accounts.mintAuthority.key,   // mint authority
+            freezeAuthority,                 // freeze authority
+            decimals                         // decimals
         );
 
         // Invoke Metadata Program to create a new account for the metadata account
         _createMetadataAccount(
-            metadata, // metadata account
-            mint,  // mint account
-            mintAuthority, // mint authority
-            payer, // payer
-            payer, // update authority (of the metadata account)
+            tx.accounts.metadata.key,       // metadata account
+            tx.accounts.mint.key,           // mint account
+            tx.accounts.mintAuthority.key,  // mint authority
+            tx.accounts.payer.key,          // payer
+            tx.accounts.payer.key,          // update authority (of the metadata account)
             name, // name
             symbol, // symbol
-            uri // uri (off-chain metadata json)
+            uri, // uri (off-chain metadata json)
+            tx.accounts.rentAddress.key,
+            tx.accounts.metaplexId.key
         );
     }
 
@@ -65,12 +70,14 @@ contract pda_mint_authority {
 		address updateAuthority, // update authority for the metadata account
 		string name, // token name
 		string symbol, // token symbol
-		string uri // token uri
+		string uri, // token uri
+        address rentAddress,
+        address metaplexId
     ) private {
         // // Independently derive the PDA address from the seeds, bump, and programId
         (address pda, bytes1 _bump) = try_find_program_address(["mint_authority"], type(pda_mint_authority).program_id);
 
-        require(address(this) == pda, 'INVALID_PDA');
+        require(mintAuthority == pda, 'INVALID_PDA');
 
         DataV2 data = DataV2({
             name: name,
@@ -95,13 +102,13 @@ contract pda_mint_authority {
             AccountMeta({pubkey: payer, is_writable: true, is_signer: true}),
             AccountMeta({pubkey: updateAuthority, is_writable: false, is_signer: false}),
             AccountMeta({pubkey: address"11111111111111111111111111111111", is_writable: false, is_signer: false}),
-            AccountMeta({pubkey: address"SysvarRent111111111111111111111111111111111", is_writable: false, is_signer: false})
+            AccountMeta({pubkey: rentAddress, is_writable: false, is_signer: false})
         ];
 
         bytes1 discriminator = 33;
         bytes instructionData = abi.encode(discriminator, args);
 
-        address"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s".call{accounts: metas, seeds: [["mint_authority", abi.encode(_bump)]]}(instructionData);
+        metaplexId.call{accounts: metas, seeds: [["mint_authority", abi.encode(_bump)]]}(instructionData);
     }
 
     struct CreateMetadataAccountArgsV3 {
@@ -120,33 +127,40 @@ contract pda_mint_authority {
         bool usesPresent; // To handle Rust Option<> in Solidity
     }
 
-    function mintTo(address payer, address tokenAccount, address mint, address owner) public {
+    @mutableSigner(payer)
+    @mutableAccount(tokenAccount)
+    @account(owner)
+    @mutableAccount(mint)
+    @mutableAccount(pdaAccount)
+    function mintTo() external {
         // Create an associated token account for the owner to receive the minted token
         SplToken.create_associated_token_account(
-            payer, // payer account
-            tokenAccount, // associated token account address
-            mint, // mint account
-            owner // owner account
+            tx.accounts.payer.key, // payer account
+            tx.accounts.tokenAccount.key, // associated token account address
+            tx.accounts.mint.key, // mint account
+            tx.accounts.owner.key // owner account
         );
 
         // Mint 1 token to the associated token account
         _mintTo(
-            mint, // mint account
-            tokenAccount, // token account
-            1 // amount
+            tx.accounts.mint.key, // mint account
+            tx.accounts.tokenAccount.key, // token account
+            1, // amount
+            tx.accounts.pdaAccount.key
         );
 
-        // Remove mint authority from mint account
+        // // Remove mint authority from mint account
         _removeMintAuthority(
-            mint // mint
+            tx.accounts.mint.key, // mint
+            tx.accounts.pdaAccount.key
         );
     }
 
     // Invoke the token program to mint tokens to a token account, using a PDA as the mint authority
-    function _mintTo(address mint, address account, uint64 amount) private {
+    function _mintTo(address mint, address account, uint64 amount, address pdaAccount) private {
         // Independently derive the PDA address from the seeds, bump, and programId
         (address pda, bytes1 _bump) = try_find_program_address(["mint_authority"], type(pda_mint_authority).program_id);
-        require(address(this) == pda, 'INVALID_PDA');
+        require(pdaAccount == pda, 'INVALID_PDA');
 
         // Prepare instruction data
         bytes instructionData = new bytes(9);
@@ -164,10 +178,10 @@ contract pda_mint_authority {
         SplToken.tokenProgramId.call{accounts: metas, seeds: [["mint_authority", abi.encode(_bump)]]}(instructionData);
     }
 
-    function _removeMintAuthority(address mintAccount) private {
+    function _removeMintAuthority(address mintAccount, address pdaAccount) private {
         // Independently derive the PDA address from the seeds, bump, and programId
         (address pda, bytes1 _bump) = try_find_program_address(["mint_authority"], type(pda_mint_authority).program_id);
-        require(address(this) == pda, 'INVALID_PDA');
+        require(pdaAccount == pda, 'INVALID_PDA');
 
 		AccountMeta[2] metas = [
 			AccountMeta({pubkey: mintAccount, is_signer: false, is_writable: true}),

+ 16 - 49
tokens/pda-mint-authority/solang/tests/pda-mint-authority.ts

@@ -51,33 +51,20 @@ describe("pda-mint-authority", () => {
     // Add your test here.
     const tx = await program.methods
       .createTokenMint(
-        wallet.publicKey, // payer
-        mintKeypair.publicKey, // mint
-        dataAccountPDA, // mint authority
         dataAccountPDA, // freeze authority
-        metadataAddress, // metadata address
         0, // 0 decimals for NFT
         nftTitle, // NFT name
         nftSymbol, // NFT symbol
         nftUri // NFT URI
       )
-      .accounts({ dataAccount: dataAccountPDA })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: true },
-        {
-          pubkey: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: metadataAddress, isWritable: true, isSigner: false },
-        { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
-        { pubkey: SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
-      ])
+      .accounts({ 
+        payer: wallet.publicKey,
+        mint: mintKeypair.publicKey,
+        metadata: metadataAddress,
+        mintAuthority: dataAccountPDA,
+        rentAddress: SYSVAR_RENT_PUBKEY,
+        metaplexId: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
+      })
       .signers([mintKeypair])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
@@ -91,34 +78,14 @@ describe("pda-mint-authority", () => {
     );
 
     const tx = await program.methods
-      .mintTo(
-        wallet.publicKey, // payer
-        tokenAccount, // associated token account address
-        mintKeypair.publicKey, // mint
-        wallet.publicKey // owner of token account
-      )
-      .accounts({ dataAccount: dataAccountPDA })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: false },
-        { pubkey: tokenAccount, isWritable: true, isSigner: false },
-        { pubkey: dataAccountPDA, isWritable: true, isSigner: false },
-        {
-          pubkey: SystemProgram.programId,
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
-        {
-          pubkey: ASSOCIATED_TOKEN_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .mintTo()
+      .accounts({ 
+        pdaAccount: dataAccountPDA,
+        payer: wallet.publicKey,
+        tokenAccount: tokenAccount,
+        owner: wallet.publicKey,
+        mint: mintKeypair.publicKey
+     })
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
   });

+ 3 - 3
tokens/spl-token-minter/solang/libraries/mpl_metadata.sol

@@ -6,9 +6,7 @@ import 'solana';
 // If bool for Option<> type is false, comment out the corresponding struct field otherwise instruction fails with "invalid account data"
 // TODO: figure out better way to handle Option<> types
 library MplMetadata {
-	address constant metadataProgramId = address"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
 	address constant systemAddress = address"11111111111111111111111111111111";
-    address constant rentAddress = address"SysvarRent111111111111111111111111111111111";
 
 	// Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/token-metadata/program/src/instruction/metadata.rs#L31
 	struct CreateMetadataAccountArgsV3 {
@@ -76,7 +74,9 @@ library MplMetadata {
 		address updateAuthority,
 		string name,
 		string symbol,
-		string uri
+		string uri,
+        address rentAddress,
+        address metadataProgramId
 	) public {
         // // Example of how to add a Creator[] array to the DataV2 struct
 		// Creator[] memory creators = new Creator[](1);

+ 1 - 1
tokens/spl-token-minter/solang/libraries/spl_token.sol

@@ -1,5 +1,5 @@
 import 'solana';
-import 'system_instruction.sol';
+import './system_instruction.sol';
 
 library SplToken {
 	address constant tokenProgramId = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";

+ 25 - 18
tokens/spl-token-minter/solang/solidity/spl-token-minter.sol

@@ -7,47 +7,54 @@ contract spl_token_minter {
     @payer(payer)
     constructor() {}
 
+    @mutableSigner(payer) // payer account
+    @mutableSigner(mint) // mint account to be created
+    @mutableAccount(metadata) // metadata account to be created
+    @signer(mintAuthority) // mint authority for the mint account
+    @account(rentAddress)
+    @account(metadataProgramId)
     function createTokenMint(
-        address payer, // payer account
-        address mint, // mint account to be created
-        address mintAuthority, // mint authority for the mint account
         address freezeAuthority, // freeze authority for the mint account
-        address metadata, // metadata account to be created
         uint8 decimals, // decimals for the mint account
         string name, // name for the metadata account
         string symbol, // symbol for the metadata account
         string uri // uri for the metadata account
-    ) public {
+    ) external {
         // Invoke System Program to create a new account for the mint account and,
         // Invoke Token Program to initialize the mint account
         // Set mint authority, freeze authority, and decimals for the mint account
         SplToken.create_mint(
-            payer,            // payer account
-            mint,            // mint account
-            mintAuthority,   // mint authority
+            tx.accounts.payer.key,            // payer account
+            tx.accounts.mint.key,            // mint account
+            tx.accounts.mintAuthority.key,   // mint authority
             freezeAuthority, // freeze authority
             decimals         // decimals
         );
 
         // Invoke Metadata Program to create a new account for the metadata account
         MplMetadata.create_metadata_account(
-            metadata, // metadata account
-            mint,  // mint account
-            mintAuthority, // mint authority
-            payer, // payer
-            payer, // update authority (of the metadata account)
+            tx.accounts.metadata.key, // metadata account
+            tx.accounts.mint.key,  // mint account
+            tx.accounts.mintAuthority.key, // mint authority
+            tx.accounts.payer.key, // payer
+            tx.accounts.payer.key, // update authority (of the metadata account)
             name, // name
             symbol, // symbol
-            uri // uri (off-chain metadata json)
+            uri, // uri (off-chain metadata json)
+            tx.accounts.rentAddress.key,
+            tx.accounts.metadataProgramId.key
         );
     }
 
-    function mintTo(address mintAuthority, address tokenAccount, address mint, uint64 amount) public {
+    @mutableAccount(mint)
+    @mutableAccount(tokenAccount)
+    @mutableSigner(mintAuthority)
+    function mintTo(uint64 amount) external {
         // Mint tokens to the token account
         SplToken.mint_to(
-            mint, // mint account
-            tokenAccount, // token account
-            mintAuthority, // mint authority
+            tx.accounts.mint.key, // mint account
+            tx.accounts.tokenAccount.key, // token account
+            tx.accounts.mintAuthority.key, // mint authority
             amount // amount
         );
     }

+ 13 - 45
tokens/spl-token-minter/solang/tests/spl-token-minter.ts

@@ -50,33 +50,20 @@ describe("spl-token-minter", () => {
     // Create the token mint
     const tx = await program.methods
       .createTokenMint(
-        wallet.publicKey, // payer
-        mintKeypair.publicKey, // mint
-        wallet.publicKey, // mint authority
         wallet.publicKey, // freeze authority
-        metadataAddress, // metadata address
         9, // decimals
         tokenTitle, // token name
         tokenSymbol, // token symbol
         tokenUri // token uri
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: true },
-        {
-          pubkey: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), // Metadata program id
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: metadataAddress, isWritable: true, isSigner: false },
-        { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
-        { pubkey: SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
-      ])
+      .accounts({ 
+        payer: wallet.publicKey,
+        mint: mintKeypair.publicKey,
+        metadata: metadataAddress,
+        mintAuthority: wallet.publicKey,
+        rentAddress: SYSVAR_RENT_PUBKEY,
+        metadataProgramId: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
+       })
       .signers([mintKeypair])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
@@ -93,32 +80,13 @@ describe("spl-token-minter", () => {
 
     const tx = await program.methods
       .mintTo(
-        wallet.publicKey, // payer
-        tokenAccount.address, // associated token account address
-        mintKeypair.publicKey, // mint
         new anchor.BN(150) // amount to mint
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: tokenAccount.address, isWritable: true, isSigner: false },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: false },
-        {
-          pubkey: SystemProgram.programId,
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
-        {
-          pubkey: ASSOCIATED_TOKEN_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .accounts({ 
+        mintAuthority: wallet.publicKey,
+        tokenAccount: tokenAccount.address,
+        mint: mintKeypair.publicKey,
+       })
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
   });

+ 3 - 3
tokens/transfer-tokens/solang/libraries/mpl_metadata.sol

@@ -6,9 +6,7 @@ import 'solana';
 // If bool for Option<> type is false, comment out the corresponding struct field otherwise instruction fails with "invalid account data"
 // TODO: figure out better way to handle Option<> types
 library MplMetadata {
-	address constant metadataProgramId = address"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
 	address constant systemAddress = address"11111111111111111111111111111111";
-    address constant rentAddress = address"SysvarRent111111111111111111111111111111111";
 
 	// Reference: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/token-metadata/program/src/instruction/metadata.rs#L31
 	struct CreateMetadataAccountArgsV3 {
@@ -76,7 +74,9 @@ library MplMetadata {
 		address updateAuthority,
 		string name,
 		string symbol,
-		string uri
+		string uri,
+        address rentAddress,
+        address metadataProgramId
 	) public {
         // // Example of how to add a Creator[] array to the DataV2 struct
 		// Creator[] memory creators = new Creator[](1);

+ 1 - 1
tokens/transfer-tokens/solang/libraries/spl_token.sol

@@ -1,5 +1,5 @@
 import 'solana';
-import 'system_instruction.sol';
+import './system_instruction.sol';
 
 library SplToken {
 	address constant tokenProgramId = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";

+ 36 - 30
tokens/transfer-tokens/solang/solidity/transfer-tokens.sol

@@ -8,64 +8,70 @@ contract transfer_tokens {
     @payer(payer)
     constructor() {}
 
+    @mutableSigner(payer) // payer account
+    @mutableSigner(mint) // mint account to be created
+    @mutableAccount(metadata) // metadata account to be created
+    @signer(mintAuthority) // mint authority for the mint account
+    @account(rentAddress)
+    @account(metadataProgramId)
     function createTokenMint(
-        address payer, // payer account
-        address mint, // mint account to be created
-        address mintAuthority, // mint authority for the mint account
         address freezeAuthority, // freeze authority for the mint account
-        address metadata, // metadata account to be created
         uint8 decimals, // decimals for the mint account
         string name, // name for the metadata account
         string symbol, // symbol for the metadata account
         string uri // uri for the metadata account
-    ) public {
+    ) external {
         // Invoke System Program to create a new account for the mint account and,
         // Invoke Token Program to initialize the mint account
         // Set mint authority, freeze authority, and decimals for the mint account
         SplToken.create_mint(
-            payer,            // payer account
-            mint,            // mint account
-            mintAuthority,   // mint authority
+            tx.accounts.payer.key,            // payer account
+            tx.accounts.mint.key,            // mint account
+            tx.accounts.mintAuthority.key,   // mint authority
             freezeAuthority, // freeze authority
             decimals         // decimals
         );
 
         // Invoke Metadata Program to create a new account for the metadata account
         MplMetadata.create_metadata_account(
-            metadata, // metadata account
-            mint,  // mint account
-            mintAuthority, // mint authority
-            payer, // payer
-            payer, // update authority (of the metadata account)
+            tx.accounts.metadata.key, // metadata account
+            tx.accounts.mint.key,  // mint account
+            tx.accounts.mintAuthority.key, // mint authority
+            tx.accounts.payer.key, // payer
+            tx.accounts.payer.key, // update authority (of the metadata account)
             name, // name
             symbol, // symbol
-            uri // uri (off-chain metadata json)
+            uri, // uri (off-chain metadata json)
+            tx.accounts.rentAddress.key,
+            tx.accounts.metadataProgramId.key
         );
     }
 
-    function mintTo(
-        address payer, // payer account
-        address tokenAccount, // token account to create and receive the minted token
-        address mint, // mint account
-        address owner, // token account owner
-        uint64 amount // amount to mint
-    ) public {
-        // Mint token to the token account
+    @mutableAccount(mint)
+    @mutableAccount(tokenAccount)
+    @mutableSigner(mintAuthority)
+    function mintTo(uint64 amount) external {
+        // Mint tokens to the token account
         SplToken.mint_to(
-            mint, // mint account
-            tokenAccount, // token account
-            payer, // mint authority
+            tx.accounts.mint.key, // mint account
+            tx.accounts.tokenAccount.key, // token account
+            tx.accounts.mintAuthority.key, // mint authority
             amount // amount
         );
     }
 
     // Transfer tokens from one token account to another via Cross Program Invocation to Token Program
+    @mutableAccount(from) // token account to transfer from
+    @mutableAccount(to) // token account to transfer to
+    @signer(owner)
     function transferTokens(
-        address from, // token account to transfer from
-        address to, // token account to transfer to
         uint64 amount // amount to transfer
-    ) public {
-        SplToken.TokenAccountData from_data = SplToken.get_token_account_data(from);
-        SplToken.transfer(from, to, from_data.owner, amount);
+    ) external {
+        SplToken.transfer(
+            tx.accounts.from.key, 
+            tx.accounts.to.key, 
+            tx.accounts.owner.key, 
+            amount
+        );
     }
 }

+ 18 - 71
tokens/transfer-tokens/solang/tests/transfer-tokens.ts

@@ -47,33 +47,20 @@ describe("Transfer Tokens", () => {
     // Add your test here.
     const tx = await program.methods
       .createTokenMint(
-        wallet.publicKey, // payer
-        mintKeypair.publicKey, // mint
-        wallet.publicKey, // mint authority
         wallet.publicKey, // freeze authority
-        metadataAddress, // metadata address
         9, // 0 decimals for NFT
         nftTitle, // NFT name
         nftSymbol, // NFT symbol
         nftUri // NFT URI
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: true },
-        {
-          pubkey: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: metadataAddress, isWritable: true, isSigner: false },
-        { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
-        { pubkey: SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
-      ])
+      .accounts({ 
+        payer: wallet.publicKey,
+        mint: mintKeypair.publicKey,
+        metadata: metadataAddress,
+        mintAuthority: wallet.publicKey,
+        rentAddress: SYSVAR_RENT_PUBKEY,
+        metadataProgramId: new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
+       })
       .signers([mintKeypair])
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
@@ -90,33 +77,13 @@ describe("Transfer Tokens", () => {
 
     const tx = await program.methods
       .mintTo(
-        wallet.publicKey, // payer
-        tokenAccount.address, // associated token account address
-        mintKeypair.publicKey, // mint
-        wallet.publicKey, // owner of token account
         new anchor.BN(150) // amount to mint
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        { pubkey: tokenAccount.address, isWritable: true, isSigner: false },
-        { pubkey: mintKeypair.publicKey, isWritable: true, isSigner: false },
-        {
-          pubkey: SystemProgram.programId,
-          isWritable: false,
-          isSigner: false,
-        },
-        { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
-        {
-          pubkey: ASSOCIATED_TOKEN_PROGRAM_ID,
-          isWritable: false,
-          isSigner: false,
-        },
-      ])
+      .accounts({ 
+        mintAuthority: wallet.publicKey,
+        tokenAccount: tokenAccount.address,
+        mint: mintKeypair.publicKey,
+       })
       .rpc({ skipPreflight: true });
     console.log("Your transaction signature", tx);
   });
@@ -140,33 +107,13 @@ describe("Transfer Tokens", () => {
 
     const tx = await program.methods
       .transferTokens(
-        tokenAccount.address,
-        receipientTokenAccount.address,
         new anchor.BN(150)
       )
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .remainingAccounts([
-        {
-          pubkey: wallet.publicKey,
-          isWritable: true,
-          isSigner: true,
-        },
-        {
-          pubkey: mintKeypair.publicKey,
-          isWritable: false,
-          isSigner: false,
-        },
-        {
-          pubkey: tokenAccount.address,
-          isWritable: true,
-          isSigner: false,
-        },
-        {
-          pubkey: receipientTokenAccount.address,
-          isWritable: true,
-          isSigner: false,
-        },
-      ])
+      .accounts({ 
+        from: tokenAccount.address,
+        to: receipientTokenAccount.address,
+        owner: wallet.publicKey,
+       })
       .rpc();
     console.log("Your transaction signature", tx);
   });