Skip to content

Commit

Permalink
Merge pull request #19 from wbydo/release
Browse files Browse the repository at this point in the history
Release(mint 成功)
  • Loading branch information
wbydo committed Apr 29, 2022
2 parents f95eef4 + a4501e6 commit 86509aa
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 13 deletions.
25 changes: 13 additions & 12 deletions contract/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BigNumber } from 'ethers';
import { ethers, network } from 'hardhat';

const chainName = network.name;
Expand All @@ -15,6 +16,11 @@ if (BASE_URI_PROD == null || BASE_URI_PROD === '') {
throw new Error('BASE_URI_STG is empty.');
}

const gasPrice =
process.env.GAS_PRICE != null && process.env.GAS_PRICE !== ''
? process.env.GAS_PRICE
: '50';

const baseURI = (() => {
if (chainName === 'mumbai') {
return BASE_URI_STG;
Expand All @@ -27,23 +33,18 @@ const main = async () => {
const contract = await ethers
.getContractFactory('WbydoProfileNft')
.then((factory) => {
return factory.deploy(baseURI);
return factory.deploy(baseURI, {
gasPrice: ethers.utils.parseUnits(gasPrice, 'gwei'),
type: 0,
gasLimit: BigNumber.from('1900000'),
});
})
.then((contract) => {
return contract.deployed();
});
const { address, deployTransaction } = contract;
console.log({ address, deployTransaction });

const receipt0 = await contract.mint(0).catch((err: unknown) => {
throw new Error(`${err}`);
});
console.log({ receipt0 });

const receipt1 = await contract.mint(1).catch((err: unknown) => {
throw new Error(`${err}`);
});
console.log({ receipt1 });
const { hash } = deployTransaction;
console.log({ address, hash });
};

main().catch((error: unknown) => {
Expand Down
54 changes: 54 additions & 0 deletions contract/scripts/mint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ethers, network } from 'hardhat';
import { BigNumber } from 'ethers';

const chainName = network.name;
if (chainName !== 'mumbai' && chainName !== 'polygon') {
throw new Error(`chainName: ${chainName}`);
}

const BASE_URI_STG = process.env.BASE_URI_STG;
if (BASE_URI_STG == null || BASE_URI_STG === '') {
throw new Error('BASE_URI_STG is empty.');
}

const BASE_URI_PROD = process.env.BASE_URI_PROD;
if (BASE_URI_PROD == null || BASE_URI_PROD === '') {
throw new Error('BASE_URI_STG is empty.');
}

const NFT_ADDRESS = process.env.NFT_ADDRESS;
if (NFT_ADDRESS == null || NFT_ADDRESS === '') {
throw new Error('NFT_ADDRESS is empty.');
}

const MINT_ID = process.env.MINT_ID;
if (MINT_ID == null || MINT_ID === '') {
throw new Error('MINT_ID is empty.');
}

const gasPrice =
process.env.GAS_PRICE != null && process.env.GAS_PRICE !== ''
? process.env.GAS_PRICE
: '50';

const main = async () => {
const nft = (await ethers.getContractFactory('WbydoProfileNft')).attach(
NFT_ADDRESS
);

const receipt = await nft
.mint(MINT_ID, {
gasPrice: ethers.utils.parseUnits(gasPrice, 'gwei'),
type: 0,
gasLimit: BigNumber.from('150000'),
})
.catch((err: unknown) => {
throw new Error(`${err}`);
});
console.log({ receipt });
};

main().catch((error: unknown) => {
console.error(`${error}`);
process.exit(1);
});
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"compile": "npm run clean && npx -w contract hardhat compile",
"clean": "npx -w contract hardhat clean",
"deploy:stg": "npx -w contract hardhat run scripts/deploy.ts --network mumbai",
"deploy:prod": "npx -w contract hardhat run scripts/deploy.ts --network mumbai"
"deploy:prod": "npx -w contract hardhat run scripts/deploy.ts --network polygon",
"mint:stg": "npx -w contract hardhat run scripts/mint.ts --network mumbai",
"mint:prod": "npx -w contract hardhat run scripts/mint.ts --network polygon"
},
"devDependencies": {
"cross-env": "^7.0.3",
Expand Down

0 comments on commit 86509aa

Please sign in to comment.