2

I'm using ruby and would like to find out if an address is a contract one that can potentially take a lot of gas to transfer money to (and possibly failed in the middle).

In this: Using EVM assembly to get the address' code size

They suggesting to use this code:

function isContract(address addr) returns (bool) {
  uint size;
  assembly { size := extcodesize(addr) }
  return size > 0;
}

I think this is to be executed inside ETH miner itself? If I want to perform a simple check on my browser/Ruby on Rails server, how should I do it?

1

You can use the Ethereum node's RPC interface described here: https://github.com/ethereum/wiki/wiki/JSON-RPC. You're interested in this function here: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode. You can use curl to request the data.

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.