-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy_decryption_contracts_verbose.sh
executable file
·67 lines (60 loc) · 4.14 KB
/
deploy_decryption_contracts_verbose.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
#!/bin/bash
# Define colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
source ".env"
# Deploy IBE_HASHING
cd ibe-contract-hashing
echo -e "${YELLOW}Building the IBE_HASHING contract...${NC}"
cargo +nightly-2024-05-20 build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target=wasm32-unknown-unknown --release
echo -e "${YELLOW}Deploying the IBE hashing contract...${NC}"
outputIbehashing=$(cargo +nightly-2024-05-20 stylus deploy -e $rpc_url --private-key="$PRIVATE_KEY_1" --wasm-file=./target/wasm32-unknown-unknown/release/ibe-contract-hashing.wasm 2>/dev/null)
addressIbehashing=$(echo "$outputIbehashing" | grep "deployed code at address" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g')
echo -e "${GREEN}IBE_HASHING_CONTRACT_ADDRESS $addressIbehashing"
cd ..
# Deploy IBE_CONTRACT
cd ibe-contract
echo -e "${YELLOW}Building the IBE contract...${NC}"
cargo +nightly-2024-05-20 build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target=wasm32-unknown-unknown --release
echo -e "${YELLOW}Deploying the IBE contract...${NC}"
outputIbe=$(cargo +nightly-2024-05-20 stylus deploy -e $rpc_url --private-key="$PRIVATE_KEY_1" --wasm-file=./target/wasm32-unknown-unknown/release/ibe.wasm)
addressIbe=$(echo "$outputIbe" | grep "deployed code at address" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g')
echo -e "${GREEN}IBE_CONTRACT_ADDRESS $addressIbe"
echo -e "${YELLOW}Initializing the IBE contract...${NC}"
initialize_ibe_output=$(cast send $addressIbe "initialize(string)" $addressIbehashing --rpc-url $rpc_url --private-key $PRIVATE_KEY_1 2>&1)
echo "${initialize_ibe_output}"
echo -e "${YELLOW}Initialized the IBE contract"
cd ..
# Deploy CHACHA20_MAC
cd chacha20-contract-mac
echo -e "${YELLOW}Building the CHACHA20_MAC contract...${NC}"
cargo +nightly-2024-05-20 build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target=wasm32-unknown-unknown --release > /dev/null 2>&1
echo -e "${YELLOW}Deploying the CHACHA_20_MAC contract...${NC}"
outputmac=$(cargo +nightly-2024-05-20 stylus deploy -e $rpc_url --private-key="$PRIVATE_KEY_1" --wasm-file=./target/wasm32-unknown-unknown/release/chacha20mac.wasm 2>/dev/null)
addressmac=$(echo "$outputmac" | grep "deployed code at address" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g')
echo -e "${GREEN}CHACHA20_MAC_ADDRESS $addressmac"
cd ..
# Deploy CHACHA20_DECRYPTER
cd chacha20-contract-decrypter
echo -e "${YELLOW}Building the CHACHA20_DECRYPTER contract...${NC}"
cargo +nightly-2024-05-20 build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target=wasm32-unknown-unknown --release > /dev/null 2>&1
echo -e "${YELLOW}Deploying the CHACHA20_DECRYPTER contract...${NC}"
outputchachadecrypter=$(cargo +nightly-2024-05-20 stylus deploy -e $rpc_url --private-key="$PRIVATE_KEY_1" --wasm-file=./target/wasm32-unknown-unknown/release/chacha20.wasm 2>/dev/null)
addresschachadecrypter=$(echo "$outputchachadecrypter" | grep "deployed code at address" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g')
echo -e "${GREEN}CHACHA20_DECRYPTER_ADDRESS $addresschachadecrypter"
cd ..
# Deploy DECRYPTER
cd decrypter-contract
echo -e "${YELLOW}Building the DECRYPTER contract...${NC}"
cargo +nightly-2024-05-20 build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target=wasm32-unknown-unknown --release > /dev/null 2>&1
echo -e "${YELLOW}Deploying the DECRYPTER contract...${NC}"
outputdecrypter=$(cargo +nightly-2024-05-20 stylus deploy -e $rpc_url --private-key="$PRIVATE_KEY_1" --wasm-file=./target/wasm32-unknown-unknown/release/decrypter.wasm 2>/dev/null)
addressdecrypter=$(echo "$outputdecrypter" | grep "deployed code at address" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g')
echo -e "${GREEN}DECRYPTER_ADDRESS $addressdecrypter"
echo -e "${YELLOW}Initializing the decrypter contract...${NC}"
initialize_decrypter_output=$(cast send $addressdecrypter "initialize(string,string,string)" $addressIbe $addressmac $addresschachadecrypter --rpc-url $rpc_url --private-key $PRIVATE_KEY_1 2>&1)
echo "${initialize_decrypter_output}"
echo -e "${GREEN}Decrypter initialization completed successfully.${NC}"
cd ..