<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>CS - Category - HEJTAO</title>
        <link>https://hejtao.netlify.app/categories/cs/</link>
        <description>CS - Category - HEJTAO</description>
        <generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 26 Mar 2025 00:00:00 &#43;0000</lastBuildDate><atom:link href="https://hejtao.netlify.app/categories/cs/" rel="self" type="application/rss+xml" /><item>
    <title>Merkle Airdrop</title>
    <link>https://hejtao.netlify.app/posts/cs-merkle-airdrop/</link>
    <pubDate>Wed, 26 Mar 2025 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-merkle-airdrop/</guid>
    <description><![CDATA[How to play? Airdrop a bunch of ERC20 tokens to users Deploy a smart contract Send an email with wallet address, token amount and proof to each user The user claims their tokens from the smart contract Build a merkle tree import { MerkleTree } from &#39;merkletreejs&#39;; import keccak256 from &#39;keccak256&#39;; import { solidityPacked } from &#39;ethers&#39;; function main() { const whitelist = [ { address: &#39;0x2173dEd80D3c17D2f349234a31ab8789D28Dd333&#39;, amount: 100 }, { address: &#39;0x2AFAF65965e08DBd0e0aD7a5594E6b5BE398CBd6&#39;, amount: 200 }, { address: &#39;0xfbc89Db3927bCCda61F550d3d9f3998750b7b93f&#39;, amount: 300 }, ]; const leaves = whitelist.]]></description>
</item>
<item>
    <title>How to Create an NFT Contract with Oppenzeppelin</title>
    <link>https://hejtao.netlify.app/posts/cs-721-practice/</link>
    <pubDate>Thu, 27 Feb 2025 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-721-practice/</guid>
    <description><![CDATA[ERC721 // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ERC721} from &#34;@openzeppelin/contracts/token/ERC721/ERC721.sol&#34;; contract Wave is ERC721 { constructor() ERC721(&#34;Wave&#34;, &#34;WV&#34;) {} function mint(address to, uint256 tokenId) public { _safeMint(to, tokenId); } } Access Owner // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ERC721} from &#34;@openzeppelin/contracts/token/ERC721/ERC721.sol&#34;; import {Ownable} from &#34;@openzeppelin/contracts/access/Ownable.sol&#34;; contract Wave is ERC721, Ownable { constructor() ERC721(&#34;Wave&#34;, &#34;WV&#34;) Ownable(msg.sender) {} function mint(address to, uint256 tokenId) public onlyOwner { _safeMint(to, tokenId); } } Minter Add /interfaces/IMinterManager.]]></description>
</item>
<item>
    <title>How to Build a NFT Market with Locksrare Protocol</title>
    <link>https://hejtao.netlify.app/posts/cs-market/</link>
    <pubDate>Fri, 10 Jan 2025 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-market/</guid>
    <description><![CDATA[Terminology Maker: a passive order that exists off-chain Taker: an order that is executed on-chain Ask: the ask user sells NFT assets for fungible tokens Bid: the bid user buys NFT assets by spending fungible tokens Create Maker Create MakerAsk get global nonce from LooksRareProtocol
check that collection has approved the TransferManager
allow TransferManager to transfer NFT assets check that TransferManager has approved LooksRareProtocol
import { utils, providers, Wallet } from &#39;ethers&#39;; import { LooksRare, CollectionType, StrategyType } from &#39;@looksrare/sdk-v2&#39;; async function main() { const chainId: number = 2021; const provider = new providers.]]></description>
</item>
<item>
    <title>Verkle Trie of Ethereum</title>
    <link>https://hejtao.netlify.app/posts/cs-kzg-commitment/</link>
    <pubDate>Sat, 23 Nov 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-kzg-commitment/</guid>
    <description><![CDATA[Polynomial Coefficient representation $$f(x) = x^3 - 2x + 1$$
Point-values representation (0,1), (1,0), (2,5), (3,22) Point-values to coefficients How many points do we need?
if $d$ is the degree of the polynomial, then $d+1$ points are needed. How to find the coefficients? (method 1) solve the linear equation in $d+1$ variables (method 2) use Lagrange interpolation Reed-Solomon code: Let $d+1$ points be the stored data, and add other $n$ points as the parity data.]]></description>
</item>
<item>
    <title>Elliptic Curve Cryptography</title>
    <link>https://hejtao.netlify.app/posts/cs-ecc/</link>
    <pubDate>Mon, 28 Oct 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-ecc/</guid>
    <description><![CDATA[Elliptic Curve $$y^2 = x^3 + ax + b$$
Point Addition The point has to be reflected on the x-axis to keep the associactivity of addition
Point Doubling Naturally consider the tangent line
Elliptic curve cryptography To guess the private key $n$ is super super hard
The problem of elliptic curve over real numbers The consecutive points of curve $y^2 = x^3 + x + 1$ with the beginning point $(0,1)$ are as follows.]]></description>
</item>
<item>
    <title>Deploy Smart Contract to Ronin Network with Hardhat</title>
    <link>https://hejtao.netlify.app/posts/cs-hardhat/</link>
    <pubDate>Sun, 15 Sep 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-hardhat/</guid>
    <description><![CDATA[Initiate project mkdir play-hardhat &amp;&amp; cd play-hardhat mkdir contracts mkdir scripts npm init -y yarn add -D hardhat @openzeppelin/hardhat-upgrades @nomicfoundation/hardhat-verify @nomicfoundation/hardhat-ethers yarn hardhat init Configuration // hardhat.config.ts import type { HardhatUserConfig } from &#39;hardhat/config&#39;; import { MNEMONIC, PRIVATE_KEY } from &#39;./secrets.json&#39;; import &#39;@openzeppelin/hardhat-upgrades&#39;; import &#39;@nomicfoundation/hardhat-verify&#39;; import &#39;@nomicfoundation/hardhat-ethers&#39;; const config: HardhatUserConfig = { solidity: { version: &#39;0.8.27&#39;, settings: { optimizer: { enabled: true, runs: 200, }, }, }, networks: { ronin: { chainId: 2020, url: &#39;https://api.]]></description>
</item>
<item>
    <title>Sequelize Notes</title>
    <link>https://hejtao.netlify.app/posts/cs-sequelize/</link>
    <pubDate>Wed, 11 Sep 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-sequelize/</guid>
    <description><![CDATA[Connection import { Sequelize } from &#39;sequelize&#39;; export const db = new Sequelize({ host: &#39;localhost&#39;, dialect: &#39;mysql&#39;, port: 3306, database: &#39;seq&#39;, username: &#39;root&#39;, password: &#39;123456&#39;, define: { timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段，默认为true freezeTableName: true, // 防止Sequelize自动复数化表名 underscored: false, // 使用下划线命名风格 }, logging: false, }); (async () =&gt; { try { await db.authenticate(); console.log(&#39;Connection has been established successfully.&#39;); } catch (error) { console.error(&#39;Unable to connect to the database:&#39;, error); } })(); Join table const signatures: (Pick&lt;ISignature, &#39;tokenId&#39; | &#39;status&#39; | &#39;hash&#39;&gt; &amp; { dataValues: any })[] = await Signature.]]></description>
</item>
<item>
    <title>Smart Contract Security</title>
    <link>https://hejtao.netlify.app/posts/cs-smartcontract-security/</link>
    <pubDate>Fri, 12 Jul 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-smartcontract-security/</guid>
    <description><![CDATA[Reentrancy Single-Function Reentrancy // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; contract Vulnerable { mapping (address =&gt; uint256) private balances; function withdraw() public { uint256 amount = balances[msg.sender]; (bool success, ) = msg.sender.call{value: amount}(&#34;&#34;); require(success); balances[msg.sender] = 0; } } When msg.sender is a smart contract, the withdraw() process may include:
update the Ethereum State Trie (i.g. the balances of from and to) excute receive() or fallback() of the smart contract withdraw() is called again during the second step Cross-Function Reentrancy // SPDX-License-Identifier: MIT pragma solidity ^0.]]></description>
</item>
<item>
    <title>Microservice with Go</title>
    <link>https://hejtao.netlify.app/posts/cs-microservice/</link>
    <pubDate>Tue, 02 Apr 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-microservice/</guid>
    <description><![CDATA[Go-Zero Kratos Quick Start install prerequisites
brew install go brew install protoc brew install protoc-gen-go # the binary will be under `~/go/bin`, so add it to your PATH go install github.com/go-kratos/kratos/cmd/kratos@latest create a new project
kratos new kratos-demo cd kratos-demo go mod download start the project
go generate ./... kratos run API Generate a service delete api/helloworld
add .proto file with kratos proto add api/sfh/v1/sfh.proto
in order to support HTTP, modify api/sfh/v1/sfh.]]></description>
</item>
<item>
    <title>TypeScript Notes</title>
    <link>https://hejtao.netlify.app/posts/cs-ts/</link>
    <pubDate>Thu, 21 Mar 2024 00:00:00 &#43;0000</pubDate>
    <author>HEJTAO.COM</author>
    <guid>https://hejtao.netlify.app/posts/cs-ts/</guid>
    <description><![CDATA[安装与执行 yarn add typescript yarn global add ts-node yarn add @types/{MODULE} yarn add {MODULE} ts-node ./src/index.ts Cannot find name &lsquo;console&rsquo; ? =&gt; yarn add @types/node
范型 class MyClass {} interface Example { a: string; b: number; c: MyClass; d: () =&gt; void; e: new () =&gt; MyClass; } type NonConstructorKeys&lt;T&gt; = { [P in keyof T]: T[P] extends new () =&gt; any ? never : P }[keyof T]; // NonConstructorKeys&lt;Example&gt; 的类型是 &#39;a&#39; | &#39;b&#39; | &#39;c&#39; | &#39;d&#39; var e: Example = { a: &#39;xxx&#39;, b: 666, c: new MyClass(), d: () =&gt; { console.]]></description>
</item>
</channel>
</rss>
