In this article, we will discuss how to manage your staking on the Aurora Validator. To recap quickly, Aurora is an EVM-compatible blockchain running as an L2 on the Near Protocol. In the heart of it is an Aurora Engine smart contract. That is why every transaction on Aurora is relayed to the Near and has the corresponding Near transaction. You can read more about this here. That is why Aurora doesn’t have its own validators – we’re just re-using the Near ones.

In January 2023, we re-launched our validator with a new address, aurora.pool.near. What is curious about it is that it gives you the rewards in AURORA tokens directly on the Near network.

Recently, the Near Wallet was deprecated on the 1st of January, 2024. And that has driven users to other wallets. Unfortunately, many of these don’t support staking capabilities, especially with the non-standard validator as `aurora.pool.near` is. 

So, based on the recent support experience, we have decided to publish a guide on how to use your terminal on your laptop or PC to manage your staking on the Aurora’s Validator. Let’s look into the details now!

Installing `near-cli-rs`

Near CLI is your human-friendly companion that helps to interact with Near Protocol from the terminal right away. There are multiple ways to install it, see here. I am using Mac, so I will choose the first option and execute in my Terminal:

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh 

You can also run it as an npm package:

npx near-cli-rs 

After installation, if you execute near command you should be able to see this screen:

Connecting your account

Now, let's connect your account to the near-cli-rs. To do this, execute the near command and choose the account option, which you've seen in the previous screenshot above, using the Enter key.

You will see the next screen saying What do you want to do with an account?. Choose the import-account option there and press Enter:

You will see a screen with different import options:

Choose one that fits you! I will try to use using-web-wallet option. The browser window with https://app.mynearwallet.com/ will be opened, and you will see a popup asking for your permission to connect:

Click the Connect button to approve. After that, you will need to confirm this choice by typing your full account name into the popup:

Then, you will get the next alert about successful authorization:

Now, you can go back to your terminal window, and you will see a message asking you to enter your account name again:

Enter it there and press Enter. After that, choose a keychain to store your keys. I am choosing the first option there:

You will get the final message that `... access key is saved in the keychain` and a console command that can replace this manual process of choosing different options in the future:

So, all of the things we did here could be achieved also with this command:

near account import-account using-web-wallet network-config mainnet

That is great! As you can see, near-cli-rs is teaching you the terminal commands automatically while exploring it!

You have added your Near account to near-cli-rs, and it is now ready to be used.
Let's try it to stake some tokens on the Aurora Validator!

Staking tokens

TLDR: to stake your tokens, you need to use the next command:

near staking delegation karkunow.near \
     deposit-and-stake '1 NEAR' \
     aurora.pool.near network-config mainnet \
     sign-with-keychain send

Let's review the rest of the section to learn the details about how it works with near-cli.

First, make sure you know what validator you will use to stake. You can check the list of validators with this command:

near staking validator-list network-config mainnet

I, of course, will use aurora.pool.near for this demo.

To stake your tokens, start with executing the near command and choosing the staking option from the list:

Now, choose delegation:

And type your Near account into the console and press Enter. In my case, I have it already listed, so I will just choose mine from the list:

After that, you need to choose deposit-and-stake (not just stake or stake-all, these options won't work if your tokens were not deposited to the validator yet):

Then, enter the amount of NEAR tokens to be staked, I am entering 1NEAR for the purpose of this demo:

Now, type in your validator address or choose from the list (you can use the tab key to autocomplete):

Choose the network now, I will opt for the mainnet:

After this, you will see your transaction formed and ready to be signed. By default, I am signing it with my keychain:

Now, you can send the transaction and execute it:

You will see the transaction ID and a link to the Explorer after the successful execution:

We can visit the Explorer link to see the details of the transaction:

Unstaking tokens

TLDR: You just need to use the next command, which is really similar to the one used for staking:

near staking delegation karkunow.near \
     unstake-all \
     aurora.pool.near network-config mainnet \
     sign-with-keychain send

If you don't want to unstake all the funds, just use the unstake option and enter the amount of NEAR tokens you want to get back.

Now, let's go through a few screenshots to understand better how I got this command from the near-cli-rs. As we have learned from the previous section, to manage our staking activities, we just execute:

near staking delegation <your account here>

Now, if you want to unstake your tokens – just choose the unstake-all or unstake option from the list:

After that, you will be guided through the same screens as for the staking to enter the amount, validator address, network config (mainnet or testnet), and then – sign and send it. After the execution, you will see:

Exactly the same command will be formed by near-cli-rs after that process. So now, you can use this shortcut instead.

After unstaking, you will need to wait for the 4 epochs on Near blockchain to pass, which will take around 50-60 hours of time. And then, you will be ready to withdraw them and the associated rewards. The rewards will be automatically unlocked together with the unstaked tokens.

Withdrawing tokens

I won't go into details with the screenshots here. Now, we're ready just to use the commands.

So, to withdraw your tokens and rewards, you need to execute this:

near staking delegation karkunow.near \
     withdraw-all \
     aurora.pool.near network-config mainnet \
     sign-with-keychain send

If you don't want to withdraw all the funds, just use `withdraw` and enter the amount of NEAR tokens you want to withdraw.

After the execution, you will see:

Claiming on Aurora's validator

Aurora's validator allows you to farm the AURORA tokens instead of NEAR by staking NEAR on it. It is based on this smart contract. That is the reason why you need to use another way to claim these rewards in AURORA tokens. Can we do it with near-cli-rs? Yes! Let's see how it is done.

I will use two variables to track the staking pool and account:

export STAKINGCONTRACT=aurora.pool.near && \
export MYACCOUNT=karkunow.near

To track how much tokens you have right now in staking you should execute:

near contract call-function as-read-only aurora.pool.near \
     'get_unclaimed_reward' json-args \
     '{"account_id":"'${MYACCOUNT}'", "farm_id":0}' \
      network-config mainnet now

You will see the something similar to the next screen:

The value will be in Wei, so you need to convert it to get the real value of 0.0032 AURORA by multiplying it with 10^-18.

To claim your rewards you need to call the claim method on aurora.pool.near contract:

near contract call-function as-transaction aurora.pool.near \
     'claim' json-args \
     '{"account_id": "'${MYACCOUNT}'", \
       "token_id": "aaaaaa20d9e0e2461697782ef11675f668207961.factory.bridge.near"}' \
     prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' \
     sign-as karkunow.near /
     network-config mainnet /
     sign-with-keychain / 
     send

We're passing the account and NEP-141 AURORA token address to the contract's claim method. Also we attach 100TGas of gas and deposit 1 yoctoNear to it.

After the execution, you will get the transaction hash, which you can now track in the explorer:

That is it! You claimed your rewards from the Aurora Validator.

If you want to dive deeper, you can read more docs about the aurora.pool.near methods here.

Final thoughts

Thank you for reading the article! We have learned a lot today!
We hope that near-cli-rs will be an indispensable tool for you while working with the Near ecosystem and that it will make it easier for you to interact with the blockchain.
See you in the next articles!