Calling EVM contracts from C++
How an EVM contract calls a C++ contract in AppLayer.
class SolMyContract {
public:
uint256_t myFunction(const uint256_t& arg1, const uint256_t& arg2) const {};
static void registerContract() {
ContractReflectionInterface::registerContractMethods<SolMyContract>(
std::vector<std::string>{}, // List of dependencies or related artifacts if any
std::make_tuple("myFunction", &SolMyContract::myFunction, FunctionTypes::View, std::vector<std::string>{"arg1", "arg2"})
);
}
};uint256_t AnotherContract::callMyFunction(const Address& targetAddr, const uint256_t& arg1, const uint256_t& arg2) const {
SolMyContract::registerContract(); // Ensure the EVM contract's methods are registered (Can be done only a single time in the constructor)
return this->callContractViewFunction<SolMyContract>(this, targetAddr, &SolMyContract::myFunction, arg1, arg2);
}Last updated