Skip to content

Commit

Permalink
changed README.md copy. moved files
Browse files Browse the repository at this point in the history
  • Loading branch information
sogoiii committed May 2, 2024
1 parent 17b1fb6 commit 76a9c10
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 146 deletions.
4 changes: 2 additions & 2 deletions deploy/30_verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// 'HolographDropERC721',
// 'HolographDropERC721V2',
// 'HolographDropERC721Proxy',
'CountdownERC721',
'CountdownERC721Proxy',
// 'CountdownERC721',
// 'CountdownERC721Proxy',
// 'HolographFactory',
// 'HolographFactoryProxy',
// 'HolographGeneric',
Expand Down
16 changes: 8 additions & 8 deletions scripts/countdown_erc721/1-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ async function main() {
* STEP 2: SET THE STATIC VALUES
*/

const contractName = 'CustomERC721';
const contractSymbol = 'C721';
const contractName = 'CountdownTest001';
const contractSymbol = 'CTO1';

const customERC721Initializer: CountdownERC721Initializer = {
description: '',
imageURI: '',
externalLink: '',
encryptedMediaURI: '',
description: '<ENTER MY DESCRIPTION>',
imageURI: 'testURI', // Will not change, currently hardcoded
externalLink: 'https://your-nft-project.com', // Will not change, currently hardcoded
encryptedMediaURI: 'ar://encryptedMediaUriHere', // Will not change, currently hardcoded
startDate: 1714512791, // Epoch time for Tuesday, April 30, 2024 9:33:11 PM
initialMaxSupply: 4173120, // Total number of ten-minute intervals until Oct 8, 2103
mintInterval: 600, // Duration of each interval
initialOwner: deployerAddress,
initialMinter: deployerAddress,
fundsRecipient: deployerAddress,
contractURI: 'https://example.com/metadata.json',
contractURI: 'https://example.com/metadata.json', // Will not change, currently hardcoded
salesConfiguration: {
publicSalePrice: 100000000,
publicSalePrice: 10_000_000, // Set price in USD (10_000_000 = $10 USD)
maxSalePurchasePerAddress: 0, // no limit
},
};
Expand Down
4 changes: 2 additions & 2 deletions scripts/countdown_erc721/3-mintTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ async function main() {
* STEP 2: SET HARDCODED VALUES
*/

const contractAddress = '';
const recipient = '';
const contractAddress = '0xc4535d9a032c0f3ef3c6e03a35d7444de9083148';
const recipient = '0xD17e8cEe2EC7fEE30e9F9ECB82EaB918659872AF';
const quantity = 1;

/*
Expand Down
3 changes: 2 additions & 1 deletion scripts/countdown_erc721/4-purchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ async function main() {

const contractAddress = '0xd323e2c37ca989f5e923a12bcdf10aa3544fa8fa';
const quantity = 1;
const price = ethers.utils.parseUnits('100', 6);
const price = ethers.utils.parseUnits('10', 6);

// DO NOT CHANGE THIS!
const dropsPriceOracleAddress = '0xeA7f4C52cbD4CF1036CdCa8B16AcA11f5b09cF6E';

/*
Expand Down
49 changes: 27 additions & 22 deletions scripts/countdown_erc721/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ This folder contains four scripts:
- `1-deploy.ts`
- `2-setOwner.ts`
- `3-mintTo.ts`
- `2-purchase.ts`
- `4-purchase.ts`

Below are the steps required to run the scripts successfully.

</br>

## Prerequisites

Expand All @@ -18,8 +17,7 @@ Below are the steps required to run the scripts successfully.
- Wallet private key
- Network provider URL
- Optional: Hardware wallet (e.g., Ledger)

</br>


## Environment Variables

Expand All @@ -28,9 +26,8 @@ Ensure the following environment variables are set:
- `CUSTOM_ERC721_SALT`: Salt for deterministic address generation (must be a 32-character hexadecimal string)
- `CUSTOM_ERC721_PROVIDER_URL`: Network provider URL
- `HARDWARE_WALLET_ENABLED`: (Optional) Flag indicating whether a hardware wallet is enabled
- `HOLOGRAPH_ENVIRONMENT`: Holograph environment (localhost, develop, testnet, mainnet)
- `HOLOGRAPH_ENVIRONMENT`: Holograph environment (develop, testnet, mainnet)

</br>

## Script 1: Contract Deploy

Expand All @@ -47,6 +44,15 @@ This script utilizes hardcoded values, which need to be updated, to generate the
- `contractName`: Name of the ERC721 contract
- `contractSymbol`: Symbol of the ERC721 contract
- `countdownERC721Initializer`: Initializer object containing various parameters for the ERC721 contract
- `description`: Description of the contract
- `imageURI`: Image URL for the NFT
- `externalLink`
- `encryptedMediaURI`
- `startDate`: Start date in seconds from epoc
- `initialMaxSupply`: Total Max Supply
- `mintIntervals`: How much to reduce counter by for a mint
- `contractURI`s
- `publicSalePrice`: Note that `10_000_000 = $10` USD

3. **Preparing to Deploy Contract:**
- Encode contract initialization parameters.
Expand All @@ -56,30 +62,27 @@ This script utilizes hardcoded values, which need to be updated, to generate the
- Execute the deployment process.
- Upon successful deployment, the contract address will be displayed.

</br>

To run the script, use the following command in your terminal:

```sh
ts-node countdown_erc721/deploy.ts
ts-node ./scripts/countdown_erc721/1-deploy.ts
```

</br>

## Script 2: Set Owner
## Script 2: Set Owner [WIP]

This is a straightforward script that invokes the contract to update the owner using hardcoded values.

### Steps

2. **Set the static values:**
1. **Set the static values:**
- Configure the static values:
- `contractAddress`: The CountdownERC721 address
- `newOwner`: The wallet address of the new owner.
3. **Run the script update the owner:**
2. **Run the script update the owner:**

```sh
ts-node countdown_erc721/2-setOwner.ts
ts-node ./scripts/countdown_erc721/2-setOwner.ts
```

## Script 3: Mint To
Expand All @@ -88,15 +91,16 @@ This is a straightforward script that invokes the contract `mintTo` function usi

### Steps

2. **Set the static values:**
1. **Set the static values:**
- Configure the static values:
- `contractAddress`: The CountdownERC721 address
- `recipient`: The wallet address of recipient.
- `quantity`: The number of tokens to be minted.

3. **Run the script update the owner:**
2. **Run the script update the owner:**

```sh
ts-node countdown_erc721/3-mintTo.ts
ts-node ./scripts/countdown_erc721/3-mintTo.ts
```

## Script 4: Purchase
Expand All @@ -105,13 +109,14 @@ This is a straightforward script that invokes the contract `purchase` function u

### Steps

2. **Set the static values:**
1. **Set the static values:**
- Configure the static values:
- `contractAddress`: The CountdownERC721 address
- `quantity`: The number of tokens to be minted.
- `price`: The public sale price in wei.

3. **Run the script update the owner:**
2. **Run the script update the owner:**

```sh
ts-node countdown_erc721/4-purchase.ts
```
ts-node ./scripts/countdown_erc721/4-purchase.ts
```
37 changes: 1 addition & 36 deletions scripts/countdown_erc721/utils.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
import { ethers, Contract, Signer } from 'ethers';
import { Environment } from '@holographxyz/environment';
import { hexlify, zeroPad } from '@ethersproject/bytes';
import { JsonRpcProvider, Log } from '@ethersproject/providers';
import { TransactionReceipt, TransactionResponse } from '@ethersproject/abstract-provider';

import { DeploymentConfigSettings, Hex } from './types';
import {getHolographAddress} from "../utils/utils";

export function flattenObject(obj: Record<string, any>): any[] {
return Object.values(obj).map((value: any) => {
if (typeof value === 'object') {
if (Array.isArray(value)) {
value.map((item) => flattenObject(item));
}
return flattenObject(value); // Recursively flatten nested objects
}
return value;
});
}

export function parseBytes(str: string, size = 32): Hex {
return hexlify(zeroPad(ethers.utils.toUtf8Bytes(str), size)) as Hex;
}

export function destructSignature(signedMessage: Hex) {
return {
r: ('0x' + signedMessage.substring(2, 66)) as Hex,
s: ('0x' + signedMessage.substring(66, 130)) as Hex,
v: ('0x' + signedMessage.substring(130, 132)) as Hex,
};
}

export function getHolographAddress(environment: Environment) {
const HOLOGRAPH_ADDRESSES: { [key in Environment]: string } = {
[Environment.localhost]: '0x17253175f447ca4B560a87a3F39591DFC7A021e3'.toLowerCase(),
[Environment.experimental]: '0x199728d88a68856868f50FC259F01Bb4D2672Da9'.toLowerCase(),
[Environment.develop]: '0x11bc5912f9ed5E16820f018692f8E7FDA91a8529'.toLowerCase(),
[Environment.testnet]: '0x1Ed99DFE7462763eaF6925271D7Cb2232a61854C'.toLowerCase(),
[Environment.mainnet]: '0x1Ed99DFE7462763eaF6925271D7Cb2232a61854C'.toLowerCase(),
};

return HOLOGRAPH_ADDRESSES[environment];
}

export async function getFactoryAddress(provider: JsonRpcProvider, environment: Environment): Promise<Hex> {
const getFactoryABI = ['function getFactory() view returns (address factory)'];
Expand Down
6 changes: 1 addition & 5 deletions scripts/custom_delay_reveal_erc721/2-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ import { getNetworkByChainId } from '@holographxyz/networks';

import {
deployHolographableContract,
destructSignature,
flattenObject,
getFactoryAddress,
getRegistryAddress,
parseBytes,
readCsvFile,
} from './utils';
import { CustomERC721Initializer, DeploymentConfig, DeploymentConfigSettings, Hex } from './types';
import { customErc721Bytecode } from './custom-erc721-bytecode';
import { FileColumnsType, parseFileContent, parsedEnv } from './validations';
import {destructSignature, flattenObject, getFactoryAddress, getRegistryAddress, parseBytes} from "../utils/utils";

require('dotenv').config();

Expand Down
76 changes: 6 additions & 70 deletions scripts/custom_delay_reveal_erc721/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import path from 'path';
import { parse } from 'csv-parse';
import { ethers, Contract, Signer } from 'ethers';
import { Environment } from '@holographxyz/environment';
import { hexlify, zeroPad } from '@ethersproject/bytes';
import { JsonRpcProvider, Log } from '@ethersproject/providers';
import { appendFileSync, createReadStream, existsSync, unlinkSync } from 'fs';
import { TransactionReceipt, TransactionResponse } from '@ethersproject/abstract-provider';
import {parse} from 'csv-parse';
import {Contract, ethers, Signer} from 'ethers';
import {Log} from '@ethersproject/providers';
import {appendFileSync, createReadStream, existsSync, unlinkSync} from 'fs';
import {TransactionReceipt, TransactionResponse} from '@ethersproject/abstract-provider';

import { DeploymentConfigSettings, Hex } from './types';
import {DeploymentConfigSettings, Hex} from './types';

export const writeCSVFile = (filePath: string, data: string, breakLine = true) => {
try {
Expand Down Expand Up @@ -77,68 +75,6 @@ export function encryptDecrypt(url: string, hexKey: string): string {
return ethers.utils.hexlify(result);
}

export function flattenObject(obj: Record<string, any>): any[] {
return Object.values(obj).map((value: any) => {
if (typeof value === 'object') {
if (Array.isArray(value)) {
value.map((item) => flattenObject(item));
}
return flattenObject(value); // Recursively flatten nested objects
}
return value;
});
}

export function parseBytes(str: string, size = 32): Hex {
return hexlify(zeroPad(ethers.utils.toUtf8Bytes(str), size)) as Hex;
}

export function generateRandomSalt() {
return '0x' + Date.now().toString(16).padStart(64, '0');
}

export function destructSignature(signedMessage: Hex) {
return {
r: ('0x' + signedMessage.substring(2, 66)) as Hex,
s: ('0x' + signedMessage.substring(66, 130)) as Hex,
v: ('0x' + signedMessage.substring(130, 132)) as Hex,
};
}

export function getHolographAddress(environment: Environment) {
const HOLOGRAPH_ADDRESSES: { [key in Environment]: string } = {
[Environment.localhost]: '0x17253175f447ca4B560a87a3F39591DFC7A021e3'.toLowerCase(),
[Environment.experimental]: '0x199728d88a68856868f50FC259F01Bb4D2672Da9'.toLowerCase(),
[Environment.develop]: '0x11bc5912f9ed5E16820f018692f8E7FDA91a8529'.toLowerCase(),
[Environment.testnet]: '0x1Ed99DFE7462763eaF6925271D7Cb2232a61854C'.toLowerCase(),
[Environment.mainnet]: '0x1Ed99DFE7462763eaF6925271D7Cb2232a61854C'.toLowerCase(),
};

return HOLOGRAPH_ADDRESSES[environment];
}

export async function getFactoryAddress(provider: JsonRpcProvider, environment: Environment): Promise<Hex> {
const getFactoryABI = ['function getFactory() view returns (address factory)'];
const holograph = new Contract(getHolographAddress(environment), getFactoryABI, provider);
try {
const factoryProxyAddress: string = await holograph.getFactory();
return factoryProxyAddress.toLowerCase() as Hex;
} catch (error) {
throw new Error(`Failed to get HolographFactory address.`, { cause: error });
}
}

export async function getRegistryAddress(provider: JsonRpcProvider, environment: Environment): Promise<Hex> {
const getRegistryABI = ['function getRegistry() view returns (address registry)'];
const holograph = new Contract(getHolographAddress(environment), getRegistryABI, provider);
try {
const registryProxyAddress: string = await holograph.getRegistry();
return registryProxyAddress.toLowerCase() as Hex;
} catch (error) {
throw new Error(`Failed to get HolographRegistry address.`, { cause: error });
}
}

export async function deployHolographableContract(
deployer: Signer,
factoryProxyAddress: Hex,
Expand Down
Loading

0 comments on commit 76a9c10

Please sign in to comment.