Algorder Account

Algorder
Algorder
5 min readJun 21, 2021

--

In this article, we will dive into some details about Algorder Account smart contract.

I Created my Algorder Account, where is my smart contract?

There are few ways to get the address of your Algorder Account smart contract. The easiest way is to click the Avalanche Explorer link below your account page.

An alternative way is getting your smart contract’s address directly from our main contract on Avalanche Explorer.

Algorder Main Contract:

From the above link you may reach to our verified Algorder smart contract.

  • Open the read contract tab
  • Enter your c-chain address to the getAccountContractAddress input. (red box) press query button.
  • Your Algorder Account Smart contract address will be printed in the blue box.

How do I verify my Account’s smart contract on Avalanche Network?

Algorder Main contract is already verified on the Avalanche Explorer. But your Algorder Account Smart Contract isn’t verified on the Avalanche Explorer. You could verify it with the steps below:
1) Open your smart contract page on Avalanche Explorer.

2)Open Code tab. Press verify & publish button.
3)Fill the fields as follows.
Contract Name: AlgorderAccount
Include nighly builds: No
Compiler: v0.8.4
EVM Version: default
Optimization: No

4) for the ”Enter the Solidity Contract Code” field, you may get the source code from the main Algorder smart contract.

Open the code tab and press the copy source code button. Then paste it to the ”Enter the Solidity Contract Code” field on your verify form.
5)Once you paste the code. Select “Try to fetch constructor arguments automatically” to Yes. And press verify & publish button.

6)Now you have your smart contract verified on the Avalanche Explorer.

Here is an example of a verified Algorder Account smart contract.
https://cchain.explorer.avax.network/address/0xBaa2A13C98D6Eb85318c5c7D14C6Acd97096Dd53/read-contract

Walkthrough the functions of Algorder Account Smart Contract

Read-only functions:
These functions can be called by anyone.

getOwner: It returns the owner of this smart contract. For your Algorder Account, it is your c-chain address. So you are the owner of your Algorder Account’s smart contract.

getOrdersLength: Number of active orders on your Algorder Account.

getOrder: Returns the parameters of the requested orderId.

checkOrderCondition: This method returns a boolean (true/false) depending on whether the condition of the requested orderId is met or not. This method is not checking your balance. It only checks whether the condition you entered for the order is met or not.

checkOrder: This method checks 3 things.
1) If the order’s condition is met
2) User has the necessary balance on his/her Algorder Account for the swap operation.
3) User has 0.1 Avax for the tip on his/her Algorder Account.
It returns true if all these 3 succeeds. It also means that an Algorthic could send this order to the Dex.

Write functions:

createOrder:

It saves a new order on your Algorder Account. This is a method that only the owner (you) could trigger. No one else can create an order to your Algorder account.

deleteOrder:

It deletes the requested order from your Algorder Account. Again only the owner (you) could trigger this function. No one else can delete an order from your Algorder account.

withdraw & withdrawToken:

These methods are for withdrawing AVAX (withdraw), and ERC-20 tokens (withdrawToken) from your Algorder Account. As you see these functions are also onlyOwner functions. This means that only the owner (you) could trigger these functions. No one else can withdraw any AVAX or tokens from your Algorder account.

sendOrder:

This is the only function on your smart contract that can be called by another person but you. What this function do is:

  • It sends the order to the dex.
  • Delete order from your Algorder Account. (so that it could not be sent again).
  • Send 0.1 AVAX tips to the person that called this function.

As you see in the first two lines of code of this function. There are 2 required conditions in order for executing this function.

  1. checkOrder read-only function must return true. It means that this order’s price condition is met. An Algorthic can’t send your order to dex if the condition isn’t met.
  2. The person who calls this function must have 10000 Algor tokens on his/her balance. This means that he/she is an Algorthic.

Summary

We designed and implemented our smart contract in a trustless and safety-first approach.
Even if the website is closed, the team is gone Algorder website is not available and things like that, you could always open your smart contract on Avalanche Explorer and withdraw your funds. It is not possible to steal your funds on your Algorder Account.
All of our code is publicly available on Avalanche Explorer. If you have any comments/feedback/questions/bugs you see in our code or system. Please reach us on our discord channel/Twitter.

Thanks

--

--