Deploy app on the dstack-vmm

After the dstack-vmm is ready, you can deploy an app following these steps:

1. On-chain Registration

Registration Process

Deploy an App’s control contract AppAuth. Use the reference contract or develop your own implementing the IAppAuth interface.

Call KmsAuth.registerApp(appAuthAddress) to register and obtain the App Id.

git clone https://github.com/Dstack-TEE/dstack
cd dstack/kms/auth-eth
npm install
npx hardhat compile
export PRIVATE_KEY=<your eth private key here>
export KMS_CONTRACT_ADDRESS=0xFE6C45aE66344CAEF5E5D7e2cbD476286D651875
npx hardhat app:deploy --allow-any-device --network phala
Deploying proxy…
Waiting for deployment…
AppAuth Proxy deployed to: 0xD4a546B1C7e63CD4CeD314b2C90108e49191A915
Implementation deployed to: 0x5aC1671E1Df54994D023F0B05806821d6D84e086
Deployment completed successfully
Transaction hash: 0xceac2ac6d56a40fef903b947d3a05df42ccce66da7f356c5d54afda68277f9a9
Waiting for transaction 0xe144e9007208079e5e82c04f727d2383c58184e74d4f860e62557b5f330ab832 to be confirmed…
App registered in KMS successfully
Registered AppId: 0xA35b434eE853fdf9c2Bf48Fa1583Ac1332d50255

Important: Note the AppId - you’ll need this when deploying the CVM. If upgrading contracts in the future, backup the .openzeppelin/unknown-2035.json file.

2. Add App Compose Hash to Whitelist

Build app-compose.json and calculate its sha256 to get compose-hash. The compose hash can also be previewed in the dstack-vmm UI.

export PRIVATE_KEY=<your eth private key here>
export KMS_CONTRACT_ADDRESS=0xFE6C45aE66344CAEF5E5D7e2cbD476286D651875
npx hardhat app:add-hash --network phala --app-id 0xA35b434eE853fdf9c2Bf48Fa1583Ac1332d50255 0x44d9cb98aaa6ab11f5729fc7d6fd58117585e0e3fbec621612dcee6b2dfbcde5

3. Deploy Instances using dstack-vmm

Deployment Configuration

  • Select image dstack-0.4.2
  • Fill in the AppId from contract deployment
  • Memory requirement: ≥ 3G or exactly = 2G
App Deployment Interface

Access Your Application

After the app starts normally, click [Board] to access. You can find the connections to dstack-gateway nodes, meaning that the app is now reachable from the internet.

Application Dashboard

Deployment Complete!

You have successfully deployed a complete dstack infrastructure with KMS, Gateway, and VMM components. Your applications are now running in secure Trusted Execution Environments and accessible through the internet.