# Storage

Disassembling NEAR storage at HERE Wallet

{% embed url="<https://my.herewallet.app/stake>" %}
Try in web&#x20;
{% endembed %}

### Abstract

The smart contract implements the NEP-141 spec (similar to ERC-20) to store user funds. In exchange for the NEAR, the user receives tokens of the wrapped NEAR. Most of the money held on the contract is staking, but some are always left free. This allows the user to swap hNEAR to NEAR at any time without commission and use their funds.

For transactions within the wallet, hNEAR is used. For transactions with third-party users first conversion hNEAR to NEAR and then transfer NEAR.

![](/files/tfPDuG1xz67HfeToxCL9)

The `astostaking` project is used for staking. Users receive an accrual of interest to their hNEAR account on demand. The resulting income can be withdrawn at any time, turning it into NEAR.

{% embed url="<https://astrostakers.com/>" %}
More about astostaking
{% endembed %}

### Money management

**There are private methods for controlling steaking**

* `stake(&self, amount: U128)`
* `unstake(&self, amount: U128)`
* `deposit_stake(&self, amount: U128)`
* `withdraw_stake(&self, amount: U128)`

With them, the owner has full access to the allocation of staking. The calls duplicate the management methods "astro-stakers.poolv1.near". `(stake, unstake, deposit, withdraw)`

### Staking income

#### Owner

The owner can get his dividends at any time, using the method `recive_owner_dividends(amount)`. `amount` must be less than the total balance of all users and the number of accumulated dividends. The method `get_account_total_balance()` on the `astostaking` the contract will be called to check the storage balance. If the check is successful, the owner has received it on his account hNEAR.

#### User

User can receive their dividends at any time, using the method `recive_dividends`. User will receive hNEAR = `user_balance / 1000 * apy_value / ONE_YEAR_TS * (NOW_TS - last_accrual_ts)`. 0 <= `apy_value` <= 1000


# Getting Income

This article describes how to generate income from liquid staking

Unlike other liquid staking, hNEAR rate is fixed and always equal to 1 NEAR.

Income is accumulated in the form of dividends, which are recalculated after any balance change (transfer, withdrawal, deposit). You can check the amount of accumulated dividends by calling the

```bash
NEAR_ENV=mainnet near view storage.herewallet.near  get_user  '{"account_id":"komour.near"}'
```

The accumulated dividends can be transferred to the account at any time by calling the `claim_dividends` method or by pressing the claim button in the application or on the website.

<figure><img src="/files/o15BKiulI2WUNqbGL69X" alt=""><figcaption></figcaption></figure>

```bash
NEAR_ENV=mainnet near call storage.herewallet.near  claim_dividends  '' --accountId bob.near
```

After that, your balance in hNEAR will be increased. \
**For example:** if you held 1 hNEAR for a year with a yield of 9.5%, your balance will increase by 0.095 NEAR and become 1.095 hNEAR = 1.095 NEAR

### Reasoning

HERE Storage does not have a minimum unstaking fee, but we still have to balance so free liquidity is always available. That's why users have different yields. It will go up if the user holds money for a long time and go down if the user uses liquidity often. In order for each user to have his own yield it is necessary to count independently.


# Security

In this page we want to tell you more about what solutions we use to ensure security of storage in HERE Wallet

### Funds Control.

We were faced with a difficult task: the development team must manage the balance of frozen and free NEAR. This management allows us to maximize profits from staking. At the same time, the community must have a control tool and the ability to hand over control to a simple and open algorithm.

### Red Button

To solve this problem, we have created the "Red Button" approach in our contract. It is a set of public methods that are available only if liquidity drops below 5% of the total users' balance. These methods will allow you to unstake all the money and return it to the contract vaults. Also, if the "Red Button" is pressed, the management methods will be blocked for 6 epochs. During this time, the money will have time to unstake and all users will be able to withdraw it from the smart contract.

This approach ensures that even if the contract is mismanaged, users can always access the money. At the same time, it gives more freedom to management since it is not necessary to put all the logic of money management into a smart contract. External management works more accurately and gives more profit.

{% hint style="warning" %}
The "Red Button" will be pressed automatically in the HERE Wallet application if low liquidity is detected when checking the status of the contract.
{% endhint %}

### **Cost forecasting**

An important task in smart contract management is forecasting expenses to have enough available NEAR. We use machine learning algorithms to predict the amount of NEAR that will be withdrawn over the next 4 eras. This makes our prediction the closest to reality.

### Interest Payment

**I**nterest accrual is automatic. When you open the HERE Wallet app, the background requests a smart contract and requests a transfer profit NEAR to the user's account. Withdrawal can be requested at least every second, all accumulated interest since the last withdrawal NEAR will be withdrawn. The interest rate is fixed. Only the contract owner may change it, for example, if the yield of the staking changes. It is guaranteed to be between 2 and 10% APY.

It is the task of the contract management team to get the income. The user is guaranteed to get his percentage. If the management is not good enough, the money will be paid out of reserves. If there is not enough money in the reserves to pay dividends, the HERE Wallet app will automatically transfer all NEAR to the cold wallet and you will use it as usual, like on the web wallet. Interest will never be paid at the expense of other users' balances.

