Guide: How to Upload a Smart Contract on the Juno Chain

Welcome to this tutorial on deploying a smart contract to the Juno testnet. This guide will show you how to deploy and interact with a contract using CLI. For scripting using Rust, you can use [cw-orc

Preparation:

Required Materials: A computer with an internet connection, familiarity with GitHub, and basic knowledge of smart contracts.

Steps:

  1. Find an Example Smart Contract:

(Note: The steps here mainly involve browsing, no specific bash commands.)

In this tutorial we will be using https://github.com/Reecepbcups/cw-clock-exampl

  1. Connect to the Juno Testnet:

Check out our new video that shows you how to deploy a local env

https://github.com/Reecepbcups/cw-clock-example

  1. Create a Juno Wallet:

bash junod keys add MyWalletName

5. Claim junox Test Tokens:

Head to Juno Discord https://discord.com/invite/caEBtA4QDb and find FAUCET section. In there you can get some using the API provided and inputting the wallet address you created in the previous step. https://faucet.reece.sh/uni-6/JUNO_ADDRESS_HERE

6. Verify Token Receipt:

junod query bank balances [YOUR_WALLET_ADDRESS]

7. Configure the Juno Command Line:

bash junod config node [NODE_URL] 
junod config chain-id [CHAIN_ID] 
junod config gas auto 
junod config gas-prices 0.025ujuno

8. Deploy the Smart Contract:

Assuming you've downloaded clock_example.wasm to your current directory

junod tx wasm store clock_example.wasm --from MyWalletName --gas 1500000 --chain-id [CHAIN_ID]

9. Instantiate the Smart Contract:

Replace [CODE_ID] with the code ID obtained from the previous step e.g 3785

 junod tx wasm instantiate [CODE_ID] '{"count": 0}' --label "my-clock-instance" --from MyWalletName --amount 100ujuno

10. Interact with the Smart Contract:

Query the smart contract (replace [CONTRACT_ADDRESS] with the address from instantiation) junod query wasm contract [CONTRACT_ADDRESS]


junod tx wasm execute [CONTRACT_ADDRESS] '{"increment": {}}' --from MyWalletName --amount 10ujuno

Conclusion:

  • You've now successfully uploaded, instantiated, and interacted with a smart contract on the Juno testnet.

  • If you have further questions or ideas, join the Juno community on Discord, particularly the "developer lounge".


Note: Adjust the bash commands to fit your specific situation, and always double-check them, especially when working with real tokens or live environments.\

Last updated