hardhat/builtin-tasks/task-names#TASK_NODE TypeScript Examples
The following examples show how to use
hardhat/builtin-tasks/task-names#TASK_NODE.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: run-local.ts From nouns-monorepo with GNU General Public License v3.0 | 5 votes |
task(
'run-local',
'Start a hardhat node, deploy contracts, and execute setup transactions',
).setAction(async (_, { ethers, run }) => {
await run(TASK_COMPILE);
await Promise.race([run(TASK_NODE), new Promise(resolve => setTimeout(resolve, 2_000))]);
const contracts = await run('deploy-local');
await run('populate-descriptor', {
nftDescriptor: contracts.NFTDescriptor.instance.address,
nounsDescriptor: contracts.NounsDescriptor.instance.address,
});
await contracts.NounsAuctionHouse.instance
.attach(contracts.NounsAuctionHouseProxy.instance.address)
.unpause({
gasLimit: 1_000_000,
});
await run('create-proposal', {
nounsDaoProxy: contracts.NounsDAOProxy.instance.address,
});
const { chainId } = await ethers.provider.getNetwork();
const accounts = {
'Account #0': {
Address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
'Private Key': '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
},
'Account #1': {
Address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
'Private Key': '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',
},
};
console.table(accounts);
console.log(
`Noun contracts deployed to local node at http://localhost:8545 (Chain ID: ${chainId})`,
);
console.log(`Auction House Proxy address: ${contracts.NounsAuctionHouseProxy.instance.address}`);
console.log(`Nouns ERC721 address: ${contracts.NounsToken.instance.address}`);
console.log(`Nouns DAO Executor address: ${contracts.NounsDAOExecutor.instance.address}`);
console.log(`Nouns DAO Proxy address: ${contracts.NounsDAOProxy.instance.address}`);
await ethers.provider.send('evm_setIntervalMining', [12_000]);
await new Promise(() => {
/* keep node alive until this process is killed */
});
});
Example #2
Source File: index.ts From hardhat-deploy with MIT License | 5 votes |
task(TASK_NODE, 'Starts a JSON-RPC server on top of Hardhat EVM')
.addOptionalParam('export', 'export current network deployments')
.addOptionalParam('exportAll', 'export all deployments into one file')
.addOptionalParam(
'tags',
'specify which deploy script to execute via tags, separated by commas',
undefined,
types.string
)
.addOptionalParam(
'write',
'whether to write deployments to file',
true,
types.boolean
)
.addOptionalParam(
'gasprice',
'gas price to use for transactions',
undefined,
types.string
)
.addOptionalParam('maxfee', 'max fee per gas', undefined, types.string)
.addOptionalParam(
'priorityfee',
'max priority fee per gas',
undefined,
types.string
)
// TODO --unlock-accounts
.addFlag('noReset', 'do not delete deployments files already present')
.addFlag('noImpersonation', 'do not impersonate unknown accounts')
.addFlag('silent', 'whether to renove log')
.addFlag('noDeploy', 'do not deploy')
.addFlag('watch', 'redeploy on every change of contract or deploy script')
.setAction(async (args, hre, runSuper) => {
if (args.noImpersonation) {
deploymentsManager.disableAutomaticImpersonation();
}
nodeTaskArgs = args;
if (!isHardhatEVM(hre)) {
throw new HardhatPluginError(
`
Unsupported network for JSON-RPC server. Only hardhat is currently supported.
hardhat-deploy cannot run on the hardhat provider when defaultNetwork is not hardhat, see https://github.com/nomiclabs/hardhat/issues/1139 and https://github.com/wighawag/hardhat-deploy/issues/63
you can specifiy hardhat via "--network hardhat"
`
);
}
deploymentsManager.runAsNode(true);
// console.log('node', args);
await runSuper(args);
});