Sometimes we have to stop our service for system upgrades, repairs...

So is there any way to stop receiving token from another account?

1 Answer 1


Yes. You can freeze your contract by creating a multi_index table that indicates whether the account is frozen or not.

When a token is received, you can assert on whether the account is frozen or not.

You can create an action to set the frozen status of the contract.


  class [[eosio::table]] freeze
      uint64_t id;
      bool frozen;
      uint64_t primary_key() const {return id;}

  typedef eosio::multi_index< eosio::name("freeze"), freeze > freeze_table;

  void mycontract::freeze(bool frozen)
    freeze_table.modify(freeze_table.find(0), _self, [&](auto & table)
        table.frozen = frozen;

  // This has to be linked to the eosio.token transfer in the apply function
  void mycontract::transfer(eosio::name from, 
    eosio::name to, 
    eosio::asset quantity, 
    std::string memo) 
    freeze_table ftab(_self, _self.value);
    auto isfrozen = ftab.find(0);
    eosio::check(isfrozen != ftab.end(),"Freeze table not initialized");
    eosio::check(!isfrozen->frozen,"Account is frozen, no funds currently being accepted");
  • I want to account stop receiving EOS , not stop the smart contract to receive EOS. same as ETH's account , apparently EOSIO does not support,
    – Son Le
    Feb 16, 2019 at 5:49
  • The way to do that would be to upload a smart contract onto your account. That is what I am saying Feb 16, 2019 at 11:27
  • As the example above, users still send EOS to my account, it doesn't make sense.
    – Son Le
    Feb 16, 2019 at 14:46
  • The eosio::check in the example will make the transaction fail if frozen is set to true. Meaning, any account sending a transaction to your account (that has the smart contract deployed and set frozen to true) will see an error message and the transfer will fail. Feb 16, 2019 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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