This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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!"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: AGPL-3.0-only | |
pragma solidity ^0.8.7; | |
contract Timestamp { | |
uint public timestamp; | |
function saveTimestamp() public { | |
timestamp = block.timestamp; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.7; | |
contract CountEmitLog { | |
event WantsToCount(address indexed msgSender); | |
constructor() {} | |
function emitCountLog() public { | |
emit WantsToCount(msg.sender); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 [email protected] | |
contract My721Token is ERC721URIStorage, Ownable { | |
uint256 private _nextTokenId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 [email protected] | |
contract My721Token is ERC721URIStorage, Ownable { | |
uint256 private _nextTokenId; |