zkSync Airdrop Guide
Arbitrum has been airdropped a while ago, and I heard that some people have retired by airdrop. zkSync is the next popular airdrop opportunity. Here I research and organize a piece of information for your reference. The next post zkSync Airdrop Guide Step by Step provides an step by step tutorial. Airdrop RulesBefore starting the zkSync interaction, let’s refer to the recent Arbitrum, which is also Layer 2, and the previous Optimism airdrop rules as a reference. OptimismRefer to Optimism Airdrop ...
Solidity Gas Optimizations - Variable Ordering
DescriptionYou may not know that the order of declaration of variables will also affect the consumption of Gas.Since the EVM operations are all performed in units of 32 bytes, the compiler will attempt to package the variables into a 32 bytes set for access, so as to reduce access times.However, the compiler is not smart enough to automatically optimize the grouping of variables. It will group the statically-sized variables in groups of 32 bytes. For example: 12345678910111213contract MyContract ...
Solidity Gas Optimizations - Data Compression
In the process of developing smart contract, because we want to be able to achieve matching function, we have implemented a function that can input multiple orders. As more and more features are added to our function and more and more arguments are required to ensure contractual fairness, such as miners’ fees, taker’s fee, maker’s fee and payment method of fee. We encounter to the variable too much and can not compile, and a lot of data consumed gas has also become a problem. In our matching fun ...
Solidity Gas Optimizations - Function Name
DescriptionYou may not think that the name of the function will also have an impact on gas consumption. In fact, in the worst case, there may be more than a thousand of gas impacts. Let’s take a look at the following code: 1234contract Test { function b() public { }} The above execution b() will consume 125 gas, then change to the following: 1234567contract Test { function a() public { } function b() public { }} This time b() becomes 147 ga ...
Solidity Gas Optimizations
A smart contract development business have its costs come from the transactions of smart contracts; the gas consumption has a direct impact on the company’s costs structure. Writing contracts in an energy-saving way are essential. This article will analyze some of the factors that affect gas consumption in smart contracts. Outlining what is the most expensive instruction and uses it with caution. Gas consumption can refer to the following two tables: Table 1 Table 2 The gas used in Table 1 is ...
How to Measure JavaScript Code Coverage With jscoverage
We had known How to Write a Library for Node.js and Browser with Mocha Unit Tests. Now, we can use some tool to calculate code coverage further. We used mocha before, so we choose jscoverage because it can support mocha. Please done your unit tests before start. Installation1npm install jscoverage --save-dev Ignored FilesIf we don’t want to include some files, we can add the list to .covignore in the root of project. And write like this: 12/tests/node_modules/ Eg. we don’t want to include test ...
How to Write a Library for Node.js and Browser with Mocha Unit Tests
Mocha is a test framework for JavaScript, it provides Node.js and browser versions. Assume we implement a JavaScript library and we want to run unit tests automatically. And also, we want that it could be used in Node.js and browsers. We can use following methods to do that. This example files structure look like this: 12345src\md5.jstests\test.jstests\node-test.jstests\index.htmlpackage.json Or refer to js-md5. InstallationInstall mocha package to your project. 12npm install mocha --save-devnpm ...
Node.js - How to Integrate Travis CI with GitHub
Travis CI is service for Continuous Integration and it is easy to integrate with the projects on GitHub. It support many programming languages. Travis CI will run unit tests after the project update and report the results. This article will introduce how to integrate node.js projects. Enable Travis CI for GitHub projectYou can sign in with GItHub account and find your projects on GitHub. Go to the Accounts page on the top-right side.Click the toggle to enable. .travis.ymlAdd .travis.yml file to ...
How to omit bundle exec prefix by bundle binstubs
bundle binstubsIn Ruby, we use Bundler to manage the gem in our projects. We also use bundle exec prefix to run the command in our projects for ensuring that it’s running in current bundler. Eg. 1bundle exec rake db:migrate But, it seems a little inconvenient so that we can use binstubs to omit it. Assume that we want to generate binstubs of rake: 1bundle binstubs rake This will generate rake script in the bin folder, and now we can run 1./bin/rake equal to 1bundle exec rake If you want to gener ...