Building on Aptos: A Guide for Solana Developers #2
Open Github Page
Fungible Assets on Aptos and Solana
Fungible Asset Launchpad Example
Tips for Building on Aptos
Aptos Developer Docs
Tips for Building on Aptos
Cross Contract Call
Similar to Solana, Aptos also uses static dispatch to ensure safety. That means you need to have the source code of the contract you want to call at compile time.
Let's first look at how to add a dependency to another contract in Solana's Cargo.toml
.
[dependencies]anchor-spl = { version = "0.29.0", features = ["metadata"] }
On Aptos, it's very similar, we add the dependency in Move.toml
file, AptosFramework
is a Move Package which contains a collections of contracts at the same address. Fungible asset contract is one of them.
[dependencies]AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "mainnet", subdir = "aptos-move/framework/aptos-framework"}
Using the dependency in Solana is as simple as importing the contract and calling the function.
use anchor_spl::metadata::create_metadata_accounts_v3;pub fn handle_create_token( ctx: Context<CreateToken>, //...) -> Result<()> { create_metadata_accounts_v3(...)?; // ...}
On Aptos, you import the contract and call the function in the same way.
use aptos_framework::primary_fungible_store;use aptos_framework::fungible_asset;public entry fun create_fa( // ...) acquires Registry { primary_fungible_store::create_primary_store_enabled_fungible_asset( // ... ); let mint_ref = fungible_asset::generate_mint_ref(fa_obj_constructor_ref); let burn_ref = fungible_asset::generate_burn_ref(fa_obj_constructor_ref); let transfer_ref = fungible_asset::generate_transfer_ref(fa_obj_constructor_ref); // ...}
Next step: try it yourself
Want to quickly build a production ready end-to-end Fungible Asset
dapp? Learn more about our create-aptos-dapp tool to easily bootstrap on the Aptos network