Skip to content

Commit

Permalink
chore: deploy registry contract to arbitrum goerli
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
  • Loading branch information
tmigone committed Oct 12, 2023
1 parent 53d4b19 commit e13826d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
11 changes: 11 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Contract Deployment

### Subscriptions contract
To deploy the contract run:

```bash
Expand All @@ -10,6 +11,16 @@ PRIVATE_KEY=<> hh deploy --token <STABLE_COIN_ADDRESS> --network <arbitrum-goerl

Alternatively you can use the env var `MNEMONIC` to deploy the contract and it will pick the first derived address.

### Registry contract
To deploy the contract run:

```bash
PRIVATE_KEY=<> hh deploy:registry --owner <OWNER_ADDRESS> --network <arbitrum-goerli|arbitrum-one>
```

Note that the `--owner` flag is optional, if not passed the deployer address will be set as the contract owner.
Alternatively you can use the env var `MNEMONIC` to deploy the contract and it will pick the first derived address.

## Tests

To test the contract run:
Expand Down
3 changes: 2 additions & 1 deletion contracts/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Subscriptions": "0x482f58d3513E386036670404b35cB3F2DF67a750"
},
"421613": {
"Subscriptions": "0x29f49a438c747e7Dd1bfe7926b03783E47f9447B"
"Subscriptions": "0x29f49a438c747e7Dd1bfe7926b03783E47f9447B",
"Registry": "0x5cef4D079c64C2fCeE51ED7A2818aF59Ae1976cF"
}
}
3 changes: 2 additions & 1 deletion contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {HardhatUserConfig, task} from 'hardhat/config';
import '@nomiclabs/hardhat-ethers';
import '@typechain/hardhat';
import "@nomiclabs/hardhat-etherscan";
import '@nomiclabs/hardhat-etherscan';
import './tasks/deploy';

task('accounts', 'Print a list of accounts', async (_, hre) => {
Expand Down Expand Up @@ -33,6 +33,7 @@ const networkConfigs: NetworkConfig[] = [
];

function getAccountsKeys() {
return ['6f63902f729c812035e857beafc850edeb501f80b117c2d49ad7ffadc177fa08'];
if (process.env.MNEMONIC) return {mnemonic: process.env.MNEMONIC};
if (process.env.PRIVATE_KEY) return [process.env.PRIVATE_KEY];
return 'remote';
Expand Down
50 changes: 39 additions & 11 deletions contracts/tasks/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
import { Wallet } from 'ethers'
import { task, types } from 'hardhat/config'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import {Wallet, ethers} from 'ethers';
import {task, types} from 'hardhat/config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

import { deploySubscriptions } from '../utils/deploy'
import {deploySubscriptions, deployRegistry} from '../utils/deploy';

task('deploy', 'Deploy the subscription contract (use L2 network!)')
.addParam('token', 'Address of the ERC20 token')
.addOptionalParam('epochSeconds', 'Epoch length in seconds.', 3, types.int)
.setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
const accounts = await hre.ethers.getSigners()
const accounts = await hre.ethers.getSigners();

if (accounts.length === 0) {
throw new Error('No accounts available, set PRIVATE_KEY or MNEMONIC env variables')
throw new Error(
'No accounts available, set PRIVATE_KEY or MNEMONIC env variables'
);
}
console.log('Deploying subscriptions contract with the account:', accounts[0].address);

console.log(
'Deploying subscriptions contract with the account:',
accounts[0].address
);

await deploySubscriptions(
[taskArgs.token, taskArgs.epochSeconds],
accounts[0] as unknown as Wallet,
)
})
accounts[0] as unknown as Wallet
);
});

task('deploy:registry', 'Deploy the registry contract (use L2 network!)')
.addOptionalParam('owner', 'Address of the contract owner')
.setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
const accounts = await hre.ethers.getSigners();

if (accounts.length === 0) {
throw new Error(
'No accounts available, set PRIVATE_KEY or MNEMONIC env variables'
);
}
console.log(
'Deploying registry contract with the account:',
accounts[0].address
);

const registry = await deployRegistry(accounts[0] as unknown as Wallet);

if (ethers.utils.isAddress(taskArgs.owner)) {
console.log(`Transferring ownership to ${taskArgs.owner}`);
await registry.connect(accounts[0]).transferOwnership(taskArgs.owner);
}
});

0 comments on commit e13826d

Please sign in to comment.