Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/hex"
"fmt"
"sort"
"github.com/cloudflare/circl/sign/dilithium"
)
@ChristianOConnor
ChristianOConnor / RandomReachDebug6p2.sol
Last active May 31, 2023 00:54
This contract mints NFTs and selects a random Classifier with API3. This contract also requires a signature from a server-bound private key via EIP712.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
@ChristianOConnor
ChristianOConnor / deployRandomDebug5Local.ts
Created May 28, 2023 07:21
Deploys RandomDebug5Local NFT contract
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
import { ethers } from "hardhat";
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
const dotenv = require("dotenv");
@ChristianOConnor
ChristianOConnor / RandomReachDebug5Local.sol
Created May 28, 2023 07:19
mints nfts with second EIP712 sugnature and should be run locally on hardhat node
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "hardhat/console.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
@ChristianOConnor
ChristianOConnor / get-addrs-from-eip712-sig.js
Last active May 28, 2023 07:16
Getting the address from a signature in javascript with ethers.js
const { ethers } = require('ethers');
async function recoverSigner(address, nonce, deadline, v, r, s) {
const domain = {
name: "RandomReachDebug5Local",
version: "1",
chainId: 31337,
verifyingContract: "0x8464135c8F25Da09e49BC8782676a84730C318bC",
};
@ChristianOConnor
ChristianOConnor / deployGetAddressFromSig.ts
Created May 27, 2023 11:14
Deploy the GetAddressFromSig contract on hardhat
import { ethers } from "hardhat";
const hre = require("hardhat");
const dotenv = require("dotenv");
dotenv.config();
async function main() {
const GetAddressFromSig = await hre.ethers.getContractFactory("GetAddressFromSig");
const gasPrice = await GetAddressFromSig.signer.getGasPrice();
console.log(`Current gas price: ${gasPrice}`);
@ChristianOConnor
ChristianOConnor / GetAddressFromSig.sol
Last active May 28, 2023 01:34
GetAddressFromSig which gets the address in an ethers split sig
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
contract GetAddressFromSig is ERC721, EIP712 {
struct Request {
@ChristianOConnor
ChristianOConnor / RandomReachDebug5.sol
Created May 26, 2023 00:26
Fifth iteration of RandomReachDebug which mints from an array of 3 Classifiers and relies on an authorized private key.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
@ChristianOConnor
ChristianOConnor / RandomReachDebug4.sol
Created May 25, 2023 22:02
I think _REQUEST_RANDOM_NFT_TYPEHASH is wrong
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
@ChristianOConnor
ChristianOConnor / RandomReachDebug2.sol
Created May 24, 2023 22:20
Contract to mint Random Classifier NFT with authorized wallet signature
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";