Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Find rainbows
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidsi committed May 1, 2021
1 parent c1e59cf commit eb56c19
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 5 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,23 @@ npm run dev
- Point the MetaMask-enabled browser to: http://localhost:3000/

- Mint a token ;)

## Expected Rainbow Tokens:

| (index) | block | date | timestamp |
| ------- | -------- | ------------------------ | ------------- |
| 0 | 12373314 | 2021-05-05T08:21:16.657Z | 1620202876657 |
| 1 | 12374516 | 2021-05-05T12:45:55.077Z | 1620218755077 |
| 2 | 12399679 | 2021-05-09T09:05:58.307Z | 1620551158307 |
| 3 | 12426259 | 2021-05-13T10:38:00.107Z | 1620902280107 |
| 4 | 12444663 | 2021-05-16T06:09:56.947Z | 1621145396947 |
| 5 | 12466279 | 2021-05-19T13:29:04.307Z | 1621430944307 |
| 6 | 12470457 | 2021-05-20T04:48:55.687Z | 1621486135687 |
| 7 | 12476918 | 2021-05-21T04:31:25.497Z | 1621571485497 |
| 8 | 12484634 | 2021-05-22T08:50:13.857Z | 1621673413857 |
| 9 | 12488171 | 2021-05-22T21:48:57.627Z | 1621720137627 |
| 10 | 12501032 | 2021-05-24T21:00:31.437Z | 1621890031437 |
| 11 | 12532935 | 2021-05-29T18:04:30.067Z | 1622311470067 |
| 12 | 12540699 | 2021-05-30T22:33:52.507Z | 1622414032507 |
| 13 | 12565110 | 2021-06-03T16:08:21.817Z | 1622736501817 |
| 14 | 12567458 | 2021-06-04T00:45:18.897Z | 1622767518897 |
6 changes: 3 additions & 3 deletions contracts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@typechain/ethers-v5": "^5.0.0",
"@types/chai": "^4.2.15",
"@types/mocha": "^8.2.1",
"@types/node": "^14.14.31",
"@types/node": "^14.14.43",
"chai": "^4.3.0",
"ethereum-waffle": "^3.2.2",
"ethers": "^5.0.31",
Expand Down
79 changes: 79 additions & 0 deletions contracts/scripts/findRainbows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { ethers } from 'ethers';

import {
LissajousArgs,
addresses,
LissajousToken,
LissajousToken__factory,
} from '..';
import simulateLissajousArgs from '../lib/simulateLissajousArgs';

export const main = async () => {
const provider = ethers.getDefaultProvider('mainnet', {
alchemy: 'U3ZksHolqD4YuDZrJuEn0PLpzMO2lCqC',
});

const contractAddress = addresses[1].LissajousToken;

const contract: LissajousToken = LissajousToken__factory.connect(
contractAddress,
provider,
);

// console.log(await provider.detectNetwork());

const now = new Date().getTime();
const currentBlock = await provider.getBlockNumber();
const startBlock = (await contract.startBlock()).toNumber();
const endBlock = (await contract.endBlock()).toNumber();
const rainbowFrequency = await contract.rainbowFrequency();

console.log((endBlock - startBlock) / rainbowFrequency);

// console.log(rainbowFrequency);

// let i;
// for (i = currentBlock; i <= endBlock; i++) {
// const { rainbow } = simulateLissajousArgs(i);

// if (rainbow) {
// const isRainbow = await contract.isBlockRainbow(i);
// console.log(i, rainbow, isRainbow);
// }
// }

const averageBlockTime = 13.21;

const nextRainbowBlocks = [
12373314,
12374516,
12399679,
12426259,
12444663,
12466279,
12470457,
12476918,
12484634,
12488171,
12501032,
12532935,
12540699,
12565110,
12567458,
];

const expectedDates = nextRainbowBlocks.map((block) => {
const diff = block - currentBlock;
const diffMs = diff * averageBlockTime * 1000;
return { block, date: new Date(now + diffMs), timestamp: now + diffMs };
});

console.table(expectedDates);
};

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
3 changes: 2 additions & 1 deletion contracts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"typeRoots": ["@types", "node_modules/@types"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.js", "**/*.json"],
"files": ["./hardhat.config.ts", "./addresses.json"]
Expand Down

0 comments on commit eb56c19

Please sign in to comment.