I would like to check the code hash of an account from within my smart contract. Is this possible?

| improve this question | | | | |

I have since learned that this isn't possible, and could only be done using an external oracle or other off-chain service. If this changes in the future I will update this answer.

| improve this answer | | | | |

There's currently no WASM intrinsic to do that. However, Newdex keeps a list of all smart contracts for anyone to check on-chain. See here for more details

| improve this answer | | | | |

Update Actually, you don't have access to account_object from the contract.

You can use account.code_version.

See https://github.com/EOSIO/eos/blob/0f6695cb8d31e3d2f318d1720e9d9ad23e1ce80d/libraries/chain/eosio_contract.cpp#L151

From cleos do: cleos get code <accountName>

| improve this answer | | | | |
  • 2
    The question asks how to do it from within a smart contract, not how to do it with cleos. – Phillip Hamnett - EOS42 Sep 24 '18 at 15:42

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.