Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blog/2024-07-01.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ If your application relies on community-contributed or unreviewed third-party co

If you are not relying on any untrusted component code, then **maybe**. You are not being forced to migrate and there are still teams actively building new applications leveraging B.O.S. Additionally, there are no plans to deprecate main B.O.S. gateways at [dev.near.org](https://dev.near.org), [near.social](https://near.social), [dapdap](https://dapdap.net) or [bos.gg](https://bos.gg). However, the underlying framework and virtual machine are no longer actively developed or maintained by the original team. Consequently, the pace at which new features are introduced and existing bugs or vulnerabilities are addressed may be slower than expected. We openly welcome new maintainers for [this codebase](https://github.com/nearsocial). However, as previously mentioned, we anticipate that additional security vulnerabilities may still be discovered.

We have updated [Frontends for Web3 dApps in docs.near.org](/web3-apps/tutorials/web-login/wallet-selector) to help you choose a solution that is right for you. If you need help, please reach out to one of our support channels on [Telegram](https://t.me/neardev) or [Discord](https://near.chat) and we will be happy to assist you or answer any questions you have.
We have updated ["Frontends for Web3 dApps" in docs.near.org](/web3-apps/tutorials/wallet-login) to help you choose a solution that is right for you. If you need help, please reach out to one of our support channels on [Telegram](https://t.me/neardev) or [Discord](https://near.chat) and we will be happy to assist you or answer any questions you have.
74 changes: 58 additions & 16 deletions blog/2024-11-07.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,71 @@ The idea of bringing Ethereum wallets to Near was born on the [NEP-518](https://

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
1. A `Transaction Encoder` service, that encodes NEAR actions into Ethereum transactions
2. A `Translator RPC` service, that translates Ethereum RPC calls into NEAR RPC calls
3. A `Wallet Contract` that allows NEAR accounts to process EVM transactions

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

---

### Login
### Transaction Encoder

Imagine your account on Metamask is `0xD79...314`, and you want to login on a Near application.
The `Transaction Encoder` - implemented [directly in the NEAR Wallet Selector](https://github.com/near/wallet-selector/blob/main/packages/ethereum-wallets/src/lib/index.ts) - takes the intent of the user (e.g. call `set_greeting` on `hello.near`) and translates it into an Ethereum transaction that the EVM wallet can sign.

The first time you login, `ethereum-wallets.near` will create the Near account `0xD79...314` for you.
#### To (field)
The `to` field of the Ethereum transaction is transformed following these rules:
- If the `receiverId` matches `^0x[a-f0-9]{40}$` (e.g. `0xD79...314`), then the `to` field is set to the `receiverId`
- Otherwise (e.g. `ana.near` or an implicit account) the `to` field is set as `keccak-256(receiverId)[12,32]`

<img src="/assets/blog/web3wallets/login.png" style={{width: "auto", display: "block", margin: "0 auto"}} />
#### Data (field)
The `data` field contains the RLP-encoded NEAR actions wanted by the user, encoded as function calls on Ethereum, for example:
- `FunctionCall(to: string, method: string, args: bytes, yoctoNear: uint32)`
- `Transfer(to: string, yoctoNear: uint32)`
- `Stake(public_key: bytes, yoctoNear: uint32)`
- `AddKey(public_key: bytes, nonce: uint64, is_full_access: bool, allowance: uint256, receiver_id: string, method_names: string[])`

Your new Near account already has a `Wallet Contract` deployed on it, which can **translate ethereum transactions** into **account actions**.
:::info
For more information on how other fields (such as `value`, `gas`, and `chainId`) are set, please refer to the [NEP-518 technical specification](https://github.com/near/NEPs/issues/518)
:::

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

### Translator RPC

The `Translator RPC` is a service deployed at `https://eth-rpc.mainnet.near.org` (for mainnet) and `https://eth-rpc.testnet.near.org` (for testnet) that translates Ethereum RPC calls into NEAR RPC calls.

In other words, the `Translator RPC` simply acts as a relayer, taking the Ethereum transactions signed by the user and translating them into a function call into the `Wallet Contract` deployed in the user's account.

---

### Wallet Contract

The `Wallet Contract` is a smart contract on NEAR that allows NEAR accounts to process EVM transactions.

The contract exposes a method called `rlp_execute`, which takes as argument an RLP-encoded Ethereum transaction, verifies its signature, and executes the NEAR actions encoded in the `data` field of the transaction.

Every NEAR account created through an EVM wallet has the `Wallet Contract` deployed on it.

:::tip Wallet Accounts
Remember that in NEAR **all accounts** can **have contracts**, and that **contracts** can perform **all the actions** that the **account can do**.
:::

### Using your Account
---

## Using the Account

### First Time Login

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

The first time you login through your EVM wallet, the wallet selector will contact the account `ethereum-wallets.near` to create a NEAR account with the same address as your Ethereum wallet. For example, if your address on Metamask is `0xD79...314`, the NEAR account created will be `0xD79...314`.

On this account, the `Wallet Contract` is deployed and a function-call key is added for the `rlp_execute` function of the contract.

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

### Interacting with Applications

Once you have logged in, you can 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.

Expand All @@ -65,16 +109,14 @@ Check [this transaction](https://testnet.nearblocks.io/txns/GrVGFVFmGBcNP5xkoA21

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**](/web3-apps/tutorials/web-login/ethereum-wallets) and working example [**hello world frontend**](https://github.com/near-examples/hello-near-examples/tree/main/frontend).
Do not worry! it is very simple, check the working example [**hello world frontend**](https://github.com/near-examples/hello-near-examples/tree/main/frontend).

---

## Resources

1. [**Integration Tutorial**](/web3-apps/tutorials/web-login/ethereum-wallets)

2. [Hello World Example](https://github.com/near-examples/hello-near-examples/blob/main/frontend/)
1. [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)
2. [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
3. [NEP-518](https://github.com/near/NEPs/issues/518), the proposal that started it all
2 changes: 1 addition & 1 deletion docs/api/rpc/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ balancing.

:::tip

If you want to use a custom RPC provider with NEAR Wallet Selector, [check this example](../../web3-apps/tutorials/web-login/wallet-selector.md#custom-rpc).
You can use any of these RPC endpoints with [any of our APIs](../../tools/near-api.md#view-function) or [wallet libraries](../../web3-apps/tutorials/wallet-login.md)

:::

Expand Down
2 changes: 1 addition & 1 deletion docs/chain-abstraction/chain-signatures/implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ The method requires four parameters:
1. The `payloads` (or hashes) to be signed for the target blockchain
2. The derivation `path` for the account we want to use to sign the transaction
3. The `keyType`, `Ecdsa` for `Secp256k1` signatures and `Eddsa` for `Ed25519` signatures.
4. The `signerAccount` which contains the `accountId` that is signing and the `signAndSendTransactions` function from the [wallet selector](../../tools/wallet-selector.md).
4. The `signerAccount` which contains the `accountId` that is signing and the `signAndSendTransactions` function from [Near Connect](../../web3-apps/tutorials/wallet-login).

<Tabs groupId="code-tabs">
<TabItem value="Ξ EVM">
Expand Down
10 changes: 5 additions & 5 deletions docs/primitives/dao.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ You can create a DAO by interacting with the `sputnik-dao` contract:
The full list of roles and permissions you can find [here](https://github.com/near-daos/sputnik-dao-contract#roles-and-permissions).
:::

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -209,7 +209,7 @@ Query the list of DAOs existing in Sputnik Dao.
});
```

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -269,7 +269,7 @@ These snippets will enable you to query the proposals existing in a particular D
});
```

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -414,7 +414,7 @@ Create a proposal so other users can vote in favor or against it.
});
```

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -734,7 +734,7 @@ These snippet will enable your users to cast a vote for proposal of a particular
Available vote options: `VoteApprove`, `VoteReject`, `VoteRemove`.
:::

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down
6 changes: 3 additions & 3 deletions docs/primitives/dex.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Query your deposit balances by calling the `get_deposits` method:
});
```

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

<details>
<summary>Example response</summary>
Expand Down Expand Up @@ -306,7 +306,7 @@ DEXs work by having multiple pools of token pairs (e.g. NEAR-USDC) that users ca
});
```

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

<details>
<summary>Example response</summary>
Expand Down Expand Up @@ -498,7 +498,7 @@ In order to swap a token for another, you need to [have funds](#deposit-funds),
});
```

Learn more about adding the [Wallet Selector Hooks](../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../web3-apps/tutorials/wallet-login) to your application

<details>
<summary>Example response</summary>
Expand Down
14 changes: 7 additions & 7 deletions docs/primitives/ft/ft.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Here is how to directly interact with the factory contract through your applicat
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -204,7 +204,7 @@ You can query the FT's metadata by calling the `ft_metadata`.
</p>
</details>

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -275,7 +275,7 @@ To know how many coins a user has you will need to query the method `ft_balance_
</p>
</details>

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -326,7 +326,7 @@ By calling this `storage_deposit` the user can register themselves or **register
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -374,7 +374,7 @@ To send FT to another account you will use the `ft_transfer` method, indicating
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -464,7 +464,7 @@ Let's assume that you need to deposit FTs on [Ref Finance](https://rhea.finance/
</p>
</details>

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -564,7 +564,7 @@ While the FT standard does not define a `burn` method, you can simply transfer t
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down
12 changes: 6 additions & 6 deletions docs/primitives/linkdrop/linkdrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ await callMethod({
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -155,7 +155,7 @@ await callMethod({
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -200,7 +200,7 @@ await callMethod({
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -270,7 +270,7 @@ await callMethod({
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -317,7 +317,7 @@ await callMethod({
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -396,7 +396,7 @@ await callMethod({
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down
8 changes: 4 additions & 4 deletions docs/primitives/nft/nft.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Here is how to directly interact with the factory contract through your applicat
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -228,7 +228,7 @@ You can query the NFT's information and metadata by calling the `nft_token`.
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

<details>

Expand Down Expand Up @@ -388,7 +388,7 @@ In both cases, it is necessary to invoke the `nft_transfer` method, indicating t
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down Expand Up @@ -538,7 +538,7 @@ While the NFT standard does not define a `burn` method, you can simply transfer
});
```

Learn more about adding the [Wallet Selector Hooks](../../web3-apps/tutorials/web-login/wallet-selector.md) to your application
Learn more about adding [Near Connect](../../web3-apps/tutorials/wallet-login) to your application

</TabItem>
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Expand Down
Loading