0xosas

@0xosas

Joined on Jul 22, 2022

  • Well, this article is relating to my last article on tictactoe game and this is because of similar logic being used. A Minsweeper Game The objective of the game is to clear a board that contains hidden "mines" or "bombs" without detonating any of them, and they are randomly placed in a 9x9 grid (beginners level). On every right opeing there's a clue which indicate how many bombs are in the adjacent cells. At any point, you can perform 2 actions: Marking a cell - marking or flagging a cell that you think might be a bomb Revealing a cell - revealing the cell. If it is an empty cell, then all of the surrounding empty cells will also be revealed. Revealing a cell containing a bomb is game over.
     Like  Bookmark
  • Ethereum transactions that revert still have to pay the gas used up until the revert was triggered; If they run out of gas they pay the full limit. If they hits a revert opcode, probably from a require statement as a result of maybe an integer overflow check, they'd pay the gas up until the revert opcode was hit. They don't pay for the gas afterwards. The implication is we should revert as early as possible in the execution to save the users gas incase a transaction reverts. Here are two (2) example contracts: // DO NOT USE IN PRODUCTION // USED FOR EXPLANATION ONLY contract Example1 { uint256 public a;
     Like 1 Bookmark
  • The first crypto-currency Bitcion has limited a block size to 1-MB, and this is beacause if a block is too large it becomes expensive to store or sync with other nodes across the world or the blockchain. Ethereum doesn't place a block limit like Bitcion does, it just limits the total amount of computation on a single block since each computation has a gas cost. And the reason for this is, if a block has too much computation on it, it becomes difficult for nodes to verify the transactions quickly. So with a block limit set, if a transactions requires too much gas the transactions gets reverted. What is gas? Gas is a transaction unit that represents computational effort. It’s the fuel you must buy to get miners to add your transaction to a block. At the time of writting the block limit is 30 million (30,000,000) gas; An eth transfer cost 21 thousand (21,000) gas, so doing the math you'd see that a single block can hold just 1,428 transfers approximately. A few relating terms.
     Like 2 Bookmark
  • Building on Ethereum can be expensive, and many times it intuitive to gain control over your code and one way to achieve this is by utilzing bit operations. Many developers use it as a means of optimization, expecially in the case of ethereum when you code now cost you money. Here I'd be explaining a program I wrote not long ago, just so you'd gain an understanding of a simple use case of bit operations. Also, I assume you understand how to work with bitwise operators, and if you don't check out my article on how they work here. What is Tic-tac-toe Tic-tac-toe is a 2 player game where players take turns to make a finite amount of moves until either all moves has been exhausted (its a draw) or a player has won. Here is a typical tic-tac-toe game. # an empty game # game where play x won
     Like 2 Bookmark
  • This is an introduction to using bitwise operators and you'd learn how to do magical stuffs with them. So basically bit operations are used to manipulate bits (binary numbers) and here are the signs used: Bitwise AND & A bitwise AND is a binary operation that takes two bits and performs the logical AND operation on them. If the bits compared are 1, then bit in the resulting binary representation is 1 (1 & 1 = 1); otherwise, the result is 0 (1 & 0 = 0 and 0 & 0 = 0) source. Here is a typical example: A B A & B
     Like 1 Bookmark