Skip to content

Commit

Permalink
docs: intro and accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksandre committed May 8, 2024
1 parent f1d5816 commit 8a7c449
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/configs/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const sidebar: Record<string, SidebarConfig> = {
text: 'EVM',
children: [
'/build/evm',
'/build/evm/accounts.md',
'/build/evm/smart_contracts.md',
'/build/evm/UniqueNFT.md'
],
Expand Down
46 changes: 46 additions & 0 deletions docs/build/evm/accounts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Account mirrors

There are two types of accounts in Unique Network:

- Native substrate accounts. Generic substrate account looks like `5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY`
- Ethereum accounts, a 42-character hexadecimal string starting with `0x`

Because of different formats, substrate and ethereum addresses cannot interact directly. For example, you cannot send tokens from Metamask to the substrate address; it requires the ethereum format.

However, it is possible to mix these two worlds thanks to account mirroring.

## Account mirrors

Mirroring is a mechanism that allows you to get address representation in a different format—substrate for ethereum address and ethereum for substrate.

You can play around with address converter in the [Reference section]('../../../../reference/tools.md').

For example:

- Ethereum mirror for `5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY` is `0xd43593c715Fdd31c61141ABd04a99FD6822c8558`
- Substrate mirror for `0x1B8EeEC6eD7e9C6B98291A8274c006e251902Ef3` is `5FkhL2YH6rZD2AspxMBoUfFnA4GwWVKHVTbL1kChhYMvSq7B`

> It is very important to note that you can not get the original account from the mirror account. Because of the different sizes, this is a one-way mapping.
Here is the primary use case for mirrors:

1. If you want to send tokens from substrate account to ethereum account - send it to it's substrate mirror.

2. The opposite operation works with one tradeoff. Tokens sent to the ethereum mirror of a substrate account will not directly top up the substrate account's balance. However, the substrate account can "withdraw" tokens from its ethereum mirror using `api.tx.evm.withdraw` method.

## Code example

To get an accounts mirror, use `Address` util from `@unique-nft/utils.`

```ts
import { Address } from "@unique-nft/utils";

const ethMirror = Address.mirror.substrateToEthereum('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
// 0xd43593c715Fdd31c61141ABd04a99FD6822c8558

const subMirror = Address.mirror.ethereumToSubstrate('0x1B8EeEC6eD7e9C6B98291A8274c006e251902Ef3');
// 5FkhL2YH6rZD2AspxMBoUfFnA4GwWVKHVTbL1kChhYMvSq7B
```


The following articles will teach you more advanced concepts that make the developer and user experience smoother.
14 changes: 11 additions & 3 deletions docs/build/evm/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# EVM docs
# Intro to Unique EVM

Welcome to the Ethereum Virtual Machine (EVM) section. Here, we introduce how developers can utilize familiar Ethereum-based tools to interact with Unique Network's advanced NFT pallet.

Tech demo:
<TestMetamask/>
Unique Network employs Substrate’s flexibility to deliver native NFT features, boosting scalability and customization in digital asset management. It also supports EVM compatibility, allowing Ethereum toolsets to manipulate NFTs. This enables the use of Solidity and other Ethereum standards for NFT interactions on Unique Network, creating a flexible development environment within the Polkadot ecosystem.

This documentation will guide you through deploying and interacting with NFTs via the EVM layer, offering a comprehensive toolkit for both Substrate and Ethereum developers.

## Connect to the EVM on Unique Network

You can connect to Unique utilizing familiar tools such as MetaMask and Ethers.js. These tools allow developers to interact with and deploy smart contracts as they would on any Ethereum-compatible network.

You can find connection settings in [reference](../../reference/index.md).

0 comments on commit 8a7c449

Please sign in to comment.