-
Originally from Stack Overflow. I know there is a Move module (smart contract) on chain with a function that looks like this: public entry fun do_nothing() {} I know it is deployed at I have a Move module of my own that looks like this.
[package]
name = 'mine'
version = '1.0.0'
[dependencies.AptosFramework]
git = 'https://github.com/aptos-labs/aptos-core.git'
rev = 'main'
subdir = 'aptos-move/framework/aptos-framework'
[addresses]
my_addr = "81e2e2499407693c81fe65c86405ca70df529438339d9da7a6fc2520142b591e"
other_addr = "6286dfd5e2778ec069d5906cd774efdba93ab2bec71550fa69363482fbd814e7"
module my_addr::mine {
use other_addr::other::do_nothing;
public entry fun do_stuff() {
do_nothing();
}
} As you can see, I'm telling the compiler where the
Why is compilation failing? Why can't the compiler figure it out for me based on the ABIs of the Move modules it finds at |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The problemIn order to publish a Move module that calls a function in another Move module, you need its source code. This is true of all Move modules, not just your own. You'll notice in So to make this work, you need to have access to the source. Source: Git DependencyIf you have access to the source in another git repository, you can tell the compiler where to find the
This is telling the compiler, "the source code for Source: LocalIf you have the source code locally, you can do this instead:
Where the argument for Source: I don't have it?If you don't have the source, you can try to download it. By default, when someone publishes a Move module, they include the source code alongside it. First try to download the code:
If the source code was indeed deployed on chain, you should see this:
Inside From here, you can just follow the steps for Note: The value for Source: The download failed?If you ran
You'll find that This means the author published the code with this CLI argument set:
Meaning they purposely chose not to include the source on chain. In that case, you can get the source by decompiling the bytecode. See this post explaining how to do that: #31 I hope this helps, happy coding!! The code used in this answer can be found here: https://github.com/banool/move-examples/tree/main/call_other_module. |
Beta Was this translation helpful? Give feedback.
The problem
In order to publish a Move module that calls a function in another Move module, you need its source code. This is true of all Move modules, not just your own. You'll notice in
Move.toml
there is already a dependency onAptosFramework
. This is what allows you to call all the framework functions, e.g. those related to coins, tokens, signer, timestamps, etc.So to make this work, you need to have access to the source.
Source: Git Dependency
If you have access to the source in another git repository, you can tell the compiler where to find the
other
module by adding this to your Move.toml: