I have written a smart contract and I want to start testing it, it contains an apply function, which currently checks for a transfer, and then calls the appropriate function:
void mycontract::apply(account_name contract, account_name act)
{
switch(act)
{
case N(transfer):
eosio_assert(contract == N(eosio.token), "MyContract | use eosio.token");
on(unpack_action_data<eosio::currency::transfer>());
break;
}
}
I also have the C version, which does not belong to the mycontract class:
extern "C"
{
[[noreturn]] void apply( uint64_t receiver, uint64_t code, uint64_t action )
{
mycontract _mycontract(receiver);
if(code == N(eosio.token))
{
switch(action) {
case N(transfer):
_mycontract.on(eosio::unpack_action_data<eosio::currency::transfer>());
break;
default:
break;
}
}
eosio_exit(0);
}
}
Finally, I try to add the contract to my local nodeos:
cleos set contract contractowner ../mycontract/ -p contractowner
I then receive the following error message, which I don't understand:
Error 3070002: Runtime Error Processing WASM
Error Details:
Smart contract's apply function not exported; non-existent; or wrong type
pending console output:
Does anyone know what could be causing this error message, or how I could go about debugging it further?
EDIT: It also doesn't work if I use the macro:
EOSIO_ABI( eosio::mycontract, (on) )
EOSIO_ABI(mycontract, (on))
?