TUTORIAL: Deploying a smart contract on mainnet network with "AEproject"
Overview
This tutorial will walk you through the process of deploying Sophia ML Smart contract on the æternity mainnet network with the AEproject tool. We will fund our account and finally deploy a HelloWorld contract.
Prerequisites
Before we go any further, please make sure you have followed the Deploying on Testnet tutorial.
Getting Tokens
Since we have created an account at the Deploying on Testnet tutorial, we will look at separate ways we can fund our account with tokens before we deploy our contract to the æternity mainnet network.
Superhero
Superhero is a P2P social platform that elevates the impact that sharing can have. You can earn AE easily on Superhero by publishing good content on the web. Learn more about Superhero at https://superhero.com.
Exchanges
Another way in which you can fund your account with AE tokens is through exchange platforms. Here you can trade from Fiat currencies to AE tokens or from other cryptocurrencies to AE tokens. Check out CoinMarketCap for more details on exchanges.
Local P2P
You can also purchase AE locally from an individual who is willing to sell. For this tutorial, I will make use of this method to fund our previously created account with 1AE.
Checking our balance
Let's check the balance of our account on the mainnet network with the following command in our account directory:
aecli account balance ./my-ae-account -u https://sdk-mainnet.aepps.com
and we have it:
✔ Enter your password … *****
Balance__________ 1000000000000000000
ID_______________ ak_2rBj4fHW6CEcP4w7gZn1ALsyFifrt8wiDECt7n2mpmefRYfnyH
Nonce____________ 1
Deploying HelloWorld contract on the mainnet network
Now Let's deploy our HelloWorld contract to the mainnet network using the secret key of our previously created and funded account with the following command:
aeproject deploy -n mainnet -s 336e2063e02d7886925aa9a106f85bc952e39ac974e40fa7490c0aab12b551c2f3606032c111eaacb784aa21f35534642ca1d198866285dc37832e1721ea1e47
The expected result should be similar to this:
===== Contract: HelloWorld.aes has been deployed at ct_27YfPckio77U6RJh9yisxidQZtegWmYQUxL5A8o8biQka7N4f1 =====
Your deployment script finished successfully!
Deployment Confirmation
AECLI
You can recheck your account balance to verify the deployment of the smart contract with the previous command. The output should be similar to this:
✔ Enter your password … *****
Balance_________ 999919987000000000
ID______________ ak_2rBj4fHW6CEcP4w7gZn1ALsyFifrt8wiDECt7n2mpmefRYfnyH
Nonce___________ 2
AE Studio
You can also verify the contract deployment on the mainnet network using the might AE Studio with the following steps:
- Head to AE Studio.
- Copy the HelloWorld Contract codes, and paste it as a new contract.
- Click the MAINNET button, and complete the authentication system with Superhero.
- Copy the contract address given to you after executing the
aeproject deploy
command. - Paste the contract address at the provided bar beside the Use at address: button, and click the button.
- Enter a name for the
say_hello
function, and click the Send Transaction button. - Click the Call Locally button for the
get_info
function.
Conclusion
Deploying smart contracts to the æternity mainnet network is nice and easy. In just a few minutes and with a few commands, one can deploy their desired contracts on the network. If you encounter any problems please check out the video tutorial on YouTube or contact us through the æternity dev Forum category.