{% hint style="info" %}
The number of commissions. Now the price of gas for transfer, deposit, and withdrawal is less than 0.0001N. They are recouped by the income from the staking.
{% endhint %}

### Conclusion

Today, liquid staking on the HERE Wallet is the most advanced available in the NEAR ecosystem. We can provide good income without blocking NEAR and still leave control to the community.


# Security audit

Jan 20, 2023

### HERE Liquid staking protocol passed a security audit from OtterSec

{% embed url="<https://osec.io>" %}

Ottersec - a team of independent security researchers. They are one of the most reputable companies in the NEAR ecosystem, they work with many projects and are recommended by Proximity among others. Here's a list of companies they've worked with

<figure><img src="/files/Mucz1KNwTq1P6nk8tVsW" alt=""><figcaption></figcaption></figure>

We get several recommendations to improve security. No critical errors were found. All recommendations have been corrected and we are happy to announce a new liquid-staking protocol in the NEAR ecosystem with a security audit passed.

## Report

{% embed url="<https://herewallet.app/here_wallet_audit.pdf>" %}


# Phone number transfer

Transfers by phone number are available in HERE Wallet even for those users who don't have a wallet yet. In this article let's see how it works.

### Sending by phone number takes place in several steps

1. Sending money to a smart counter - a storage with a unique key.
2. Verification of the phone number
3. Receipt of payment by phone number
4. Sending to the linked phone number

### Verification.&#x20;

Verifying phone numbers in web3 applications is a very non-trivial task. There is someone who sends SMS, and most importantly centralized verification. These problems are solved by the LIT Protocol. They provide a decentralized SMS verification protocol. When confirming a number, each of the 16 validators independently verifies the code via API Twilio and if it is correct, signs the transaction. Instead, the validators use multi-signature to ensure that the code is indeed correct.

The user then uses this signature to add his phone number data to the smart contract.

### How to store a phone number.

Storing a phone number is another non-trivial task. If you put it in plaintext or hash, it can be recovered and used for spamming and deanonymization.

Instead of a phone number, the proof of account ownership is stored. hash(account\_id, phone\_number, nonce). This is unrecoverable data, but using this proof the sender can find out who actually needs to make the transfer. The data about the linked account is stored encrypted with limits on the number of requests and cannot be retrieved by brute force!

### Receiving a transfer.

Each transfer is a phone number encrypted via LIT protocol, the decryption function is non-public.

Once the user binds his phone number he can retrieve incoming transfers using proof from LIT Protocol. In the `proof` he passes transfer\_id, nonce and his address.

Inside the LIT validator function:

1. Decrypt the phone number
2. check that `hash(account_id, phone_number, nonce)` is in the smart contract.
3. if so, the node signs the `account_id` and `transfer_id` via muti-signature.

After receiving the signature from the LIT Protocol, the user takes his transfer from the smart contract. The phone number itself is not displayed anywhere in decrypted form, if the validator did not find proof of ownership, an error will be returned without the real phone number hidden in the transfer\_id.

### Conclusion

Thus, sending, receiving and verification of the phone number are decentralized and anonymous, allowing the sender and receiver to transfer money by phone number.


# Apple app clip

App Clip HERE Wallet documentation

You can give users the option of creating an instant wallet without installing the app.&#x20;

You can use our API to give users the ability to immediately use your service

examples of use

* Give a little NEAR to all new users
* Give users the chance to get tokens or free NFT right away
* Output NFT tickets to a new wallet you just created
* Authorize users via a crypto wallet

<figure><img src="/files/fVMUHYi5FExq2YLc4k4K" alt=""><figcaption><p>Example on paras</p></figcaption></figure>

Then the user will be able to scan the wallet and immediately get some NEAR and buy NFT

{% hint style="info" %}
We guarantee that airdrop will not be activated more than once from one device. We use Apple api to verify the uniqueness of the device
{% endhint %}

To create custom linkdrop, send us an email or telegram

t.me/heresupport

<team@herewallet.app>


# Binance connect

You can connect Binance to your non-custodial wallet. In this article, we’ll explain in detail what it is, and how dose Binance connect works

## Main idea <a href="#cafb" id="cafb"></a>

The idea is to use money from the balance of the exchange onchain. When you connect Binance, you create an api key that lets you quickly move assets between the exchange and your crypto wallet. Now you can remove fees from staking, use dApps, and store money safely. And at the same time use the exchange for cheap swaps and withdrawals to fiat.

<figure><img src="/files/4K4JhI5UTn9prh6bwSWX" alt=""><figcaption></figcaption></figure>

## Connecting

