I want to call other module's function in my contract, but I haven't it's source code, just can see it's bytecode onchain;
In sodility has interface contract, and just need a proto (interface), then can call any contract even has no source code as fllow:
So how to do it in sui move?
pragma solidity ^0.4.0;
contract InfoFeed {
function info() payable returns (uint ret);
}
contract Consumer {
function deposit() payable returns (uint){
return msg.value;
}
function left() constant returns (uint){
return this.balance;
}
function callFeed(address addr) returns (uint) {
return InfoFeed(addr).info.value(1).gas(8000)();
// here i no need to get source code for InfoFeed implements, and can call it with address
}
}
First of all if you only have the modules bytecode and still want to call a function from it means that you really understand what that code does. If it is the case then you must also have understanding of what parameters it takes.
With above assumption you can, very easily, call any public function from any already deployed package by updating two files:
1. move.toml under [addresses] add the address of the package where the function you want to call is defined.
2. src/your_module.move: import the function you want to use.
Here's a sample of a function from bytecode for a package: