Mokshya Documentation

website·Indexed 30 days ago

https://mokshya-docs-7r96.vercel.app/

An open-source protocol providing smart contracts and SDKs for the Aptos Blockchain. Documentation covers the implementation and operation of Candy Machine for NFT minting, token staking with reward claims, and token vesting operations.

Tokens
3.8K
Snippets
25
Records
29
Agent score
75%

What's inside Mokshya

  1. Overview of Mokshya Protocol for Aptos

    Mokshya is an open-source protocol that develops smart contracts and Software Development Kits (SDKs) specifically for the Aptos blockchain. The project aims to lower the barrier to entry for web3 developers by providing reliable, well-documented infrastructure for decentralized applications.
  2. Stop staking for a collection

    The NFT collection creator can disable the staking feature for a specific collection using the creator_stop_staking function. This requires the collection_name as an argument.
    const stop_staking_payloads = {
      type: "entry_function_payload",
      function: mokshyastaking + "::tokenstaking::creator_stop_staking", // use account address for mokshyastaking
      type_arguments: [],
      arguments: [collection_name],
    };
    
    let txnRequest = await client.generateTransaction(
      creator.address(),
      stop_staking_payloads
    );
    let bcsTxn = AptosClient.generateBCSTransaction(creator, txnRequest);
    await client.submitSignedBCSTransaction(bcsTxn);
  3. Create a new staking pool

    To initialize staking for an NFT collection, the collection creator must call the create_staking function. This requires specifying the Daily Percentage Return (DPR), the collection name, and the total amount deposited. The creator can specify any coin type to be used for distribution.
    const create_staking_payloads = {
      type: "entry_function_payload",
      function: mokshyastaking + "::tokenstaking::create_staking", // use account address for mokshyastaking
      type_arguments: ["0x1::aptos_coin::AptosCoin"], // Coin Type
      arguments: [DPR, collection_name, total_amount_deposited],
    };
    
    let txnRequest = await client.generateTransaction(
      creator.address(),
      create_staking_payloads
    );
    let bcsTxn = AptosClient.generateBCSTransaction(creator, txnRequest);
    await client.submitSignedBCSTransaction(bcsTxn);
  4. Deploy the Candy Machine Smart Contract

    Deploy the Candy Machine smart contract by first initializing an Aptos account and then publishing the contract using the aptos move publish command. You must map the candymachine named address to your specific Aptos account address.
    # Initialize your Aptos account
    aptos init
    
    # Publish the smart contract
    # Replace <your_account_address> with the address generated from aptos init
    aptos move publish --named-addresses candymachine=<your_account_address>
  5. Create an on-chain whitelist for Candy Machine

    To store whitelisted addresses on-chain, add the list of user addresses to the whitelist parameter within the config.json file. The CLI will then send multiple transactions to register these users on-chain.
    ts-node packages/CLI/src/index.ts --create_whitelist
  6. Initialize the Candy Machine smart contract

    To set up the candy machine and provide minting information to the smart contract, use the CLI tool. Before running the initialization command, ensure the following prerequisites are met:

    1. Metadata Verification: Confirm your metadata has a manifest file and that individual JSON files are accessible by appending numbers to the URL (e.g., yourdomain.com/manifest/0.json).
    2. Gas Fees: Ensure your account has sufficient gas fees to cover the initialization transaction.
    3. Configuration: The config.json file must be fully populated, with the exception of the resource_account parameter.
    4. Environment: You must be located in the aptos-candymachine directory and have all required modules installed.
    ts-node packages/CLI/src/index.ts --create_candy
  7. Run integration tests for the Vesting smart contract

    Integration tests for the vesting smart contract are located in the tests/vesting.ts directory. To run these tests, ensure dependencies are installed and the program ID in tests/vesting.ts is updated to match your current deployment.
    # Install dependencies
    npm install
    
    # Run the tests
    yarn test
  8. Organize NFT assets for Candy Machine

    To prepare an NFT collection, create an Assets folder containing two subdirectories: images and metadata. Ensure that the image files and their corresponding JSON metadata files share the same index number (e.g., 0.png corresponds to 0.json).
    Assets/
    ├── images/
    │   ├── 0.png
    │   ├── 1.png
    │   └── ...
    └── metadata/
        ├── 0.json
        ├── 1.json
        └── ...