2

If somebody transfer eos to my contract, can my contract reject the transfer?

In ethereum, it seems that the contract can throw an exception to reject the transfer.

2

Yes, you can reject a transfer. For the time being, you need to use a custom dispatch macro from this answer. Then, you can put a transfer action into your contract like this:

void transfer(uint64_t sender, uint64_t receiver) {
    auto transfer_data = unpack_action_data<st_transfer>();
    // throw error on incoming transfers, but we're letting outgoing transfers through
    eosio_assert(transfer_data.from == _self && transfer_data.to != _self, "We don't accept incoming transfers!");
}

There is a full example that shows how to define a custom transfer action here.

0

The standard eosio.token contract will notify the sending and receiving accounts of the transfer, allowing any contract deployed to the account to be notified of the transfer and react accordingly.

I'm not sure how the transfer to the built-in EOS is handled, however. Based on the content of the currency.hpp file though, it looks like the recipient of the transfer will be notified just like the eosio.token contract does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.