-
Notifications
You must be signed in to change notification settings - Fork 3
Command Line Dapp Deployment Guidelines
This guide provides step-by-step instructions to upload and publish a DApp project using the command line.
-
Environment Variables:
-
JWT_TOKEN
: A token received after authorization. -
NAMESPACE
: The name of your project. -
PRIVATE_KEY
: The secret key linked to your Ethereum account. Keep it secure and never share it. -
API_URL
: The base endpoint. -
CONTRACT_ADDRESS
: The deployed contract address for your DApp. -
RPC_URL
: Set tooptimism-sepolia
.
Use the command
source .env
to make these variables available in your environment. -
-
Ensure that Node.js, Foundry, jq, and curl are preinstalled.
Your NAMESPACE
must meet the following requirements:
- Contain only lowercase letters, numbers, dashes (
-
), or underscores (_
). - Be between 3 and 30 characters long.
- Not start or end with a dash (
-
) or an underscore (_
).
To ensure your namespace is unique, execute the following command in the terminal:
curl -s -X POST "${API_URL}/api/unique-namespace" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"namespace":"'"$NAMESPACE"'"}' | jq -r '.unique'
To ensure your generated key is unique, execute the following command in the terminal:
curl -s -X POST "${API_URL}/api/unique-generated-key" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"key":"'"$NAMESPACE"'"}' | jq -r '.unique'
Mint a token for the namespace by running the following command:
cast send $CONTRACT_ADDRESS "safeMint(string)" "$NAMESPACE" \
--rpc-url $RPC_URL \
--private-key "$PRIVATE_KEY"
Generate a key pair for the namespace:
curl -s -X POST "${API_URL}/api/v0/key/gen?arg=$NAMESPACE&type=rsa" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "Content-Type: application/json" | jq
Build the project using:
npm run build
# or
yarn build
Alternatively, you can use any previously built project.
Generate a Content Addressable Archive (CAR) file by running the following command:
CAR_FILENAME=$(npx @synthetixio/synthetix-node-cargen ./dist/ ./out/)
Import the generated CAR file using the following command:
curl -s -X POST "${API_URL}/api/v0/dag/import?pin-roots=true" \
-H "Authorization: Bearer $JWT_TOKEN" \
-F "file=@$CAR_FILENAME" | jq
Ensure the car_files
directory contains the CAR file generated in the previous step.
Fetch the DAG content:
curl -s -X POST "${API_URL}/api/v0/dag/get?arg=<PASTE_ROOT_CID_HERE>" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "Content-Type: application/json" | jq
Note: Replace <PASTE_ROOT_CID_HERE>
with the actual Root CID (retrieved from the response of the dag/import
step).
Publish the name linked to the Root CID:
curl -s -X POST "${API_URL}/api/v0/name/publish?key=$KEY_NAME_HERE&arg=/ipfs/$ROOT_CID_HERE&ttl=10s" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "Content-Type: application/json" | jq
- Replace
$KEY_NAME_HERE
with the key name from thekey/gen
step (e.g.,nebula-forge
). - Replace
$ROOT_CID_HERE
with the Root CID from thedag/import
step.