Gas Optimization Tips
Minimize on-chain dataUse librariesUse ERC1167Turn on the Solidity optimizerUse eventsUse literal instead of computed valuesAvoid to copy arrays in memoryAvoid for-loop over dynamic rangesOptimize order of variable declarationUse eth-gas-reporter
EIP-712: Quick Intro and Use case
https://eips.ethereum.org/EIPS/eip-712 Abstract This is a standard for hashing and signing of typed structured data as opposed to just bytestrings. It includes a theoretical framework for correctness of encoding functions, specification of structured data similar to and compatible with Solidity structs, safe hashing algorithm for instances of those structures, safe inclusion of those instances in the set of signable messages, an extensible mechanism for domain separation, new RPC call eth_sig...
How Tornado Cash works
Tornado Cash is a coin mixer that you can use to anonymize your Ethereum transactions. Because of the logic of the blockchain, every transaction is public. If you have some ETH on your account, you cannot transfer it anonymously, because anybody can follow your transaction history on the blockchain. Coin mixers, like Tornado Cash, can solve this privacy problem by breaking the on-chain link between the source and the destination address by using ZKP.Deposit:Users deposit the same amount of ET...
Blockchain Developer
Gas Optimization Tips
Minimize on-chain dataUse librariesUse ERC1167Turn on the Solidity optimizerUse eventsUse literal instead of computed valuesAvoid to copy arrays in memoryAvoid for-loop over dynamic rangesOptimize order of variable declarationUse eth-gas-reporter
EIP-712: Quick Intro and Use case
https://eips.ethereum.org/EIPS/eip-712 Abstract This is a standard for hashing and signing of typed structured data as opposed to just bytestrings. It includes a theoretical framework for correctness of encoding functions, specification of structured data similar to and compatible with Solidity structs, safe hashing algorithm for instances of those structures, safe inclusion of those instances in the set of signable messages, an extensible mechanism for domain separation, new RPC call eth_sig...
How Tornado Cash works
Tornado Cash is a coin mixer that you can use to anonymize your Ethereum transactions. Because of the logic of the blockchain, every transaction is public. If you have some ETH on your account, you cannot transfer it anonymously, because anybody can follow your transaction history on the blockchain. Coin mixers, like Tornado Cash, can solve this privacy problem by breaking the on-chain link between the source and the destination address by using ZKP.Deposit:Users deposit the same amount of ET...
Blockchain Developer

Subscribe to Hicss

Subscribe to Hicss
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
You can interleave Solidity statements with inline assembly in a language close to one of the Ethereum virtual machine. This gives you more fine-grained control, which is especially useful when you are enhancing the language by writing libraries.
You only use assembly if you have no other choice because assembly manipulates directly the memory and it is kind of dangerous.
Let's see a simple example.
Assembly function: we need to put assembly inside the function. You can manipulate variables declared outside. And also you can declare a local variable.
Everything in the EVM is stored in a slot of 256bits.

Another example. In order to make it easier to see, I have put the code explanation in the comments.

Let's look at 2 other slightly more complicated examples.
The first one: Detect if an address is a smart contract(it can only be done on assembly)

The second one: Cast bytes to bytes32

You can interleave Solidity statements with inline assembly in a language close to one of the Ethereum virtual machine. This gives you more fine-grained control, which is especially useful when you are enhancing the language by writing libraries.
You only use assembly if you have no other choice because assembly manipulates directly the memory and it is kind of dangerous.
Let's see a simple example.
Assembly function: we need to put assembly inside the function. You can manipulate variables declared outside. And also you can declare a local variable.
Everything in the EVM is stored in a slot of 256bits.

Another example. In order to make it easier to see, I have put the code explanation in the comments.

Let's look at 2 other slightly more complicated examples.
The first one: Detect if an address is a smart contract(it can only be done on assembly)

The second one: Cast bytes to bytes32

No activity yet