Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Units and Globally Available Variables - all differences #6

Open
ghost opened this issue Oct 8, 2018 · 0 comments
Open

Units and Globally Available Variables - all differences #6

ghost opened this issue Oct 8, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 8, 2018

In Units and Globally Available Variables, all bellow is not supported in Array:

  1. Ether Units
    https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#ether-units

  2. Time Units
    https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#time-units

  3. In Block and Transaction Properties, following code:
    https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#block-and-transaction-properties

  • block.coinbase (address): current block miner’s address
  • block.difficulty (uint): current block difficulty
  • gasleft() returns (uint256): remaining gas
  • msg.data (bytes): complete calldata
  • msg.gas (uint): remaining gas - deprecated in version 0.4.21 and to be replaced by
    gasleft()
  • msg.sig (bytes4): first four bytes of the calldata (i.e. function identifier)
  • now (uint): current block timestamp
  • tx.gasprice (uint): gas price of the transaction
  • tx.origin (address): sender of the transaction (full call chain)
  1. In Mathematical and Cryptographic Functions (from keccak256(...) until the next subsection):
    https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#mathematical-and-cryptographic-functions

keccak256(...) returns (bytes32):
compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
sha256(...) returns (bytes32):
compute the SHA-256 hash of the (tightly packed) arguments
sha3(...) returns (bytes32):
alias to keccak256
ripemd160(...) returns (bytes20):

compute RIPEMD-160 hash of the (tightly packed) arguments
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address):
recover the address associated with the public key from elliptic curve signature or return zero on error (example usage)
In the above, “tightly packed” means that the arguments are concatenated without padding. This means that the following are all identical:
keccak256("ab", "c")
keccak256("abc")
keccak256(0x616263)
keccak256(6382179)
keccak256(97, 98, 99)
If padding is needed, explicit type conversions can be used: keccak256("\x00\x12") is the same as keccak256(uint16(0x12)).
Note that constants will be packed using the minimum number of bytes required to store them. This means that, for example, keccak256(0) == keccak256(uint8(0)) andkeccak256(0x12345678) == keccak256(uint32(0x12345678)).
It might be that you run into Out-of-Gas for sha256, ripemd160 or ecrecover on a private blockchain. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net.

  1. In Address Related:
    https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#address-related

<address>.call(...) returns (bool):
issue low-level CALL, returns false on failure, forwards all available gas, adjustable
<address>.callcode(...) returns (bool):
issue low-level CALLCODE, returns false on failure, forwards all available gas, adjustable
<address>.delegatecall(...) returns (bool):
issue low-level DELEGATECALL, returns false on failure, forwards all available gas, adjustable

  1. Contract Related
    https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#contract-related
@ghost ghost changed the title Units and Globally Available Variables Units and Globally Available Variables - all differences Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants