generated from bitcoin-sv/template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquickstart.sh
66 lines (51 loc) · 1.74 KB
/
quickstart.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
#!/bin/bash
set -e
# Install backend dependencies and configure backend
echo "Installing backend dependencies..."
cd back
npm install
npm i -g @bsv/sdk
echo "Generating Bitcoin WIF..."
wif=$(node <<'EOF'
const { PrivateKey } = require('@bsv/sdk');
// Generate a new random private key
const privateKey = PrivateKey.fromRandom();
// Print the Wallet Import Format (WIF) of the private key
console.log(privateKey.toWif());
EOF
)
echo "Generated Private Key: $wif"
mkdir -p .wifs
timestamp=$(date +%Y%m%d%H%M%S)
echo "$wif" > ".wifs/private_wif_${timestamp}.txt"
echo "Generating SHA256 hash of the WIF..."
callback=$(echo -n "$wif" | sha256sum | awk '{print $1}')
echo "Generated SHA256 Token: $callback"
echo "Creating .env file in back directory..."
cat <<EOF > .env
PORT=3030
FUNDING_WIF=$wif
MONGO_URI=mongodb://localhost:27017 # this will work if you're running a mongodb community service locally, otherwise use a remote connection string
DOMAIN=<your-domain.com> # where you'll receive callbacks with merkle paths from ARC
CALLBACK_TOKEN=$callback # to make sure you don't accept callbacks from abyone else
NETWORK=test # test | main
DB_NAME=truth-machine
EOF
echo "Updating FUNDING_WIF in docker-compose.yml..."
sed -i '' "s|FUNDING_WIF:.*|FUNDING_WIF: \"${wif}\"|" ../docker-compose.yml
cd ..
# Install frontend dependencies and configure frontend
echo "Installing frontend dependencies..."
cd front
npm install
echo "Creating .env file in front directory..."
cat <<EOF > .env
VITE_API_URL=http://localhost:3030 # update this if you're running the api on some domain
EOF
cd ..
# optionally build the images if you've changed the code
# echo "Building Docker images..."
# docker compose build
# Run the demo
echo "Starting Docker containers..."
docker compose up