- Feb 2022
-
ethernaut.openzeppelin.com ethernaut.openzeppelin.com
-
uint32(uint64(_gateKey)) == uint16(tx.origin)
the _gateKey should be the tx.origin parsed as uint16
-
require(uint32(uint64(_gateKey)) != uint64(_gateKey),
_gateKey that is not converted to either uint32 or uint16 should be different to the uint64 version
-
require(uint32(uint64(_gateKey)) == uint16(uint64(_gateKey)),
_gateKey should be able to be converted to both uint32 and uint16 without information loss
-
require(gasleft().mod(8191) == 0);
Presumably we should send gas in multiples of 8191?
-
require(msg.sender != tx.origin);
tx.origin is the originator of a contract call, no matter how many contracts sit in between it and the final destination. msg.sender is the most recent sender of the call. We can handle this condition by creating 2 contracts.
-
-
ethernaut.openzeppelin.com ethernaut.openzeppelin.com
-
balances[msg.sender] -= _amount;
Our balance isn't reduced until here, leaving the door open to reenter the contract in the msg.sender.call
-
(bool result,) = msg.sender.call{value:_amount}("");
Violates checks-effects-interactions. Call is to payable address backup or receive function
-
-
ethernaut.openzeppelin.com ethernaut.openzeppelin.com
-
king.transfer(msg.value);
This function violates the checks-effects-interact pattern by including a call to an external contract before state variables are changed.
-
-
ethernaut.openzeppelin.com ethernaut.openzeppelin.com
-
uint256(blockhash(block.number.sub(1)))
get the previous block's number, get the hash of that block, and convert to uint256, then assign to the variable blockValue.
If the placeholder lastHash is equal to blockValue, we are in the same block and the call to flip will revert.
Otherwise, update lastHash to equal blockValue (thus storing the record of the block)
-
blockhash
get the hash of the given block (only works for 256 most recent blocks, excluding current)
-
block.number
Current block number
-
-
ethernaut.openzeppelin.com ethernaut.openzeppelin.com
-
modifier onlyOwner { require( msg.sender == owner, "caller is not the owner" ); _; }
If a function is annotated with the onlyOwner modifier, the sender of the transaction must be the owner otherwise the tx will revert.
-
receive() external payable { require(msg.value > 0 && contributions[msg.sender] > 0); owner = msg.sender; }
By sending any amount of Ether to the contract once your contributions are more than 0, you will become the owner of the contract and can withdraw all of the tokens
-
function contribute() public payable {
Anyone can call this function, and can send ether to the function
-
mapping(address => uint) public contributions;
We're storing user contributions, mapping an address to the amount of the contribution
-
using SafeMath for uint256;
SafeMath is used to prevent over / underflows
-
- Feb 2019
-
-
For that reason, “overuse” of the internet and social media today may not be such a bad thing. It is our primary way of exploring all of the potential of that cultural mode, and that mode will at some point be tamed and neutered, just as Baroque music composition is now dormant.
I don't think that we can so easily equate a Baroque music fad with internet & social media addiction - it feels like a genuinely different mode of human interaction that is causing large, potentially negative changes in our societies at a core level.
-
That would have some positive effects on gdp in the short run, but its major effects would be in the much longer run, namely the prevention of a very destructive war.
As far as I understand most large, destructive wars have led to large jumps in technological prowess that has eventually 'trickled down' to the consumer market & society in general, raising GDP in the process (think the internet, jet propulsion, lasers, reconstructive surgery, etc)
-
- Sep 2018
-
nolanlawson.com nolanlawson.com
-
it executes before the browser’s next style/layout calculation step.
requestAnimationFrame allows for fluid and predictable execution.
-
Broadly speaking, a setTimeout(0) doesn’t really run in zero milliseconds. Usually, it runs in 4.
The 0 in a setTimeout(0) call is actually only a minimum amount of time - due to the Event Loop cycles the 0 call will usually run in no less than 4ms.
-
It's important to understand that in the Event Loop there are Tasks & Microtasks. The Microtask queue is exhausted before returning to the Task queue - and Microtasks can queue other Microtasks, hance why the for loop in this example will block any other execution.
-