Skip to content

Commit

Permalink
add contracts tool
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCardinalError committed Dec 4, 2024
1 parent f11e048 commit 20e90ff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tasks/contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { task } from 'hardhat/config';
import fs from 'fs';
import path from 'path';

task('contracts', 'Display contract deployment information')
.addParam('target', 'Network type (main or test)')
.setAction(async (taskArgs: { target: string }) => {
const networkType = taskArgs.target.toLowerCase();

if (networkType !== 'main' && networkType !== 'test') {
throw new Error('Network parameter must be either "main" or "test"');
}

const fileName = networkType === 'main' ? 'mainnet_deployed.json' : 'testnet_deployed.json';

// Read JSON file
const filePath = path.join(__dirname, '..', fileName);
const fileContent = fs.readFileSync(filePath, 'utf8');
const deploymentData = JSON.parse(fileContent);

// Extract and display contract information
console.log(`\nDeployed Contracts (${networkType})`);
console.log('========================');

Object.entries(deploymentData.contracts).forEach(([name, data]: [string, any]) => {
console.log(`\n${name}:`);
console.log(`Address: ${data.address}`);
console.log(`Explorer: ${data.url}`);
});
});
1 change: 1 addition & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './signatures';
export * from './copybatch';
export * from './contracts';

0 comments on commit 20e90ff

Please sign in to comment.