Skip to content

Commit

Permalink
Adding local deployment script (#16)
Browse files Browse the repository at this point in the history
Adding local deployment script the DIDRegistry contract


---------

Authored-by: Robert Leonard 
Reviewed-by: Martin Riedel
  • Loading branch information
Robert-H-Leonard authored Sep 25, 2023
1 parent c5b15fe commit 636fed8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,4 @@ Deployments are manually triggered via a github action. Before deployments pleas


#### Local deployment
To deploy locally you must have the following enviornment variables in your `.env` file:

- `DEFENDER_KEY` and `DEFENDER_SECRET`
- `DEFENDER_RELAY_KEY` and `DEFENDER_RELAY_SECRET`

- `EXPLORER_API_KEY`: Needed for contract source code verification

- `DID_REGISTRY_PROXY_ADDRESS`: Target address for upgrades and ownership changes
- `GNOSIS_ADDRESS`: Multi-sig wallet address that will become owner of deployed contracts

- `BNB_TESTNET_RPC_URL`: Needed for bnb testnet deployments
- `BNB_RPC_URL`: Needed for bnb mainnet deployments

Once these are configured you can run any of the deployment/upgrade scripts inside the `package.json` scripts.
To deploy locally you first start the anvil node by running `anvil`, then you can run the local deployment script `npm run local-deployment` or `yarn local-deployment`
3 changes: 3 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const config: HardhatUserConfig = {
bnbSmartChain: {
url: process.env.BNB_RPC_URL!,
chainId: 56,
},
local: {
url: 'http://127.0.0.1:8545'
}
},
etherscan: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"repository": "[email protected]:identity-com/did-bnb.git",
"license": "MIT",
"scripts": {
"local-deployment": "npx hardhat run --network local scripts/deployLocally.ts",
"testnet-deploy-and-verify-contract": "npx hardhat run --network testnetBnb scripts/deployProxy.ts",
"testnet-upgrade-and-verify-contract": "npx hardhat run --network testnetBnb scripts/upgradeProxyImplementation.ts",
"mainnet-deploy-and-verify-contract": "npx hardhat run --network bnbSmartChain scripts/deployProxy.ts",
Expand Down
29 changes: 29 additions & 0 deletions scripts/deployLocally.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ethers } from "hardhat";

export const DETERMINISTIC_ADDRESS = "0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B";

async function main() {
//@ts-ignore

const deployment = await ethers.deployContract("DIDRegistry", []);

const deployedAddress = await deployment.getAddress();

const bytecode = await deployment.getDeployedCode();

console.log(`Did Registry deployed at: ${deployedAddress}`);

await ethers.provider.send('anvil_setCode',[
DETERMINISTIC_ADDRESS,
bytecode
])

console.log(`Did Registry deployed at deterministic address: ${DETERMINISTIC_ADDRESS}`);

}


main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

0 comments on commit 636fed8

Please sign in to comment.