1. &#x20;🔐 Unblock the feature, now it is available to NFT owners and opens 5 new users a day from the waiting list
2. &#x20;🤝 Click on the Binance tab and follow the instructions
3. 💸 Write `#done username.near` in [discord](https://discord.gg/JMVbdBjb) in the #binance channel and get **4** **USDT**!

## New opportunities <a href="#id-85fb" id="id-85fb"></a>

Since you can now store assets in a non-custodial wallet and use decentralized applications directly — you have many new possibilities.

* Stake onchain with a freeze of 3 days instead of 120 days on Binance
* If Binance goes bankrupt as FTX, you keep your money
* You don't pay commissions for using dApps and you do it without intermediaries

<br>

<figure><img src="/files/K0UeT92Ee6mUlPmMHqdL" alt=""><figcaption></figcaption></figure>

## Special award: 4 USDT 💸 <a href="#id-7288" id="id-7288"></a>

The first 1,000 users to make a deep Binance connection (not view only) will receive 4 USDT

**Terms**

* you must be among the first 1000 users
* there must be more than $100 on the Binance account and it must be registered till April 15th, 2023
* one Binance account can be connected only once


# Score

In the HERE update 1.3.0 the score of the account appeared. In this article, we'll explain in detail what it is, how to get it, and why you need it

**Score** is a rating of activity in the app. It is attached to an account and cannot be sent to friends or bought for money. It consists of a permanent and a variable part. Permanent is accumulated for the use of certain features / contests / inviting friends and can only increase. Dynamic part depends on the balance or amount of money in steaking and can change.

## What gives a high score?

1\. **Private features**. New features are unlocked in the app after reaching the score threshold. You can earn USDT and get gifts for the found bugs

2\. **+APY**. The more score, the more profit you get from staking. Up to 10.2% per annum!

3\. **Cashback**. Users with score higher than 2500 can do gas free transactions between friends, get cashback for swaps, and purchase of some NFTs

## **Levels:**

**0–100** — I am not a bot 🤖\
**500–1500** — Start earn more APY, +0.1% for each 100 score 💸\
**400, 800, 1200** — Unlocking a secret feature 🔐\
**2500** —God mode. Gas free transactions / cashback for swaps ☁️

<figure><img src="/files/2BGk2zaP0U6AGVekOZOj" alt=""><figcaption></figcaption></figure>

#### How to earn a score?

1. Open [app](https://download.herewallet.app/): **+5** (one per day)
2. Make the swap: **+25** (one per day)
3. Start stake: **+100**
4. Invite a friend with balance: **+150**
5. Join `👋│intros` channel at [discord](https://dd.herewallet.app/) and send intro: **+50**

More use cases soon 🔜

<br>

\ <br>


# Token swaps

How token exchange works in the HERE app

We use a orderbook-based decentralized exchanger. When you want to exchange tokens you close someone's bid in the stack directly. Thanks to the bid stack, you don't have to pay a commission to liquidity providers.

The swap takes 10-15 seconds because it includes 2 FT-transactions.

We use wrapped wBTC, wETH, wSOL, and USDT tokens so you can invest without paying for gas and make exchanges really fast. If you want to transfer tokens to submit you can send to ethereum via rainbow bridge or swap to USDC and withdraw the profit to your bank account.

We only support really reliable tokens, now there are

* USDC
* USDT
* wBTC
* ETH
* Aurora
* Paras
* stNEAR

There will be more soon

{% embed url="<https://rainbowbridge.app/>" %}

### Tonic

Tonic is a permissionless, fully on-chain, orderbook-based exchange platform built on NEAR. Our platform allows anyone to create markets for any asset on NEAR L1 or Aurora. Every component of Tonic is built with developers in mind, enabling the community to build a wide range of performant DeFi applications on NEAR. We use in on background to process swaps

{% embed url="<https://tonic.foundation>" %}

<br>


# Instant wallet

App Clip HERE Wallet documentation

**You can use instant wallet to authorize the user without leaving the site.**

We wrote a small library which is fully compatible with wallet selector. We can use it to show a QR code to the user. As soon as he scans the QR code, it will trigger a successful sub-operation and return the result of the transaction

## @herewallet/near-selector

{% embed url="<https://github.com/here-wallet/near-selector>" %}

This library allows you to interact asynchronously with the here-wallet together with the near-selector.

In contrast to the synchronous signing of transactions in MyNearWallet and official near wallet, where the user is redirected to the wallet site for signing -- **HERE Wallet** provides the ability to sign transactions using async/await API calls.

```bash
npm i near-api-js@^0.44.2
npm i @near-wallet-selector/core --save
npm i @here-wallet/near-selector --save
```

### Usage

```typescript
import "@near-wallet-selector/modal-ui/styles.css";
import { setupWalletSelector } from "@near-wallet-selector/core";
import { setupNearWallet } from "@near-wallet-selector/near-wallet";
import { setupModal } from "@near-wallet-selector/modal-ui";
import { HereWallet, setupHereWallet } from "@here-wallet/near-selector";

const selector = await setupWalletSelector({
  modules: [setupNearWallet(), setupHereWallet()],
  network: "mainnet",
});

// Force login with here-wallet easy!
const here = await selector.wallet<HereWallet>("here-wallet");
const accounts = await here.signIn({ contractId: "social.near" });

console.log(`Hello ${accounts[0].accountId}!`);
```

### How it works

By default, all near-selector api calls that you make with this library run a background process and generate a unique link that the user can go to their mobile wallet and confirm the transaction. This is a link of the form:\
**<https://h4n.app/TRX\\_SHA1\\_IN\\_BASE64\\_URL\\_SAFE>**<br>

If a user has logged into your application from a phone and has a wallet installed, we immediately transfer him to the application for signing. In all other cases, we open a new window on the web.herewallet.app site, where the user can find information about installing the wallet and sign the transaction there.

All this time while user signing the transaction, a background process in your application will monitor the status of the transaction requested for signing.

### Instant Wallet with AppClip

If your goal is to provide the user with a convenient way to log in to your desktop app, you can use Here Instant Wallet, which allows users without a wallet to instantly create one via appclip.

> At the moment here wallet is only available for IOS users

You have the option to override how your user is delivered the signing link. This is how you can create a long-lived transaction signature request and render it on your web page:

```typescript
import { Strategy } from "@here-wallet/near-selector";
import { QRCodeStrategy } from "@here-wallet/near-selector/qrcode-strategy";

// Instant wallet signin HERE!
const here = await selector.wallet<HereWallet>("here-wallet");
const element = document.getElementById("qrcode")

await here.signIn({
  contractId: "social.near",
  strategy: new QRCodeStrategy({ element, theme: "dark" }), // override new window
});
```

You can also look at an example in this repository /example/index.ts or in sandbox: <https://codesandbox.io/s/here-wallet-instant-app-6msgmn>

### Strategy and Events

Methods **signIn**, **signAndSendTransaction**, **signAndSendTransactions** have additional parameters:

```typescript
export interface AsyncHereSignDelegate {
  // DefaultStrategy by default called new window popup, you can override it
  strategy?: Strategy;
  signal?: AbortSignal;

  // Just Events, called before strategy, 
  // use this if you don't need to change strategy
  onInitialized?: () => void;
  onRequested?: (link: string) => void;
  onApproving?: (HereProviderResult) => void;
  onSuccess?: (HereProviderResult) => void;
  onFailed?: (HereProviderResult) => void;
}
```

You can also set the default strategy for `setupHereWallet`:

```typescript
setupHereWallet({ strategy: () => new CustomStrategy() })
```

### Security

To transfer data between the application and the phone, we use our own proxy service. On the client side, a transaction confirmation request is generated with a unique request\_id, our wallet receives this request\_id and requests this transaction from the proxy.

**To make sure that the transaction was not forged by the proxy service, the link that opens inside the application contains a hash-sum of the transaction. If the hashes do not match, the wallet will automatically reject the signing request**

### Near Selector

This library was created to speed up development, the most stable version of this module will be available in the official @near-selector/here-wallet library in the future!ty

{% embed url="<https://codesandbox.io/s/here-wallet-instant-app-6msgmn?file=/src/index.ts>" %}

<figure><img src="/files/fVMUHYi5FExq2YLc4k4K" alt=""><figcaption><p>Example on paras</p></figcaption></figure>


# Push notifications

All decentralized partner apps can send push notifications to their users through the HERE app. To send a notification, just make a POST request.

```bash
curl -X 'POST' \
  'https://api.herewallet.app/api/v1/dapp/push_notification' \
  -H 'accept: application/json' \
  -H 'authorization: api_key' \
  -H 'Content-Type: application/json' \
  -d '{
  "near_account_id": "mydev.near",
  "message": "NEAR rate is $2.6 today, it'\''s a great time to buy"
}'
```

### ![](/files/ZbzfcT5Fr3smgZp2GoSu)

### Restrictions

1. You can send no more than one notification per 12 hours
2. The user must have call your dapp's smart contract in the last 7 days
3. The text of the notification must be useful for the user, sending spam or unsubstantiated calls to action is prohibited

### APY KEY

To get the API key, send us an email or telegram. Include a link to the site and the address of the smart contract. Use corporate email.

t.me/heresupport

<team@herewallet.app>


# Non-blocking storage with APY

How to integrate your dApps with HERE

## Motivation

dApps must do a lot of transactions and have liquidity at every point in time. That's why they cannot use stacking. Liquid stacking with withdrawal fees is not profitable either. You will have to pay 0.3-0.5% of the amount for each transaction. That's more than the potential income from staking.

In this case, liquid steaking HERE might be a very good solution. You can to keep the entire balance of your dApps on your HERE contract, use it at any time, and still earn passive income.

{% hint style="info" %}
This works because we have part of the balance of all users and dApps free for instant use. You can read more in the HERE Storage section
{% endhint %}

## How to use HERE Storage

Contract NEAR: `storage.herewallet.app`

1. **Cash in**: call `storage_deposit()` and attach NEAR
2. **Withdraw**: call  `storage_withdraw(amount, to_account_id)`&#x20;
   * use to\_account\_id=None to withdraw NEAR
   * use to\_account\_id=bob.near to send NEAR from dApp to bob.near account
3. **Get dividends:** `receive_dividends(to_account_id)`
   1. use to\_account\_id=None to withdraw dividends to dApp account
   2. use to\_account\_id=dappowner.near to withdraw dividends from HERE to owners account

<figure><img src="/files/1RwkczXO9T6M3PL9nkbg" alt=""><figcaption></figcaption></figure>

## Example

Let's look at an example of how HERE uses the game app. Users can deposit, play and withdraw at any time. At the same time there are usually 3-4k NEAR on the balance of the dApp and the owners could earn additional income.

### Modify the dApp contract to delegate funds to HERE

```rust
#[payable]
pub fn storage_deposit(&mut self) {
    self.total_balance += env::attached_deposit();
}    
```

```rust
#[ext_contract(ext_here)]
pub trait HereStorage {
    fn storage_deposit(&self);
    fn storage_withdraw(&self, amount: U128, to_account_id: Option<ValidAccountId>);
}
pub static HERE_CONTRACT_ID: &str = "storage.herewallet.near";
pub static GAS: u64 = 50_000_000_000_000;

... 
 
#[payable]
pub fn storage_deposit(&mut self) {
    ext_here::storage_deposit(amount, &HERE_CONTRACT_ID, env::attached_deposit(), GAS)
    self.total_balance += env::attached_deposit();
}   
```

Now after the deposit all the NEAR will be immediately transferred to the HERE storage and begin to bring income

### Modify the dApp contract to use funds from HERE

```rust
#[payable]
pub fn storage_withdraw(&mut self,  amount: U128) {
    assert_one_yocto();
    self.total_balance -= amount.0;
    Promise::new(env::predecessor_account_id()).transfer(amount.0);
}    
```

```rust
#[payable]
pub fn storage_withdraw(&mut self,  amount: U128) {
    assert_one_yocto();
    self.total_balance -= amount.0;
    ext_here::storage_withdraw(amount, env::predecessor_account_id(), &HERE_CONTRACT_ID, 1, GAS)
}    
```

You can now withdraw funds from your HERE balance directly to users. For them it will be a usual transaction from your dApp

### **Get income to** owner.near

Call these methods to get dividends on your HERE account. After that you can withdraw them by turning them into a regular NEAR

```bash
near call storage.herewallet.app  register_account  '' --gas 242794783120800 --accountId owner.near

near call storage.herewallet.app  receive_dividends '{"to_account_id":"owner.near"}' --accountId $ACCOUNT --gas 242794783120800
```

## The Economy

the cost of gas using the HERE Wallet&#x20;

| Action              | Gas    | USD Price        |
| ------------------- | ------ | ---------------- |
| withdrawal          | 7 TGas | $$4.2\*10^-11$$​ |
| deposit             | 6 TGas | $$3.6\*10^-11$$​ |
| receiving dividends | 7 TGas | $$4.2\*10^-11$$​ |

Let's calculate the economics of the project using the game as an example. there is

* $100,000 on the contract&#x20;
* 10 000$ daily turnover&#x20;
* 200 transactions a day

Then

* daily gas cost: 2600 TGas \~ 0.00000000026 NEAR
* daily dividends: \~1.3 - 2.5N = 8.2 - 15$
* annual profit: 2993-5475$ \*\*<br>

<figure><img src="/files/1xINe7zi8lHTm3XhqRcb" alt=""><figcaption></figcaption></figure>

\*\* The interest rate depends on the ratio of balance to turnover and on the terms of the collaboration and will vary from 3% to 9% APY. Text `team@herewallet.app` to get the best terms for your project.


# Universal sign links

HERE supports the new transaction format without having to pass signer\_id. In this article we will explore the possibilities of this approach

### Wallet-selector format

In the previous wallet selector format, a fully encoded transaction was required to be passed, which required obtaining the signer\_id beforehand. This added the need for each dApp to have a login functionality and made it impossible to create static links to sign transactions.

### Template format

We have introduced a new transaction signing template that allows you to pass a list of actions and have the final transaction generated on the wallet side. This has several benefits:

1. **Static Links:** With the new template, it is possible to create static links for transaction signatures and use them in QR codes, for example. This enables you to make an airdrop to all event participants.
2. **Signing Transactions Without Authorization**: You can add a button to your site that allows users to post NFT or purchase transactions without requiring them to log in to their accounts. This prevents other developers from using NEAR.
3. **Creating Templates:** With this new feature, it is possible to create templates such as <https://h4n.app/g/keypom/xxxx>, which will immediately generate the transaction and redirect it for signature. This makes it easy to create a simple interface for many dApps.

### Format:&#x20;

base58 encode JSON

**example:**&#x20;

```json
{
    "transactions": [
        {
            "actions": {
                    "type": "function call",
                    "params": {
                        "gas": 30000000000000,
                        "method_name": "hi",
                        "args":"",
                        "deposit": 1
                    },
                },
            "receiverId": "bob.near",
        }
    ],
    "network": "mainnet",
}
```

`ArdZExpjN7ppCHqma1CqBn2KmZEyPVDWpJGvx2hoPJZPsFRyJPjeLvef9PPCg3kRGZNV7Nrfc4GcavoxuqGo8fVH6eq5mu5fYkJDyEkVUVhaJoLDpQTBxtfm8WQgVdLgLApDusQnUq5DjRtzwy95z3GXrxHzyqGVJMNhQPZLsZvzFCHtTX3bNukJ98W1pur1pwZm7afvsgRfng8t25ckGcfE1o7A4vn5N8eB5rhdok5wnecs1QKYssBsnfp1TUfsz`

### Supported action types:

* FunctionCall
* Transfer
* DeleteAccount
* CreateAccount
* AddKey

{% hint style="info" %}
params list same as for NEAR rpc api
{% endhint %}

Waller route: `https://my.herewallet.app/call/{b58transaction}`

### Sign

You can also sign a message with a private key without sending it to the blockchain. This is useful e.g. for authorization via a wallet

Base58 json encode:

```json
{ 
    "receiver": "dapp.name", 
    "message": "auth message to sign", 
    "network": "mainnet" 
}
```

Waller route: `https://my.herewallet.app/sign/{b58request}`<br>

### Redirect url

`?returnUrl=https://google.com`<br>

if error

`https://google.com?failure=some_error_text`

if success

`https://google.com?success=trxHash,trxHash,trxHash`


# First step

A clear instruction on how to use the HERE Wallet

## Log in/Sign up

### Seed phrase

If you have a near account, we can log in using your passphrase.if you have a wallet at wallet.near.org

1. Click "import existing account"
2. Click "use seed phrase"
3. Enter seed phrase and click “find my account

![](/files/UMTGXdZAtlPC7xQNOiDh)

### Web wallet

If you have a wallet at wallet.near.org

1. Click "import existing account"
2. Click "use seed phrase"
3. Enter seed phrase and click “find my account”
4. Click "import existing account"
5. Click "share the link"
6. Send the link to your desktop
7. Open the link, select account and click “Next”
8. Click “Connect”
9. Enter account ID and click “Confirm”
10. You will be authorized on mobile device

![](/files/Bzf7HfNyeZsOsXbfNdrL)

## Setup username (free)

NEAR is available with usernames instead of addresses. Usually, they cost 0.1N, but in the HERE app, we allocate them for free. Just enter the username and click VerifyIMPORTANT NOTES

* Once you select a username, you cannot change it. The only available is to create a new account and transfer money
* We do not recommend using your last name in the username, it can deanonymize you

## Start earning

1. Click on the big round pink button “Earn”
2. Click “Start stacking”
3. Enter the amount
4. Click “Stake”
5. All set! Now you will receive a daily income at the rate of 8-10% p.a. on your balance

![](/files/kxoL95OBBc3ARO1Qkzo1)

## Send NEAR

1. Click “Pay & Transfer”
2. Enter the address or scan QR-code
3. Click on the address
4. Enter the amount
5. Enter the note if needed and click “pay”
6. Review and click “confirm”
7. Awesome. You’ve sent the money

![](/files/pDYIrSNY3Vx2dySe4hYE)

## Use dApps

To use third-party applications you need to log into wallet.near.org using the seed phrase.\
\
Before making transfers to third-party wallets you need to withdraw part of the NEAR that generates income.

1. Click on NEAR balance
2. Click “stake/unstake”
3. Enter the amount to unstake
4. Click “Confirm”

![](/files/UWfaRDcf1UhuhFOgcm1k)

### <br>


# Login

How authorization at HERE Wallet works through access keys

NEAR keys do not contain the data needed to add records to the blockchain, they are only needed to prove to other validators that you have the right to make the transaction

In NEAR the access keys are implemented very elegantly. Each account keeps a list of public keys with permissions. This allows you to give the application partial access to the data without showing your main private key.

![Authorization](/files/gg06iDqWVoAr5x0az5PE)

To add an access key, you need to perform the same transaction as to transfer money. You pass the public key and a list of accesses you want to add. During authorization in HERE a private key is generated locally on your device. Then the public key is added to your account.

To add a key to your account, you need to sign the transaction on the NEAR web wallet. By opening a page on the web wallet with a link from the application, you transfer a public key and a list of rules. After confirmation, the web wallet will send a request to add the public key to the blockchain. Once the public key is added, the HERE application can use the generated private key to sign all transactions.

{% embed url="<https://www.youtube.com/watch?v=pvq4cVh5viU>" %}

{% hint style="info" %}
HERE is the first wallet that uses this method of authorization. Thanks to it users can log in into the application through a web wallet without using their seed! This is the fastest and most convenient way to log in to your NEAR account
{% endhint %}


# RPC NODE

How the HERE app gets data from the blockchain

To ensure that no one collects the user's confidential data, such as

* ip address
* time zone data
* device information

We use our own NEAR RPC node. Also, we use powerful server hardware and our view methods are 60-70% faster than on the official RPC node.

{% embed url="<https://github.com/near/nearcore>" %}

You can also use our RPC node at `rpc.hereallet.app`


# Gas-free transactions

When we discuss blockchain technology, one of the key questions that always arises for users is the issue of transaction fees, or as they are often referred to in the cryptocurrency ecosystem — “gas”. Gas fees represent the charge that users must pay for processing their transactions on the blockchain. But what if there was a way to do transactions without paying for gas?

In the spring of 2023, the NEAR Protocol team introduced a significant update, *nearcore* 0.17, which included support for meta-transactions. This was a huge breakthrough in lowering barriers for new users, as meta-transactions allow third parties to pay for transaction costs for any account. This means that users can start using NEAR applications without first owning NEAR tokens.

**Technology Overview**

Meta-transactions are based on the concept of “gas forwarding”. Instead of each user paying for the gas of their transaction, these costs can be shifted to a third party. In the case of NEAR, this role is played by HERE Wallet (HERE RPC). It automatically processes and pays for the user’s gas expenses.

When a user initiates a transaction, instead of interacting directly with the blockchain, they create a signature for their transaction. This signature is then sent to the HERE RPC, which takes on the gas costs, initiating the transaction in the blockchain on behalf of the user.

**Security**

As meta-transactions are a relatively new concept in the field of blockchain, questions about security naturally arise. However, it’s important to understand that when using meta-transactions, the user still controls their keys and initiates transactions independently. HERE RPC simply performs the role of paying for the gas.

In addition, even though HERE RPC pays for gas, it cannot under any circumstances influence the content of the transaction. It cannot alter data or the direction of the transaction, and it also cannot initiate transactions on behalf of the user without their permission. This ensures that, despite the convenience offered by meta-transactions, the user’s security remains paramount.

**Why is this Important?**

1. **Ease of entry for new users:** New users interested in using blockchain applications often face the hurdle of needing to purchase cryptocurrency to pay for gas. Meta-transactions bypass this obstacle, allowing new users to start working with NEAR applications without an initial purchase of NEAR tokens.
2. **Simplification of the user experience**: Paying for gas can be complicated for unprepared users, especially if the cost of gas fluctuates. HERE Wallet simplifies this process by automatically paying for the gas on behalf of the user.
3. **Support for economic inclusion:** Some users may experience difficulties in acquiring cryptocurrency due to geographical or economic barriers.


# Santa Token

In this article we will look at how Santa Token 2022 works

## Abstract

Santa Token is a fungible token token run on NEAR Protocol. It was launched on December 1st and is available for trading until January 1st, 2023. Tokens can be obtained during an airdrop or can be mined.

On January 1st all tokens can be burned and swap to USDT, NEAR, NFT, or increased staking APY for a year in the HERE app.

A total of 1,000,000 tokens have been issued, all tokens are distributed to contest partners, who in turn conduct airdrops to their users. 100 STT ≈ 1$.

## Earn

Santa Token can be earned. To do this, you just need to transfer it to a friend by phone number. For each transfer, you and your friend will earn 50 Santa tokens. We think this is a great way to surprise your friends and give them a real Christmas miracle.

{% embed url="<https://phone.herewallet.app/>" %}

## Handing out gifts

Santa Token has a transparent draw algorithm. All prizes will be handed out based on the results of a decentralized randomization call on the smart contract.

At 12:00 PST, the `happy_new_year()` contract method will become available. It will freeze all transfers and generate a random number via  `env::random_seed()` call. You can see this number by calling `get_seed()`.

Then all users will be sorted by `hash(account_id+seed)` and the sequence number of each of their tokens will be superimposed on the prize number from this table. Then each of the sponsors will be given an instruction to whom and how many prizes to send.

The table with prizes is uploaded to IPFS by link and is not changeable. Any user will be able to check their prizes after the contest ends.

## Example

prize table

1 USDC\
0.2 NEAR\
1 USDC\
NFT HERE

**Bob and Alice participated in the contest:**

<table><thead><tr><th width="280.3333333333333"> </th><th>Bob</th><th>Alisa</th></tr></thead><tbody><tr><td>account id</td><td>bob.near</td><td>alisa.near</td></tr><tr><td>Token balance</td><td>1 SANTA</td><td>3 SANTA</td></tr><tr><td>SEED</td><td><strong>123</strong></td><td><strong>123</strong></td></tr><tr><td>sha256(account_id+SEED)</td><td>06e1966d9df7d550f3a3dc71d801afb44dbaa20d1c19cf9405655c6fdacdec0a</td><td>6b6183a63e3dc66cf472a36a9b7b811c44026797cd0b36263f261b6be182bc1d</td></tr></tbody></table>

**Order:**

1. Bob (06...)
2. Alisa (6b...)

1 USDC <> BOB\
0.2 NEAR <> ALISA\
0.5 USDC <> ALISA\
NFT HERE <> ALISA

**Full prize list:** <https://nftstorage.link/ipfs/bafybeia6r4gx3f4obyurdiyknza2ejqcsqboihbkogsqgs3jul3mx5hdoi>

### Site

{% embed url="<https://herewallet.app/santa/>" %}

###

### Contract code

{% embed url="<https://github.com/here-wallet/santa-token>" %}

### Contact

{% embed url="<https://explorer.near.org/accounts/santa_token.near>" %}


# HERE Connect (js)

Connect HERE Wallet to your site to push access to more users

[The Here Wallet Connector](https://web.herewallet.app/) is a simple web service that allows web3 applications to interact with the Here mobile wallet. It uses the same transaction signing interface as the official Near Wallet. This allows web3 apps to integrate Here Wallet without changing their code.

To sign a transaction you need to scan the QR code with the phone on which the installed Here Wallet:

<figure><img src="/files/6o2bM7NUYIWo0gBybDDv" alt=""><figcaption></figcaption></figure>

### Connect @here-wallet/connect

The easiest way to integrate Here Wallet

{% embed url="<https://www.npmjs.com/package/@here-wallet/connect>" %}

Here Wallet Connect integrates itself into the `near-api-js` library, so you don't have to add extra logic to work with the wallet.

Import here-wallet/connect into the main js/ts file of your project:

<pre class="language-javascript"><code class="lang-javascript">import * as near from "near-api-js"
import runHereWallet from "@here-wallet/connect"
import "@here-wallet/connect/index.css" // you need css loader

// Initialize here wallet bridge
runHereWallet({ near })

<strong>// You dont need change your code! js
</strong></code></pre>

Now all `near-api-js` calls that automatically redirect to `wallet.near.org` will open a built-in modal window in which the user can choose which wallet he wants to use to log in or upvote a transaction:

<figure><img src="/files/6ErZn3VZ9ESHy9Uy4Bej" alt=""><figcaption></figcaption></figure>

If you want to use only Here Wallet in your application, add only HERE: true to the library initializer:

```javascript
runHereWallet({ near, onlyHere: true }) 
```

If you have any questions about using our library, you can always email us at [github](https://github.com/here-wallet/herewallet-connect)

### Advance. Change the near-api-js configuration

If you do not want to install unnecessary dependencies, you can simply change the configuration of `near-api-js`. This is done as follows:

```javascript
import * as near from "near-api-js"

const config = {
    networkId: "mainnet",
    walletUrl: "https://web.herewallet.app", // <<< that!
    nodeUrl: "https://rpc.mainnet.near.org",
    helperUrl: "https://helper.mainnet.near.org",
    explorerUrl: "https://explorer.mainnet.near.org"
    keyStore: new keyStores.BrowserLocalStorageKeyStore(),
}

// Just keep using the near api just like you did before!
const initialize = async () => {
    const near = await connect(config)
    const wallet = new WalletConnection(near, "app");

    wallet.requestSignIn({
      contractId: "contract",
      methodNames: ["method"],
    });
}ja
```

### Testnet

```javascript
const config = {
    networkId: "testnet",
    walletUrl: "https://web.testnet.herewallet.app", // <<< this!
    // default testnet setup...
}
```

### Result

{% embed url="<https://youtu.be/W7kPvL7Cujk>" %}


# NEAR Foundation

HERE Wallet received a $50,000 NEAR Foundation grant for launching a mobile wallet for NEAR Protocol

In early June, the NEAR Foundation awarded a **$50,000** grant to develop the HERE Wallet. We're making the first mobile wallet for NEAR Protocol, which will make NEAR even more accessible and closer to people. Now you don't need a computer to use all the features of NEAR and interact with dApp.

In addition to access to NEAR transfers and purchases, the app supports important ecosystem projects. Liquid Stacking is available for all HERE Wallet users to start earning income in NEAR in one click. Quick NEAR buying and selling for bitcoin is also available. All of these features enable basic users to take full advantage of the NEAR ecosystem

The grant will help the HERE Wallet team finish development and pass security checks. The NEAR Foundation team supports a lot of important ecosystem projects. This has a great impact on user interest in the platform and helps its development. We are excited to be a part of the NEAR Foundation grants program.

Now there is a B-version of the app in TestFlight, and it will launch on the Apple Store at the end of July. You can add it to the waiting list at the project's official website herewallet.app. NEAR is HERE

{% embed url="<https://herewallet.app>" %}


# Tonic DEX

We use Tonic NEAR - BTC to implement the bridge. We also together provide wBTC liquidity.

<figure><img src="/files/or436rz5JAvl5fEn9cjI" alt=""><figcaption></figcaption></figure>

Thanks to the collaboration with[ Tonic ](https://twitter.com/tonicdex)we will be able to get the minimum fee for the conversion of fungible tokens. About 0.1% instead of 0.3% at [ref.finance](https://t.co/pPQot4WUhC)


# Astrostakers

Validator at HERE Wallet

![](/files/GHXFgXAj9VSJLoqUPoZN)

HERE protocol only deals with the management of funds, to generate income we use a third-party validator.[@astrostakers](https://twitter.com/astrostakers) specializes in staking and does a lot to ensure smooth operation and security. In addition to HERE Wallet, it is trusted with over 1.5M NEARs.

It's also the cheapest and most stable validator, with a commission of only 1% of earnings. Together we enable users to earn passive income very conveniently and safely.


# GetBlock

NEAR explorer at HERE Wallet

![](/files/LblJkdUWgdcjdXlD4pOU)

We use the indexer from GetBlock to show detailed information about transactions. Thanks to this we give users the most detailed information in a good design

{% embed url="<https://getblock.io/>" %}


