Manipulating strings in Solidity is notoriously difficult. This is surprising for most developers who are used to manipulating easily in other programming languages like Javascript or Python. https://youtu.be/gNlwpr3vGYM In this article I give a couple of useful code snippets to do some simple string manipulations in Solidity. Warning: Keep in…
Read StoryGenerating a random number in a smart contract is very useful, especially for games. Can we do this in Solidity? Yes! https://youtu.be/4zvvZf-byok Here is the code: pragma solidity ^0.6.0; contract MyContract { function _randModulus(uint mod) internal returns(uint) { return uint(keccak256(abi.encodePacked( now, block.difficulty, msg.sender) )) % mod; nonce++; return rand; }…
Read StoryERC this, ERC that... so many token standards... If you want to become good in Solidity, you HAVE to understand how to transfer on-chain assets... And that means knowing token standards, like ERC20... The problem is... there are SO MANY token standards: What is an Ethereum Token? Which tokens are…
Read StoryLet's say we have 2 smart contracts. A and B. A calls B, and B throws an error. What happen in A? Not sure? haha, that's a tricky one! Actually it depends on how B was called. If B was called the normal way, the whole transaction get reverted: contract A {…
Read Storyhttps://youtu.be/-5j6Ho0Bkfk ERC20 tokens allow you to create your own coin inside Ethereum. They are used in many projects to represent financial assets, in-game assets, collectible, and other kind of assets. At some point in your project, you will probably need to interact with them. And most often, you will need to…
Read Storyhttps://youtu.be/_Nvl-gz-tRs Sending Ether between smart contracts is very important. After all, it's because smart contracts can do financial transactions that they are so powerful. But surprisingly there are a few caveats when you want to send ether from a smart contract: Transfer units are in wei (10^-18 ether), not ether…
Read Storyhttps://youtu.be/MPBOnChpi0c Solidity arrays... are like Javascript arrays, right? Nope.. In Solidity: Arrays can only contain data of the same type (ex: arrays of integers, array of booleans, but not arrays of integers AND booleans..) Arrays can be in storage, or in memory (persistent and non-persistent) You can use the `push()`…
Read StoryFinally! Smart contract 30 is finished! I have just published the last video of smart contract 30 on Solidity assembly. In total this course has 56 videos and is 13.6 hours long. It took me almost 6 month of efforts to do all the research, coding and recording. I gave…
Read StorySimple transactions on Ethereum cost from 20-30 cents to a few dollars. But complex transactions can be much more expensive. For example, the Loom network created the ERC721x standard to avoid paying millions of dollars in gas costs when doing a batch token transfer. Clearly, knowing how to reduce gas…
Read StoryAfter you deploy a web application, you can always change its code if you need to add a feature or fix a bug. All you need to do is to redeploy the code on the server. With Ethereum smart contracts, this is not possible. Once you deploy a smart contract,…
Read Story