• Discover
  • Partner with us
  • Chapters
  • Blog

Learn everything about Aptos

Course Introduction

Web1 and Web2
The Middleman
Blockchain Comes Into Play
Web3 As a New Iteration for Web
How Smart Contracts Work

What is Aptos?
Features and Advantages of Aptos
Remix Ide Plugin Setups
Move Walkthrough Part-1
Move Walkthrough Part-2

Local Environment Setup
Smart Contract Demonstration Part-1
Smart Contract Demonstration Part-2
Deploying Smart Contract to the Aptos
The Vault Contract Explanation
Submit Your Homework
Bonus: Token Standard in Aptos

Submit Your Final Project

In this homework you will modify the Aptos Vault smart contract to improve efficiency by directly using the vault address instead of deriving it from the admin address. Then, deploy and test the modified contract.

Part 1: Code Modification

Current Implementation

In the current contract, many functions take admin_address as a parameter and use get_vault_address to retrieve the vault's address:

move

public fun get_vault_address(admin_address: address): address acquires VaultSignerCapability {

    let vault_signer_cap = &borrow_global<VaultSignerCapability>(admin_address).cap;

    account::get_signer_capability_address(vault_signer_cap)

}

public entry fun deposit_tokens(admin: &signer, amount: u64) acquires Vault, VaultSignerCapability {

    let admin_address = signer::address_of(admin);

    let vault_address = get_vault_address(admin_address);

    // ... rest of the function

}

Task

Modify the contract to directly use vault_address as a parameter instead of admin_address. This change should be applied to all relevant functions.

Steps

1. Remove the get_vault_address function.

2. Update the function signatures to use vault_address instead of admin_address.

3. Remove any calls to get_vault_address within the functions.

4. Update any assertions that check the admin address to use the admin field from the Vault struct.

Example of Modified Function

move

public entry fun deposit_tokens(admin: &signer, vault_address: address, amount: u64) acquires Vault {

    let vault = borrow_global_mut<Vault>(vault_address);

    assert!(vault.admin == signer::address_of(admin), E_NOT_ADMIN);

    

    coin::transfer<AptosCoin>(admin, vault.vault_address, amount);

    [vault.total](http://vault.total)\_balance = [vault.total](http://vault.total)\_balance + amount;

    event::emit_event(&mut vault.tokens_deposited_events, TokensDepositedEvent { amount });

}

Additional Changes

  • Update all other functions (`allocate_tokens`, claim_tokens, withdraw_tokens, etc.) similarly.
  • Modify any view functions to take vault_address directly.
  • Ensure that the init_module function still correctly sets up the vault with the admin address.

Part 2: Deployment and Testing

Deployment

1. Set up Remix IDE environment if you haven't already.

2. Modify your project's Move.toml file to include any necessary dependencies.

3. Use the Remix IDE and Welldone wallet to deploy your contract after compilation.

4. Note the address where your contract is deployed.

Testing

1. Use the functions on Remix IDE to test your contract’s functionality.

2. Test each modified function to ensure it works correctly with the new vault_address parameter.

3. Verify that admin functions can only be called by the admin address.

4. Test error cases to ensure proper access control and balance checks.

Example Test Cases

  • Deploy the contract and initialize the vault
  • Deposit tokens into the vault
  • Allocate tokens to a test address
  • Attempt to allocate tokens from a non-admin address (should fail)
  • Claim allocated tokens
  • Withdraw unallocated tokens

Submission

1. Provide the modified contract code.

2. Share the address of the deployed contract on the Aptos testnet or devnet.

3. Optionally, include a brief report detailing:

  • The changes made to the contract
  • Results of your test cases
  • Any challenges encountered and how you resolved them

Bonus

Implement a new function that allows the admin to transfer ownership of the vault to a new admin address. Explain how this impacts the overall security model of the contract.

Good luck with your homework assignment! Remember to test thoroughly and always prioritize security when making changes to smart contracts.

Veri

Submit your work to complete this lesson.

Join the project workspace to share your solution and receive feedback.

Previous
Next

Lesson discussion

Swap insights and ask questions about “Learn everything about Aptos”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
WebsiteDiscoverPartner with UsBlogEvents
Discover
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsBrand GuidelineFAQsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://risein.com is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://risein.com disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Rise In, All rights reserved