Skip to content

Commit

Permalink
Merge branch 'master' into near-api-section
Browse files Browse the repository at this point in the history
  • Loading branch information
garikbesson committed Oct 9, 2024
2 parents a06e73c + 58f0de8 commit 67ee2ad
Show file tree
Hide file tree
Showing 42 changed files with 657 additions and 3,983 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ jobs:
run: |
cd website
yarn
yarn crowdin:upload
yarn build
- name: Upload to Crowdin
continue-on-error: true
run: |
cd website
yarn crowdin:upload
- name: Commit build
run: |
git add -f ./website/build ./website/.docusaurus ./website/i18n
Expand Down
2 changes: 1 addition & 1 deletion blog/2024-08-13.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Once active development by Pagoda has ceased, it doesn't mean these tools have t

Between now and February 2025, Pagoda's development work will slow down or stop on the following products and services:

- [QueryAPI](https://docs.near.org/build/data-infrastructure/query-api/intro)
- QueryAPI
- [Enhanced API](https://docs.near.org/pagoda/rpc/api)
- [Alerts & Triggers](https://docs.near.org/pagoda/alerts/intro)

Expand Down
80 changes: 80 additions & 0 deletions blog/2024-11-07.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Hello Ethereum Wallets!
authors: [gagdiez, slava]
slug: hello-ethereum-wallets
tags: [updates]
---

*You can now login using MetaMask, WalletConnect and +400 Ethereum Wallets on Near!*

<p><img src="/docs/blog/web3wallets/cover.png" /></p>

<!-- truncate -->

## Ethereum Wallets on NEAR

We are excited to announce that NEAR now supports Ethereum wallets! This means that you can now login to NEAR applications using MetaMask, WalletConnect, and over 400 other Ethereum wallets.

In this post, we will explain how Ethereum wallets work on NEAR, and where to find information on how to integrate them into your applications.

## How it works

The idea of bringing Ethereum wallets to Near was born on the [NEP-518](NEP-518](https://github.com/near/NEPs/issues/518)), and the [Aurora Labs team](https://aurora.dev) worked for over a year to make it a reality.

Since Ethereum wallets create **ethereum transactions** and talk with **ethereum RPCs**, the Aurora team had to create three components:

1. A Translator API, that translates Ethereum RPC calls into NEAR RPC calls
2. A "Wallet Contract" deployed on Near, that can process Ethereum transactions

<img src="/docs/blog/web3wallets/diagram.png" height="600px" style={{width: "auto", display: "block", margin: "0 auto"}} />


### Login

Imagine your account on Metamask is `0xD79...314`, and you want to login on a Near application.

The first time you login, `ethereum-wallets.near` will create the Near account `0xD79...314` for you.

<img src="/docs/blog/web3wallets/login.png" style={{width: "auto", display: "block", margin: "0 auto"}} />

Your new Near account already has a `Wallet Contract` deployed on it, which can **translate ethereum transactions** into **account actions**.

:::tip
In Near, smart contracts can do anything an account can do, including sending tokens and calling other contracts!
:::

### Using your Account

Once you have logged in, you can use start interacting with the application. If at some point the application needs to interact with the blockchain, Metamask will ask you to sign a transaction.

Under the hood, Metamask will create an Ethereum transaction and send it to the `Translator API`, deployed at `https://eth-rpc.mainnet.near.org`.

The `Translator API` will then translate the Ethereum transaction into a **function call** into the `Wallet Contract` deployed in your account. Particularly, it will call the `rlp_execute` function, passing the Ethereum transaction as an argument.

<img src="/docs/blog/web3wallets/function-call.png" style={{width: "auto", display: "block", margin: "0 auto"}} />

The `Wallet Contract` will then execute the function call, and the application will receive the result.

:::tip

Check [this transaction](https://testnet.nearblocks.io/txns/GrVGFVFmGBcNP5xkoA21gEJ7d5bUGVxtmkfHAzyUW895#enhanced) in our explorer to see the full execution path

:::

## Updating your Application

In order to support Ethereum wallets, you only need to update your version of `wallet-selector`, and configure it to include the new `ethereum-wallets` module.

Do not worry! it is very simple, check our [**tutorial**](/tools/ethereum-wallets) and working example [**hello world frontend**](https://github.com/near-examples/hello-near-examples/tree/main/frontend).

---

## Resources

1. [**Integration Tutorial**](/tools/ethereum-wallets)

2. [Hello World Example](https://github.com/near-examples/hello-near-examples/blob/main/frontend/)

3. [Recording of the Ethereum Wallet Presentation](https://drive.google.com/file/d/1xGWN1yRLzFmRn1e29kbSiO2W1JsxuJH-/view?usp=sharing)

4. [NEP-518](https://github.com/near/NEPs/issues/518), the proposal that started it all
12 changes: 12 additions & 0 deletions blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ gagdiez:
title: Docs Maintainer
url: https://github.com/gagdiez
image_url: https://github.com/gagdiez.png
socials:
x: guillewrotethis
github: gagdiez

slava:
name: Slava Karkunov
title: DevRel
image_url: https://www.datocms-assets.com/95026/1677167398-photo_2022-12-02-14-55-03.jpeg
socials:
x: apocnab
github: karkunow
linkedin: karkunov

flmel:
name: Lyudmil
Expand Down
91 changes: 0 additions & 91 deletions docs/1.concepts/data-flow/data-storage.md

This file was deleted.

23 changes: 15 additions & 8 deletions docs/2.build/2.smart-contracts/anatomy/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ You can choose between two types of collections:

Understanding how the contract stores and loads both types of collections is crucial to decide which one to use.

:::tip
:::tip Native vs SDK Collections

Use native collections for small amounts of data that need to be accessed all together, and SDK collections for large amounts of data that do not need to be accessed all together.

Use native collections for small amounts of data that need to be accessed all together, and SDK collections for large amounts of data that do not need to be accessed all together
If your collection has up to 100 entries, it's acceptable to use the native collection. For larger ones, prefer to use SDK collection. For comparison please refer to [this benchmark](https://www.github.com/volodymyr-matselyukh/near-benchmarking).

:::

:::info How the State is Handled
<details>

<summary> How the State is Handled </summary>

Each time the contract is executed, the first thing it will do is to read the values and [deserialize](./serialization.md) them into memory, and after the function finishes, it will [serialize](./serialization.md) and write the values back to the database.

:::
For native collections, the contract will fully load the collection into memory before any method executes. This happens even if the method you invoke does not use the collection. Know that this will have impact on GAS you spend for methods in your contract.

</details>

---

Expand Down Expand Up @@ -288,14 +294,15 @@ Implements a [map/dictionary](https://en.wikipedia.org/wiki/Associative_array) w
Implements a [set](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) which persists in the contract's storage. Please refer to the Rust and JS SDK's for a full reference on their interfaces.

<Tabs groupId="code-tabs">

<TabItem value="js" label="🌐 JavaScript">
<Github fname="contract.ts" language="js"
url="https://github.com/near-examples/storage-examples/blob/main/collections-js/src/contract.ts"
start="60" end="74" />
url="https://github.com/near-examples/storage-examples/blob/main/collections-js/src/contract.ts" start="60" end="74" />
</TabItem>

<TabItem value="rust" label="🦀 Rust">
<Github fname="lookup_set.rs" language="rust"
url="https://github.com/near-examples/storage-examples/blob/main/collections-rs/store/src/lookup_set.rs" start="4" end="18"/>
url="https://github.com/near-examples/storage-examples/blob/main/collections-rs/store/src/lookup_set.rs" start="4" end="18"/>
</TabItem>

</Tabs>
Expand Down Expand Up @@ -599,4 +606,4 @@ For storing data on-chain it’s important to keep in mind the following:

Let’s say for example, someone wants to put an NFT purely on-chain (rather than IPFS or some other decentralized storage solution) you’ll have almost an unlimited amount of storage but will have to pay 1 $NEAR per 100kb of storage used.

Users will be limited to 4MB per contract call upload due to MAX_GAS constraints. The maximum amount of gas one can attach to a given functionCall is 300TGas.
Users will be limited to 4MB per contract call upload due to MAX_GAS constraints. The maximum amount of gas one can attach to a given functionCall is 300TGas.
2 changes: 1 addition & 1 deletion docs/2.build/2.smart-contracts/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Having our account created, we can now deploy the contract:
<TabItem value="short" label="Short">
```bash
near deploy <created-account> build/release/hello.wasm
near deploy <created-account> build/hello_near.wasm
```
</TabItem>
Expand Down
Loading

0 comments on commit 67ee2ad

Please sign in to comment.