1

I have published a module. It has a function which publishes another module. When I try to call this function the transaction commits with error MODULE_ADDRESS_DOES_NOT_MATCH_SENDER.

My code uses account::create_resource_account to create the future module owner account and Aptos framework's aptos_framework::code::publish_package_txn(owner: &signer, metadata_serialized: vector<u8>, code: vector<vector<u8>>) to publish the module.

I retreive the metadata and code by running these commands: hexdump -ve '1/1 "%02x"' ./mymodue/build/mymodue/package-metadata.bcs and hexdump -ve '1/1 "%02x"' ./mymodue/build/mymodule/bytecode_modules/mymodulesource.mv

Here It is said that the VM does this, when a module is published:

  • Check that the module address and the sender address are the same: This check verifies that the publisher is the account that will eventually hold the module. If the two addresses do not match, an error with StatusCode::MODULE_ADDRESS_DOES_NOT_MATCH_SENDER is returned.
Max
  • 2,082
  • 19
  • 25
  • I got the same `MODULE_ADDRESS_DOES_NOT_MATCH_SENDER` error when pass the Uint8Array arguments like below: `const metadata = new HexString(packageMetadata.toString("hex")).toUint8Array(); const code = new HexString(moduleData.toString("hex")).toUint8Array();` But if I pass the string as the arguments, I got the error: Move abort in `0x1::util: 0x10001`. – yong ho Oct 26 '22 at 05:58

1 Answers1

2

Did you check Move.toml to make sure the named address where the module is deployed at matches that of the resource account you created?

movekevin
  • 36
  • 1
  • Thank you! It turns out the `account::create_resource_account` returns the same account for the same parameters (I thought it randomly generates). Needed to run the function once (in tests) and put the created account in Move.toml – Samvel Topuzyan Nov 02 '22 at 09:04