forked from zunxbt/Abstract-Chain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabstract.sh
150 lines (130 loc) · 5 KB
/
abstract.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
curl -s https://raw.githubusercontent.com/zunxbt/logo/main/logo.sh | bash
sleep 3
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
PINK='\033[1;35m'
YELLOW='\033[1;33m'
show() {
case $2 in
"error")
echo -e "${PINK}${BOLD}❌ $1${NORMAL}"
;;
"progress")
echo -e "${PINK}${BOLD}⏳ $1${NORMAL}"
;;
*)
echo -e "${PINK}${BOLD}✅ $1${NORMAL}"
;;
esac
}
install_dependencies() {
show "Installing Node.js..." "progress"
source <(wget -O - https://raw.githubusercontent.com/zunxbt/installation/main/node.sh)
clear
show "Initializing Hardhat project..." "progress"
npx hardhat init --yes
clear
show "Installing required dependencies..." "progress"
npm install -D @matterlabs/hardhat-zksync @matterlabs/zksync-contracts zksync-ethers@6 ethers@6
show "All dependencies installation completed."
}
compilation() {
show "Modifying Hardhat configuration..." "progress"
cat <<EOL > hardhat.config.ts
import { HardhatUserConfig } from "hardhat/config";
import "@matterlabs/hardhat-zksync";
const config: HardhatUserConfig = {
zksolc: {
version: "latest",
settings: {
enableEraVMExtensions: false,
},
},
defaultNetwork: "abstractTestnet",
networks: {
abstractTestnet: {
url: "https://api.testnet.abs.xyz",
ethNetwork: "sepolia",
zksync: true,
verifyURL: "https://api-explorer-verify.testnet.abs.xyz/contract_verification",
},
},
solidity: {
version: "0.8.24",
},
};
export default config;
EOL
mv contracts/Lock.sol contracts/HelloAbstract.sol
cat <<EOL > contracts/HelloAbstract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract HelloAbstract {
function sayHello() public pure virtual returns (string memory) {
return "Hey there, This smart contract is deployed with the help of @ZunXBT!";
}
}
EOL
npx hardhat clean
npx hardhat compile --network abstractTestnet
}
deployment() {
read -p "Enter your wallet private key (without 0x): " DEPLOYER_PRIVATE_KEY
mkdir -p deploy
cat <<EOL > deploy/deploy.ts
import { Wallet } from "zksync-ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-zksync";
export default async function (hre: HardhatRuntimeEnvironment) {
const wallet = new Wallet("$DEPLOYER_PRIVATE_KEY");
const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("HelloAbstract");
const tokenContract = await deployer.deploy(artifact);
console.log(\`Your deployed contract address : \${await tokenContract.getAddress()}\`);
}
EOL
}
deploy_contracts() {
read -p "How many contracts do you want to deploy? " CONTRACT_COUNT
> contracts.txt
for ((i = 1; i <= CONTRACT_COUNT; i++)); do
show "Deploying contract #$i..." "progress"
npx hardhat deploy-zksync --script deploy.ts
show "Contract #$i deployed successfully"
echo "------------------------------------"
read -p "Please enter the deployed contract address for contract #$i : " CONTRACT_ADDRESS
echo "$CONTRACT_ADDRESS" >> contracts.txt
done
}
verify_contracts() {
while IFS= read -r CONTRACT_ADDRESS; do
show "Verifying smart contract at address: $CONTRACT_ADDRESS..." "progress"
npx hardhat verify --network abstractTestnet "$CONTRACT_ADDRESS"
done < contracts.txt
}
menu() {
echo -e "\n${YELLOW}┌─────────────────────────────────────────────────────┐${NORMAL}"
echo -e "${YELLOW}│ Script Menu Options │${NORMAL}"
echo -e "${YELLOW}├─────────────────────────────────────────────────────┤${NORMAL}"
echo -e "${YELLOW}│ 1) Install Dependencies │${NORMAL}"
echo -e "${YELLOW}│ 2) Modify configuration & compile │${NORMAL}"
echo -e "${YELLOW}│ 3) Wallet Set Up │${NORMAL}"
echo -e "${YELLOW}│ 4) Deploy contract(s) │${NORMAL}"
echo -e "${YELLOW}│ 5) Verify contracts │${NORMAL}"
echo -e "${YELLOW}│ 6) Exit │${NORMAL}"
echo -e "${YELLOW}└─────────────────────────────────────────────────────┘${NORMAL}"
read -p "Enter your choice: " CHOICE
case $CHOICE in
1) install_dependencies ;;
2) compilation ;;
3) deployment ;;
4) deploy_contracts ;;
5) verify_contracts ;;
6) show "Exiting..." "progress"; exit 0 ;;
*) show "Invalid choice. Please try again." "error" ;;
esac
}
while true; do
menu
done