Skip to content

Instantly share code, notes, and snippets.

View mingderwang's full-sized avatar

Ming-der Wang mingderwang

View GitHub Profile
@mingderwang
mingderwang / gist:6c1eeaa801559cd0d9b05aaa9c99e1f9
Created April 14, 2024 17:52
if you got this error: > NX Could not find ".modules.yaml" at ".../node_modules/.modules.yaml"
// just
npm install -g @nrwl/cli@latest
npm install -g lerna@latest
// or even
rm -rf node_modules package-lock.json
npm install
pragma solidity ^0.8.0;
contract ExampleContract {
struct PassKeyId {
uint256 pubKeyX;
uint256 pubKeyY;
string keyId;
}
// You can declare a variable of type PassKeyId
/* solhint-disable */
// SPDX-License-Identifier: MIT
// from OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)
pragma solidity ^0.8.19;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*
* _Available since v4.5._
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.17;
//
// Heavily inspired from
// https://github.com/maxrobot/elliptic-solidity/blob/master/contracts/Secp256r1.sol
// https://github.com/tdrerup/elliptic-curve-solidity/blob/master/contracts/curves/EllipticCurve.sol
// modified to use precompile 0x05 modexp
// and modified jacobian double
// optimisations to avoid to an from from affine and jacobian coordinates
//
@mingderwang
mingderwang / gist:d9852d87fb038b2bdab5b15ff4e43d0c
Created March 12, 2024 06:19
export NODE_OPTIONS=--openssl-legacy-provider
odules/babel-loader/lib/index.js:51:103 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.24 and less than 0.9.0
pragma solidity ^0.8.24;
contract HelloWorld {
string public greet = "Hello World!";
}
@mingderwang
mingderwang / index.html
Created March 6, 2024 16:17
refer to https://simplewebauthn.dev/docs/packages/browser (code is generated by ChatGPT in openAI)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Authentication Example</title>
</head>
<body>
<script>
exports.endpoint = (req, res) => {
const html = `
<!-- Example 1: Preact in HTML (no build tooling required!) -->
<!-- View Code: https://glitch.com/edit/#!/familiar-warm-monday -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@mingderwang
mingderwang / Timestamp.sol
Last active February 17, 2024 16:08
Timestamp test
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.7;
contract Timestamp {
uint public timestamp;
function saveTimestamp() public {
timestamp = block.timestamp;
}
}
const { ethers } = require("ethers");
const encoder = (types, values) => {
const abiCoder = ethers.utils.defaultAbiCoder;
const encodedParams = abiCoder.encode(types, values);
return encodedParams.slice(2);
};
const create2Address = (factoryAddress, saltHex, initCode) => {
const create2Addr = ethers.utils.getCreate2Address(factoryAddress, saltHex, ethers.utils.keccak256(initCode));