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
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...
Bytes and String in Solidity
1. If we know the size of the bytes we want to store, the best approach is to use the fixed size byte array type To initialize a fixed size byte array, we need to specify the size of how many bytes we would like to store.bytes1 b1 = hex"41"; Bytes can be initialized with either a hex string hex"41" or a hex value 0X41 which is the letter A according to ASCII. 2. Fixed size bytes can be passed between smart contracts in the Solidity programming language. 3.bytes and bytes32 Bytes is a dynamic ...
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
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...
Bytes and String in Solidity
1. If we know the size of the bytes we want to store, the best approach is to use the fixed size byte array type To initialize a fixed size byte array, we need to specify the size of how many bytes we would like to store.bytes1 b1 = hex"41"; Bytes can be initialized with either a hex string hex"41" or a hex value 0X41 which is the letter A according to ASCII. 2. Fixed size bytes can be passed between smart contracts in the Solidity programming language. 3.bytes and bytes32 Bytes is a dynamic ...
Blockchain Developer

Subscribe to Hicss

Subscribe to Hicss
<100 subscribers
<100 subscribers
Share Dialog
Share Dialog
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_signTypedData, and an optimized implementation of the hashing algorithm in EVM. It does not include replay protection.
Use Case:
Key signatures IDEX requires the aggregation of orders on a centralized server, how do we ensure that orders are not altered by the exchange? The core lies in the fact that each of our transactions is signed with the user's own private key before it is sent to the centralized server, and then the smart contract will verify the user's signature when it performs settlement. If the centralized server makes any changes to the order data, it will not pass the smart contract's verification.
How to put EIP712 to use Let's take an auction scenario as an example to see how to put EIP712 to use in a product.
Defining the data structure First, list the data to be signed by the user in JSON format. For example, as an auction application, the following bid data is required to be signed
{
amount: 100,
token: “0x….”,
id: 15,
bidder: {
userId: 323,
wallet: “0x….”
}
}
Then, we can distill two data structures from the above code snippet: Bid, which contains the bid amount determined by the ERC20 token asset and auction id, and Identity, which specifies the user id and user wallet address. Next, the Bid and Identity are defined as structs, and the following solidity contract code can be written. The full list of data types supported by EIP712, such as address, bytes32, uint256, etc., can be viewed in the EIP712 draft protocol.
Bid: {
amount: uint256,
bidder: Identity
}
Identity: {
userId: uint256,
wallet: address
}
Design domain separator The main purpose is to prevent the signature of one DApp from working in another DApp, which can lead to signature conflicts. In the case of an auction, for example, a bid request in one auction application can be executed successfully in another auction application, which may lead to unnecessary losses.
Specifically, a domain separator is a structure and data such as the following.
{
name: "Auction dApp", //Dapp name
version: "2", // Version of the Dapp
chainId: "1",
verifyingContract: "0x1c56346...", //address to verify signature
salt: "0x43efba6b4..." // random value
}
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_signTypedData, and an optimized implementation of the hashing algorithm in EVM. It does not include replay protection.
Use Case:
Key signatures IDEX requires the aggregation of orders on a centralized server, how do we ensure that orders are not altered by the exchange? The core lies in the fact that each of our transactions is signed with the user's own private key before it is sent to the centralized server, and then the smart contract will verify the user's signature when it performs settlement. If the centralized server makes any changes to the order data, it will not pass the smart contract's verification.
How to put EIP712 to use Let's take an auction scenario as an example to see how to put EIP712 to use in a product.
Defining the data structure First, list the data to be signed by the user in JSON format. For example, as an auction application, the following bid data is required to be signed
{
amount: 100,
token: “0x….”,
id: 15,
bidder: {
userId: 323,
wallet: “0x….”
}
}
Then, we can distill two data structures from the above code snippet: Bid, which contains the bid amount determined by the ERC20 token asset and auction id, and Identity, which specifies the user id and user wallet address. Next, the Bid and Identity are defined as structs, and the following solidity contract code can be written. The full list of data types supported by EIP712, such as address, bytes32, uint256, etc., can be viewed in the EIP712 draft protocol.
Bid: {
amount: uint256,
bidder: Identity
}
Identity: {
userId: uint256,
wallet: address
}
Design domain separator The main purpose is to prevent the signature of one DApp from working in another DApp, which can lead to signature conflicts. In the case of an auction, for example, a bid request in one auction application can be executed successfully in another auction application, which may lead to unnecessary losses.
Specifically, a domain separator is a structure and data such as the following.
{
name: "Auction dApp", //Dapp name
version: "2", // Version of the Dapp
chainId: "1",
verifyingContract: "0x1c56346...", //address to verify signature
salt: "0x43efba6b4..." // random value
}
No activity yet