The Generation of Mnemonics
MnemonicWe know that in MetaMask, when you generate a new account, you will get a set of mnemonics. This article will explain the process of generating mnemonics. Let’s see the code first.function genMnemonic() { const randomWallet = ethers.Wallet.createRandom(); const mnemonic = randomWallet.mnemonic.phrase; console.log(mnemonic); return mnemonic; } static createRandom(provider?: null | Provider): HDNodeWallet { const wallet = HDNodeWallet.createRandom(); if (provider) { return wallet.connec...
The Generation of Mnemonics
MnemonicWe know that in MetaMask, when you generate a new account, you will get a set of mnemonics. This article will explain the process of generating mnemonics. Let’s see the code first.function genMnemonic() { const randomWallet = ethers.Wallet.createRandom(); const mnemonic = randomWallet.mnemonic.phrase; console.log(mnemonic); return mnemonic; } static createRandom(provider?: null | Provider): HDNodeWallet { const wallet = HDNodeWallet.createRandom(); if (provider) { return wallet.connec...
What is ERC721:Section 1
What is ERC-721.Actually you can simply understand the ERC-721 is NFT. This is the link of EIP-721.https://eips.ethereum.org/EIPS/eip-721 Official explanation of ERC-721 is “Non-Fungible Token”, which means every token is specially. That means you can use NFT to represent unique image, stock, or even real estate.Practical ApplicationYou can find plenty of tutorial of ERC-721. And this blog will show you the practical application. Fist of all, let’s see the solidity code of a contract which im...
What is ERC721:Section 1
What is ERC-721.Actually you can simply understand the ERC-721 is NFT. This is the link of EIP-721.https://eips.ethereum.org/EIPS/eip-721 Official explanation of ERC-721 is “Non-Fungible Token”, which means every token is specially. That means you can use NFT to represent unique image, stock, or even real estate.Practical ApplicationYou can find plenty of tutorial of ERC-721. And this blog will show you the practical application. Fist of all, let’s see the solidity code of a contract which im...
Gas Optimization Tips
In Ethereum, the execution of contract will cost gas fee. An excellent contract should cost gas fee as low as possible. In this article, I will summary some gas optimization tips.1 Storage OptimizationIn Ethereum, storage data is written in contract account, which will cost the most gas fee.1.1 Reduce writing storage dataWe can use memory to storage middle data, instead of always writing storage data.uint256 a = storageVar; // read storage a += 10; // memory operation storageVar = a; // write...
Gas Optimization Tips
In Ethereum, the execution of contract will cost gas fee. An excellent contract should cost gas fee as low as possible. In this article, I will summary some gas optimization tips.1 Storage OptimizationIn Ethereum, storage data is written in contract account, which will cost the most gas fee.1.1 Reduce writing storage dataWe can use memory to storage middle data, instead of always writing storage data.uint256 a = storageVar; // read storage a += 10; // memory operation storageVar = a; // write...
Learning from crypto zombies lesson 2
Hi all, this is my second crypto zombies lesson homework! https://share.cryptozombies.io/zh/lesson/2/share/kevin?id=Y3p8NjIzMTk2 In this section, I will show my new contract and the knowledge behind the code.pragma solidity ^0.4.19; contract ZombieFactory { event NewZombie(uint zombieId, string name, uint dna); uint dnaDigits = 16; uint dnaModulus = 10 ** dnaDigits; struct Zombie { string name; uint dna; } Zombie[] public zombies; mapping (uint => address) public zombieToOwner; mapping (addre...
Learning from crypto zombies lesson 2
Hi all, this is my second crypto zombies lesson homework! https://share.cryptozombies.io/zh/lesson/2/share/kevin?id=Y3p8NjIzMTk2 In this section, I will show my new contract and the knowledge behind the code.pragma solidity ^0.4.19; contract ZombieFactory { event NewZombie(uint zombieId, string name, uint dna); uint dnaDigits = 16; uint dnaModulus = 10 ** dnaDigits; struct Zombie { string name; uint dna; } Zombie[] public zombies; mapping (uint => address) public zombieToOwner; mapping (addre...
Learning from crypto zombies lesson 1
Hi all, I’m a developer working in web2. I want to learn web3 knowledge and become a developer in web3. In this artical, I will show my solidity learning stage. And this is my crypto zombie. You can click this link to see it. https://share.cryptozombies.io/zh/lesson/1/share/kevin?id=Y3p8NjIzMTk2 In this section, I will show my contract and the knowledge behind the code.pragma solidity ^0.4.19; contract ZombieFactory { event NewZombie(uint zombieId, string name, uint dna); uint dnaDigits = 16;...
Learning from crypto zombies lesson 1
Hi all, I’m a developer working in web2. I want to learn web3 knowledge and become a developer in web3. In this artical, I will show my solidity learning stage. And this is my crypto zombie. You can click this link to see it. https://share.cryptozombies.io/zh/lesson/1/share/kevin?id=Y3p8NjIzMTk2 In this section, I will show my contract and the knowledge behind the code.pragma solidity ^0.4.19; contract ZombieFactory { event NewZombie(uint zombieId, string name, uint dna); uint dnaDigits = 16;...