From 8a7c4492d1c522f48869070e77ad312f567b01cb Mon Sep 17 00:00:00 2001 From: Maksandre Date: Wed, 8 May 2024 20:47:14 +0400 Subject: [PATCH] docs: intro and accounts --- docs/.vuepress/configs/sidebar.ts | 1 + docs/build/evm/accounts.md | 46 +++++++++++++++++++++++++++++++ docs/build/evm/index.md | 14 ++++++++-- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 docs/build/evm/accounts.md diff --git a/docs/.vuepress/configs/sidebar.ts b/docs/.vuepress/configs/sidebar.ts index 29256d7..98c39f4 100644 --- a/docs/.vuepress/configs/sidebar.ts +++ b/docs/.vuepress/configs/sidebar.ts @@ -74,6 +74,7 @@ export const sidebar: Record = { text: 'EVM', children: [ '/build/evm', + '/build/evm/accounts.md', '/build/evm/smart_contracts.md', '/build/evm/UniqueNFT.md' ], diff --git a/docs/build/evm/accounts.md b/docs/build/evm/accounts.md new file mode 100644 index 0000000..d1a7302 --- /dev/null +++ b/docs/build/evm/accounts.md @@ -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. diff --git a/docs/build/evm/index.md b/docs/build/evm/index.md index 33afaa1..6d7e86e 100644 --- a/docs/build/evm/index.md +++ b/docs/build/evm/index.md @@ -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: - +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).