Athena -IDE- Atom-Part 2

Jae Nam
Jae Nam
Feb 16 · 4 min read

In this section we will show you how to set up the Athena IDE on ATOM, writing a test contract, account creation, performing transactions, and deploying and installing contracts. Read on to get started!

Installation Notes

  1. Install Atom here
  2. Install Package

Click Ctrl (Command on mac) + → Click Install → Search Athena-ide-atom → Click Install button.

After installation is complete, Click Packages → Click Athena IDE → Open Athena IDE Panel

Writing a Test Contract

After creating a test.lua file, copy the following contents:

function set(key, value)   
system.setItem(key, value)
end
function get(key)
return system.getItem(key)
end
abi.register(set)
abi.register_view(get)

This code is a contract to obtain and set the value of the state DB.

Account creation and transaction

You can set up a network and an account. In this example, we will test sending a tx using AERGO’s testnet.

Firstly, configure the network to be using the testnet. You can also add another network through ‘New’.

In order to send a contract, you need to create an account. You can create a new account by clicking the New button.

Click the copy button next to the account you created and head over to our faucet at https://faucet.aergoscan.io/ on your browser to deposit AERGO to your testnet address.

You can see 5 AERGO has been deposited after clicking the Sync button on the IDE.

Deploy and install contract

Here is how to deploy the contract on the blockchain network.

Smart contracts are programs that run on blockchain nodes. The operation of Contract is divided into the following: Deploy, Execute, and Query.

  • Deploy: Deploy the created contract
  • Execute: Change contract’s state DB by executing contract (modified through transaction)
  • Query: Query the state DB of the contract

In order to deploy, Compile first by pressing F7 or the Compile button.

To deploy, insert the argument into the compiled target and click the Deploy button. If you set the gas limit as 0, you can deploy as much as you’d like.

If the deployment is successful, the transaction hash and contract address will be displayed. The deployed contract information will be displayed at the bottom of the page.

To execute, enter the arguments and click on the function name. Here we will run the set function.

If you want to check the execution information, enter an argument and run the get function. Just run the function that says get.

Conclusion

So far, we have just written, deployed, and ran smart contracts with lua, the smart contract language provided by AERGO.

The IDE has many more features, such as checking for autocomplete and syntax errors.

For more information on how to run the IDE or to find information, go to the following link.

https://github.com/aergoio/athena-ide-atom — You don’t have permissions to view Try another account

For a guide to writing smart contracts in Lua, check out the following link.

https://docs.aergo.io/en/2.0/smart-contracts/lua/guide.html

Happy coding!

Also, if you have further technical questions in your journey, feel free to reach out to our developer at AERGO listed below.

Supported by:
Taeik Lim
Github: https://github.com/acktsap

Aergo blog

Enterprise-ready, open-source hybrid blockchain and…

Jae Nam

Written by

Jae Nam

Director of Business Development EMEA at Blocko

Aergo blog

Enterprise-ready, open-source hybrid blockchain and easy-to-use serverless cloud platform for building practical decentralized apps and business solutions.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade