9

I know that we have require_auth to check for permission, but I'm looking for something like is_valid_account to check if the account exists and is active in the chain.

Do we have anything like that? I tried to use eosio.token contract to transfer tokens to a non-existing account and it just allowed me to do so.

Thank you!

1
  • I noticed that if we call require_recipient and the account does not exist the action will fail... but not sure if it's the best practice because doing that we always "notify" the recipient account May 9, 2018 at 14:30

2 Answers 2

10

I found it in Dawn 4.0 release, it's simply is_account(account_name)

Check out the eosio.token new contract in transfer action, release: https://github.com/EOSIO/eos/blob/dawn-v4.0.0/contracts/eosio.token/eosio.token.cpp#L76

eosio_assert( is_account( to ), "to account does not exist");

5

There's a new intrinsic in the slim branch, but isn't declared yet in a header.

extern "C" int64_t get_account_creation_date(account_name account);

It looks like this function will fail if the account doesn't exist.

2

Your Answer

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

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