Using Ethers.js to Sign and Recover EIP-712 Typed Structured Data
Solidity - EIP-712 Typed Structured Data Hashing and Signing explains how smart contracts verify the signature of EIP-712. This article explains how to use Ethers.js for EIP-712 signing. This article uses Ethers.js version 6.7.1. Signsigner.signTypedDataEthers.js uses the following function to sign. Refer to the previous article Using Ethers.js to Sign and Recover to obtain the Signer. 1signer.signTypedData(domain, types, value): Promise<string> domain: The data of eip712Domain in the con ...
Using Web3.js to Sign and Recover EIP-712 Typed Structured Data
Solidity - EIP-712 Typed Structured Data Hashing and Signing explains how smart contracts verify the signature of EIP-712. This article explains how to use Web3.js for EIP-712 signing. This article uses Web3.js version 4.1.1. SignBrowser WalletWeb3.js can use the following functions to sign EIP-712: web3.eth.signTypedData web3.currentProvider.request Browser wallets can use the above functions, but Web3.js does not have a private key signing method, so another library will be introduced later ...
Solidity - EIP-712 Typed Structured Data Hashing and Signing
This article explains the EIP-712 standard and how to use Solidity to implement EIP-712 in smart contract. IntroductionIn the previous article, we introduced some methods of signing and verification. In practice, we may sign many data. For example: 123456789function permit(address owner, address spender, uint value, uint nonce, uint deadline, uint8 v, bytes32 r, bytes32 s) external { require(deadline >= block.timestamp, "signature expired"); require(!usedNonces[nonce], " ...
Using Ethers.js to Sign and Recover
Solidity - ecrecover this article explains how smart contracts verify signatures. This article will explain how to use Ethers.js to sign and recover. This article uses Ethers.js version 6.7.1. SignerThe Signer object will be used in the following content. Here is a brief explanation of how to obtain it. Private Key12345import { JsonRpcProvider, Wallet } from "ethers";const privateKey = '0x...'const provider = new JsonRpcProvider(url);const signer = new Wallet(privat ...
Using Web3.js to Sign and Recover
Solidity - ecrecover this article explains how smart contracts verify signatures. This article will explain how to use Web3.js to sign and recover. This article uses Web3.js version 4.1.1. SignWeb3.js provides several off-chain signing functions. This article introduces the following three: web3.eth.sign web3.eth.accounts.sign web3.personal.sign For EIP-712 related methods, refer to Using Web3.js to Sign and Recover EIP-712 Typed Structured Data. web3.eth.signThis is an old function, and the s ...
Solidity - Signature Malleability
The previous article introduced the usage of ecrecover, but the built-in ecrecover has a signature malleability problem. This article will explain this problem and how to solve it. ProblemExamples from the previous article: 1234567function test() external view returns(address) { bytes32 hash = 0xc1af4b94166cd32fc49b7b926cbb91ee421de2d04450e8ae57857b9b56ac7e53; uint8 v = 0x1b; bytes32 r = 0xe1077fb9321c187d8a43926896abac5455ce6add269e098f855ff059d6b846a3; bytes32 s = 0x56320be5f6d79c4d0e ...
Solidity - ecrecover
IntroductionThe ecrecover function in the smart contract can be used to verify the signature of the wallet. The verifier can confirm the identity of the signer without the signer’s private key. It is often used for off-chain authorization, and then used on-chain by a third party or for simple identity verification. Function1function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address) hash: The hash of the signed message. v: v value of signature. r: r value of signature. s: ...
zkEVM Airdrop Guide
zkEVM is one of the L2 solutions of ZK Rollup. While there is already a MATIC coin, it is said that there may be an airdrop opportunity as well. Here I research and organize a piece of information for your reference. As the same L2 ZK Rollup solution, the strategy is the same as the previous zkSync Airdrop Strategy. WalletJust use Metamask. BridgezkEVM 的 Bridge page, it is better to bridge when fee is under $6 (0.0028 ETH). ApplicationList some applications that have been on the mainnet Name ...
Load CSS Asynchronously
This article explains FOUC (Flash of unstyled content), render-blocking issues, and how to load CSS asynchronously. Flash of unstyled contentAfter the HTML is loaded, it will be displayed first, and then the CSS will be loaded. You will see the HTML screen without style first, and might load CSS style in short time. This causes it looks like a flicker. In addition to this situation, many webpages now also use JavaScript to render the screen, and similar problems will also occur. 例如一個使用 Bootstrap ...
GCP Cloud Monitoring - Reduce Data and Cost
Cloud Monitoring can be used to monitor system status and send alert notifications. I mainly use to monitor hard disk capacity and some custom statuses. I installed Ops Agent on all machines to monitor hard disk status. But I later realized the bill was expensive, so I did some research on its fees and how to keep costs down. PricingFirst of all, let’s understand the pricing of Cloud Monitoring. Mostly, only the first feature is used. The first 150 MiB of this part is a free quota. If we can kee ...