Skip to content

Instantly share code, notes, and snippets.

View mingderwang's full-sized avatar

Ming-der Wang mingderwang

View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract DeterministicDeployFactory {
event Deploy(address addr);
function deploy(bytes memory bytecode, uint _salt) external {
address addr;
assembly {
addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt)
@mingderwang
mingderwang / SimpleAccount.sol
Created February 9, 2024 04:48
test ethereum ERC4337 SimpleAccount.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;
/* solhint-disable avoid-low-level-calls */
/* solhint-disable no-inline-assembly */
/* solhint-disable reason-string */
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract CountEmitLog {
event WantsToCount(address indexed msgSender);
constructor() {}
function emitCountLog() public {
emit WantsToCount(msg.sender);
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
/// @custom:security-contact mingderwang@me.com
contract My721Token is ERC721URIStorage, Ownable {
uint256 private _nextTokenId;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/// @custom:security-contact mingderwang@me.com
contract My721Token is ERC721URIStorage, Ownable {
uint256 private _nextTokenId;
@mingderwang
mingderwang / MyToken721.sol
Created November 30, 2023 16:02
MyToken721
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts@5.0.0/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@5.0.0/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts@5.0.0/access/Ownable.sol";
contract MyToken721 is ERC721, ERC721URIStorage, Ownable {
uint256 private _nextTokenId;

Hi, 你好

@mingderwang
mingderwang / gist:33f0b3fc4c94ac0dae85bf7db4adf401
Created October 16, 2023 10:16
index.js:59:103 { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' }
// your answer is to run following line first.
export NODE_OPTIONS=--openssl-legacy-provider
@mingderwang
mingderwang / gist:25c02b0069e9e65c6e1d94d6bb31c48d
Last active September 22, 2023 14:24
I clone from your code and run it again, it works fine
$ node -v
v18.17.1
$ git clone https://github.com/samar19/ming-erc20-token.git
Cloning into 'ming-erc20-token'...
remote: Enumerating objects: 52, done.
remote: Counting objects: 100% (52/52), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 52 (delta 18), reused 43 (delta 10), pack-reused 0
Receiving objects: 100% (52/52), 214.26 KiB | 238.00 KiB/s, done.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts-upgradeable@4.9.3/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.9.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.9.3/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.9.3/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.9.3/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable@4.9.3/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable@4.9.3/proxy/utils/UUPSUpgradeable.sol";