Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

EgorMajj
EgorMajj

Posted on

     

Aleo Testnet - Deploy a Smart Contract

Step 1: Create a new Aleo wallet in seconds:

• Already have a wallet? Skip this step ✅
• Visithttps://aleo.tools/ and click "Generate" to create a secure wallet. Save the output 🔒

Finally, use your keys to add variables to your server with these commands

Image description

Step 2: Get tokens for your wallet

Simply text +1-867-888-5688 with the format below and receive 50 credits instantly.

Send: "50 credits to aleo1jjjnu3xk05h239ak5w2x5ejfh6del0whpe7pgya0pu00cp4pn5yq40ykus"

Step 3: Grab packages and start a slick tmux session.

sudoaptupdate&&\sudoaptinstallmakeclangpkg-configlibssl-devbuild-essentialgccxz-utilsgitcurlvimtmuxntpjqllvmufw-y&&\tmuxnew-sdeploy
Enter fullscreen modeExit fullscreen mode

Building a binary requires creating a tmux session, which may take some time. But don't worry - if your ssh connection is lost, you won't have to rebuild everything. Just reconnect to your existing tmux session and pick up where you left off.

Step 4: Add your wallet and private key as a variable.

echoEnteryourPrivateKey:&&readPK&&\echoEnteryourViewKey:&&readVK&&\echoEnteryourAddress:&&readADDRESS
Enter fullscreen modeExit fullscreen mode

Step 5: Make sure the data is correct. If not, you can do step 4 again.

echoPrivateKey:$PK&&\echoViewKey:$VK&&\echoAddress:$ADDRESS
Enter fullscreen modeExit fullscreen mode

Once you get a message from the bot confirming your wallet has been replenished, head tohttps://faucet.aleo.org/ and double-check the transaction went through.

Use the Transaction ID as the answer when using the following command.

echoEnteryourTransactionID:&&readTI
Enter fullscreen modeExit fullscreen mode
CIPHERTEXT=$(curl-shttps://vm.aleo.org/api/testnet3/transaction/$TI | jq -r '.execution.transitions[0].outputs[0].value')
Enter fullscreen modeExit fullscreen mode

Step 6: Install required software

cd$HOMEgitclonehttps://github.com/AleoHQ/snarkOS.git --depth 1cdsnarkOSbash./build_ubuntu.shsource$HOME/.bashrcsource$HOME/.cargo/env
Enter fullscreen modeExit fullscreen mode
cd$HOMEgitclonehttps://github.com/AleoHQ/leo.gitcdleocargoinstall--path.
Enter fullscreen modeExit fullscreen mode

Step 7: Deploy a contract

NAME=helloworld_"${ADDRESS:4:6}"mkdir$HOME/leo_deploycd$HOME/leo_deployleonew$NAME
Enter fullscreen modeExit fullscreen mode
RECORD=$(snarkosdeveloperdecrypt--ciphertext$CIPHERTEXT--view-key$VK)
Enter fullscreen modeExit fullscreen mode
snarkosdeveloperdeploy"$NAME.aleo"\--private-key"$PK"\--query"https://vm.aleo.org/api"\--path"$HOME/leo_deploy/$NAME/build/"\--broadcast"https://vm.aleo.org/api/testnet3/transaction/broadcast"\--fee4000000\--record"$RECORD"
Enter fullscreen modeExit fullscreen mode

After executing the command, you should see a similar result.

root@DS-A-1:~/Leo_deploy# snarkos developer deploy "$NAME.aleo" --private-key "$PK" --query "https://vm.aleo.org/api" --path "$HOME/Leo_deploy/SNAME/build/" --broadcast "https://vm.aleo.org/api/testn
et3/transaction/broadcast" --fee 4000000 --record "$RECORD"
Creating deployment transaction for 'helloworld_1m3y73.aleo'...
Created deployment transaction for 'helloworld_1m3y73.aleo'
Successfully deployed helloworld_1m3y73.aleo' to https: //vm.aleo.org/api/testnet3/transaction/broadcast.

Use the resulting transaction hash to find your contract in Explorer:https://explorer.hamp.app/
If your contract shows up in Explorer, you can go to the next step.

Step 8: Execute a contract

Use the transaction hash as the answer for the following command.

echoEnteryourDeployhash:&&readDH
Enter fullscreen modeExit fullscreen mode
CIPHERTEXT=$(curl-shttps://vm.aleo.org/api/testnet3/transaction/$DH | jq -r '.fee.transition.outputs[].value')
Enter fullscreen modeExit fullscreen mode
RECORD=$(snarkosdeveloperdecrypt--ciphertext$CIPHERTEXT--view-key$VK)
Enter fullscreen modeExit fullscreen mode
snarkosdeveloperexecute"$NAME.aleo""hello""1u32""2u32"\--private-key$PK\--query"https://vm.aleo.org/api"\--broadcast"https://vm.aleo.org/api/testnet3/transaction/broadcast"\--fee1000000\--record"$RECORD"
Enter fullscreen modeExit fullscreen mode

After execution, you should see the following output

root@DS-A-1:~/leo_deploy# snarkos developer execute "$NAME.aleo" "hello" "1u32" "2u32" --private-key $PK --query "https://vm.aleo.org/api" --broadcast "https://vm.aleo.org/api/testnet3/transaction/br
oadcast"
--fee 1000000 --record "$RECORD"
w Creating execution transaction for 'helloworld_1m3y73.aleo'
© Created execution transaction for 'helloworld_1m3y73.aleo/hello'
© Successfully broadcast execution 'helloworld_1m3y73.aleo/hello' to thehttps://vm.aleo.org/api/testnet3/transaction/broadcast.

Use the resulting transaction hash to find your contract in Explorer:https://explorer.hamp.app/

Congratulations you have deployed the contract to Aleo!

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
apexdev profile image
Ashish
  • Joined

Great

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Discord: egormajj#0340
  • Joined

More fromEgorMajj

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp