У меня следующий смарт-контракт EOSIO:
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;
class random : public contract
{
public:
using contract::contract;
[[eosio::action]]
void hi(name user) {
print("Hello and welcome to the future ", user);
}
[[eosio::action]]
int compute(int x)
{
// unsigned means no negative values which increases the range of numbers the variable can hold
const unsigned int FIVE = 5;
// FIVE = 3; // would throw an error as FIVE is declared constant
return x * x + FIVE;
}
};
EOSIO_DISPATCH(random, (compute))
Я не понимаю, как вызвать compute
действие в EOSIO_DISPATCH(random, (compute))
, потому что оно имеет тип возврата int.Может ли кто-нибудь помочь мне с этим?Я хочу развернуть этот умный контракт в testnet.Следующая ошибка генерируется при выполнении eosio-cpp -o random.wasm random.cpp --abigen
:
random.cpp:62:1: error: no matching function for call to 'execute_action'
EOSIO_DISPATCH(random, (compute))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/eosiolib/dispatcher.hpp:128:13: note: expanded from macro 'EOSIO_DISPATCH'
EOSIO_DISPATCH_HELPER( TYPE, MEMBERS ) \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/eosiolib/dispatcher.hpp:103:27: note: expanded from macro 'EOSIO_DISPATCH_HELPER'
BOOST_PP_SEQ_FOR_EACH( EOSIO_DISPATCH_INTERNAL, TYPE, MEMBERS )
~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/boost/preprocessor/seq/for_each.hpp:29:88: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH'
# define BOOST_PP_SEQ_FOR_EACH(macro, data, seq) BOOST_PP_SEQ_FOR_EACH_DETAIL_CHECK(macro, data, seq)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/usr/local/eosio.cdt/bin/../include/boost/preprocessor/seq/for_each.hpp:78:76: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_M_IM'
# define BOOST_PP_SEQ_FOR_EACH_M_IM(r, im) BOOST_PP_SEQ_FOR_EACH_M_I(r, im)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/local/eosio.cdt/bin/../include/boost/preprocessor/seq/for_each.hpp:83:61: note: expanded from macro 'BOOST_PP_SEQ_FOR_EACH_M_I'
# define BOOST_PP_SEQ_FOR_EACH_M_I(r, macro, data, seq, sz) macro(r, data, BOOST_PP_SEQ_HEAD(seq))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/eosiolib/dispatcher.hpp:98:7: note: expanded from macro 'EOSIO_DISPATCH_INTERNAL'
eosio::execute_action( eosio::name(receiver), eosio::name(code), &OP::elem ); \
^~~~~~~~~~~~~~~~~~~~~
/usr/local/eosio.cdt/bin/../include/eosiolib/dispatcher.hpp:66:9: note: candidate template ignored: could not match 'void' against 'int'
bool execute_action( name self, name code, void (T::*func)(Args...) ) {
^
1 error generated.