Your First Smart Contract | Algorand Developer Portal

Your First Smart Contract

In Getting Ready To Build, you initialized a new AlgoKit project and selected the Hello World smart contract template.

This guide returns to that project and shows two ways to work with the contract:

By the end, you will:

Deploy the Contract with the Generated Script

Section titled “Deploy the Contract with the Generated Script”

You will notice in the smart_contracts/hello_world folder a file named deploy-config.ts which is a simple example of using AlgoKit to deploy the HelloWorld smart contract in contract.algo.ts on the LocalNet started earlier and then call the hello method.

Now there are two ways to run the deploy-config.ts file to deploy and call the smart contract:

  1. By hitting F5 it will start LocalNet, build the smart contract, deploy and call the smart contract contract.algo.ts by running the deploy-config.ts file.

  2. Alternatively, you can run the following commands from the terminal to build the contract and run the deploy-config.ts file:

algokit project run build

algokit project deploy localnet

The output should look similar to the following:

=== Deploying HelloWorld ===

Idempotently deploying app "HelloWorld" from creator RQGFSWXL2RKDBO53MN3ZRWCO3CP2HCZ6T4D5DMNJSIXRV76XAEBUJNHOMY using 86 bytes of AVM (Algorand Virtual Machine) bytecode and 4 bytes of AVM bytecode

App HelloWorld not found in apps created by RQGFSWXL2RKDBO53MN3ZRWCO3CP2HCZ6T4D5DMNJSIXRV76XAEBUJNHOMY; deploying app with version 1.0.

App created by RQGFSWXL2RKDBO53MN3ZRWCO3CP2HCZ6T4D5DMNJSIXRV76XAEBUJNHOMY with ID 2225 via transaction PSO2XD77YINZRSNH5X76EN6QZYC2I3P6NITJQCCSDS7IC2PJ4RYA

Sending 1000000 µALGO from RQGFSWXL2RKDBO53MN3ZRWCO3CP2HCZ6T4D5DMNJSIXRV76XAEBUJNHOMY to JM7DKIZGR3M4EGZYYR7LXUDX3R7X6QLRV4S2YVLTSDZP73XLX5A6ZDAQLE via transaction T66O4VNOD5CV6RZ75J53PHFMIIX2DCGT2Q3VM7W3W4CJ7DJQK6MA

App 2225 called with hello(world) by RQGFSWXL2RKDBO53MN3ZRWCO3CP2HCZ6T4D5DMNJSIXRV76XAEBUJNHOMY via transaction W2ZQYBEAFXDKHWDBBKJ6WC56ASAQ267ZEHYESWYLZP3YT3AACMGQ

Called hello on HelloWorld (2225) with name = world, received: Hello, world

The deployed application’s App ID and application address are displayed, followed by the message returned from the smart contract call.

When AlgoKit builds the smart contract, it generates artifacts in the artifacts folder. These artifacts include:

AlgoKit Starter Artifacts

Tools like LORA and goal can use these artifacts to deploy and interact with your smart contract across Algorand networks.

Once the starter project is created, you will notice in the smart_contracts/hello_world folder a file named deploy_config.py which is a simple example of using AlgoKit to deploy the HelloWorld smart contract in contract.py on the Local Algorand blockchain started earlier and then call the hello method.

AlgoKit Starter config

Now there are two ways to run the deploy_config.py file to deploy and call the smart contract:

  1. By hitting F5 it will start LocalNet, build the smart contract, deploy and call the smart contract contract.py by running the deploy_config.py file.

  2. Alternatively, you can run the following commands from the terminal to build the contract and run the deploy_config.py file:

algokit project run build

algokit project deploy localnet

The output should look similar to the following:

Deploying hello_world

Called hello on HelloWorld (2225) with name=world, received: Hello, world

The App ID of of the deployed contract is displayed, followed by the message returned from the smart contract call.

When AlgoKit builds the smart contract, it generates artifacts in the artifacts folder. These artifacts include:

AlgoKit Starter Artifacts

Deploy Hello World application

Section titled “Deploy Hello World application”

The generated deployment script is the fastest way to deploy and test your contract from code. Next, you’ll use LORA to see the same contract workflow through a visual interface.

This is useful when you want to inspect app specs, build calls manually, or understand what the deployment process is doing under the hood.

Launch LORA:

algokit explore
  1. To deploy your smart contract application, select the App Lab and click on the Create button.

    LORA: App Lab

  2. Click Deploy new and click Select an ARC-32 JSON app spec file. This opens a window for you to browse to the artifacts created in the previous section of this guide. Select the HelloWorld.arc32.json manifest file.

    LORA: Deploying your appLORA: ARC-32/ARC-56 App SpecLORA: Uploading generated app spec

  3. This will load the specific manifest file for the Hello World sample application. Click Next.

    LORA: App spec uploaded successfully

  4. You can change the Name and the Version of your app. For this guide we’ll keep the default values. Click Next.

    LORA: Specify app name and version

  5. Click the () Call button. Then build and add the create transaction by clicking Add.

    LORA: Transaction builderLORA: Create new transaction

  6. Click Deploy and sign the transaction by clicking OK in the KMD (Key Management Daemon) popup to deploy the smart contract to LocalNet.

    LORA: Transaction created

  7. You should now see the deployed HelloWorld contract on the App Lab page.

    LORA: Your app is now deployed

Call the hello Method

Section titled “Call the hello Method”

With the application deployed, you can now begin interacting with it.

  1. Click on the App ID inside the HelloWorld card to go to the Application page.

    LORA: Inspecting your on-chain app

  2. Inside the ABI Methods section, you should see the hello method. Click on the dropdown and the Call button. You will be prompted with a popup allowing you to enter the parameter for the hello method and call it.

    LORA: ABI methods

  3. Enter a string in the value input and click on Add.

    LORA: Method arguments

  4. You should now see the transaction you just built on the Application page. Click Send and sign the transaction with your KMD wallet to execute the transaction.

    LORA: Sending the transaction

  5. You should now see the Send Result showing you the details about the transaction you just executed!

    LORA: Transaction results

  6. You can also click on Transaction ID to go to the Transaction page and see the full transaction details.

    LORA: Inspect transaction details

Next steps

Section titled “Next steps”

You have now deployed a smart contract, called one of its methods, and inspected the result in LORA.

You are ready to move beyond the Hello World template and start building your own Algorand applications.