Aleo Deploy and Execute Demo: deploying “Hello World!” on Aleo network
In this tutorial, you will learn how to deploy and execute a basic “Hello World!” program on the Aleo network using Leo and snarkOS. Aleo is a Layer-1 blockchain that offers unique features like Zero-Knowledge Proofs (ZKPs) and high scalability, making it an ideal platform for building privacy-centric decentralized applications (dApps).
By following this guide, you will gain hands-on experience in deploying and executing programs on the Aleo blockchain.
Usage Guide
1. Prerequisites. Before you begin, ensure you have both Leo and snarkOS installed on your machine. To verify their installations, open your terminal and type the following commands:
leo
snarkos
If you see command not found errors, you may need to install them using the instructions found here.
Optional: Install the JSON Beautifier & Editor Chrome extension for better visualization of JSON objects.
2. Generate Your Test Keys and Wallet Address. Go to Aleo Tools in your favorite browser and click the “Generate” button. Save your Address, View Key, and Private Key in a safe place, as you will need them later.
3a. Seeding Your Wallet with Credits. To seed your wallet with credits, you can request them from Aleo’s faucet at faucet.aleo.org. The faucet will send credits to your wallet, but it might take up to 5 minutes. While waiting for the credits, proceed to step 3b.
3b. Create a Leo Application. Let’s create a simple test Leo application to deploy. Open your terminal and execute the following commands:
cd $HOME/Desktop
mkdir demo_deploy_Leo_app && cd demo_deploy_Leo_app
WALLETADDRESS="" # Assign your wallet address here
APPNAME=helloworld_"${WALLETADDRESS:4:6}"
leo new "${APPNAME}"
cd "${APPNAME}" && leo run && cd -
4. Confirm the Aleo Faucet Sent Your Wallet Credits and Obtain the Ciphertext Record Value. By now, the Aleo faucet should have sent credits to your wallet. Verify your credit balance by decrypting the ciphertext record for the execute transfer that was sent to you. You can find this information in the transaction confirmation URL received after requesting credits from the faucet.
5. Obtain Your Records Plaintext. Navigate to Aleo Tools and click on the “Record” tab. Enter the ciphertext record you obtained in the previous step and your view key. Copy the plaintext record provided.
6. Deploy Your Test Application. Now that you have all the required details, it’s time to deploy your first Leo application. In your terminal, execute the following commands:
cd $PATHTOAPP && cd .. # Navigate to the path of your app
PRIVATEKEY="" # Assign your private key here
RECORD="" # Assign the plaintext record you obtained earlier here
snarkos developer deploy "${APPNAME}.aleo" --private-key "${PRIVATEKEY}" --query "https://vm.aleo.org/api" --path "./${APPNAME}/build/" --broadcast "https://vm.aleo.org/api/testnet3/transaction/broadcast" --fee 1000000 --record "${RECORD}"
You should see a confirmation of your Aleo application deployment in the form of a transaction ID.
7. Execute Your Test Application. Finally, it’s time to execute the application you just deployed. Update the --record
flag with the latest transaction linked to your wallet balance. You can find this information by going to the following URL: https://vm.aleo.org/api/testnet3/transaction/$DEPLOY_TX_ID and replacing $DEPLOY_TX_ID
with the transaction ID provided to you after your application was deployed.
Update the RECORD
variable with the plaintext record you decrypted in the previous steps. Then execute the following command in your terminal:
snarkos developer execute "${APPNAME}.aleo" "main" "1u32" "2u32" --private-key "${PRIVATEKEY}" --query "https://vm.aleo.org/api" --broadcast "https://vm.aleo.org/api/testnet3/transaction/broadcast" --fee 1000000 --record "${RECORD}"
Congratulations! You have successfully deployed and executed a Leo application on Testnet III. Have fun exploring the power of Aleo’s blockchain capabilities!
Conclusion. In this tutorial, we walked through the process of deploying and executing a “Hello World!” program on the Aleo network using Leo and snarkOS. Aleo’s unique features, such as Zero-Knowledge Proofs and scalability, make it an excellent choice for building privacy-centric decentralized applications. By following this guide, you gained valuable experience in interacting with the Aleo blockchain and witnessed the potential of this innovative platform. Now, armed with this knowledge, you are ready to explore further and build your own privacy-focused dApps on Aleo! Happy coding! 🚀
Prepared by Colliseum