April 6, 2020

How to manipulate strings in Solidity?

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 Story
April 3, 2020

How to generate a random number in smart contract?

Generating 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 Story
November 21, 2019

Ethereum Tokens explained to Developers – Full Guide (9 tokens covered)

ERC 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 Story
October 22, 2019

How error propagate between contracts in Solidity?

Let'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 Story
October 19, 2019

How to transfer ERC20 tokens with Solidity?

https://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 Story
October 17, 2019

How to transfer Ether between 2 smart contracts?

https://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 Story
October 11, 2019

Solidity vs Javascript arrays

https://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 Story
July 21, 2019

The Smart contract 30 course is finished!

Finally! 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 Story
June 28, 2019

How to optimize gas cost in a Solidity smart contract? 6 tips

Simple 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 Story
June 25, 2019

New course for testing Solidity smart contracts

After 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

Never miss a minute

Get great content to your inbox every week. No spam.
[contact-form-7 id="6" title="Footer CTA Subscribe Form"]
Arrow-up