Skip to content

Commit

Permalink
Merge pull request #1097 from lukso-network/improve-erc20-page
Browse files Browse the repository at this point in the history
Improve readability of ERC20/ERC721 <> LSP7/LSP8 table
  • Loading branch information
CJ42 authored Jul 23, 2024
2 parents cd151ba + 63ddc65 commit 7c45eb8
Show file tree
Hide file tree
Showing 4 changed files with 350 additions and 30 deletions.
25 changes: 9 additions & 16 deletions docs/learn/digital-assets/migrate-erc20-to-lsp7.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ sidebar_position: 7
description: Learn how to migrate your ERC20 token to the LSP7 Digital Asset standard on LUKSO.
---

import Erc20LSP7Table from '@site/src/components/Erc20LSP7Table';

# 🪙 Migrate ERC20 to LSP7

[LSP7DigitalAsset](../../standards/tokens/LSP7-Digital-Asset.md) is a new token standard that offers a wider range of functionality compared to [ERC20](https://eips.ethereum.org/EIPS/eip-20), as described in the [standard section](../../standards/tokens/LSP7-Digital-Asset.md). For migrating from ERC20 to LSP7, developers need to be aware of several key differences.

:::info

If you need more details about the interface differences between ERC20 and LSP7, please visit our [contract overview](../../contracts/overview/DigitalAssets/#comparisons-with-erc20--erc721) page.

:::

## Smart Contract Building

Usually, to create an ERC20 token, `ERC20` is imported from [@openzeppelin/contracts](https://www.npmjs.com/package/@openzeppelin/contracts) package, and inherited.
Expand Down Expand Up @@ -75,22 +83,7 @@ To check function definitions and explanations of behavior and each parameter, c

To interact with LSP7DigitalAsset contract, different functions should be called. This is a table comparing function definitions:

| ERC20 Function | LSP7 Equivalent |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `name()` | `getData(bytes32 dataKey)` with `dataKey = keccak256('LSP4TokenName')` |
| `symbol()` | `getData(bytes32 dataKey)` with `dataKey = keccak256('LSP4TokenSymbol')` |
| `decimals()` | `decimals()` |
| `totalSupply()` | `totalSupply()` |
| `balanceOf(address account)` | `balanceOf(address account)` |
| `approve(address spender, uint256 amount)` | `authorizeOperator(address spender, uint256 amount, bytes memory data)` |
| `allowance(address owner, address spender)` | `authorizedAmountFor(address spender, address owner)` |
| _No equivalent_ | `getOperatorsOf(address owner)` |
| _No equivalent_ | `revokeOperator(address spender, bytes memory data)` |
| _No equivalent_ | `increaseAllowance(address spender, uint256 addedAmount, bytes memory data)` |
| _No equivalent_ | `decreaseAllowance(address spender, uint256 subtractedAmount, bytes memory data)` |
| `transfer(address to, uint256 amount)` | `transfer(address from, address to, uint256 amount, bool force, bytes memory data)` |
| `transferFrom(address from, address to, uint256 amount)` | `transfer(address from, address to, uint256 amount, bool force, bytes memory data)` |
| _No equivalent_ | `batchCalls(bytes[] memory data)` |
<Erc20LSP7Table/>

## dApps and Indexers

Expand Down
23 changes: 9 additions & 14 deletions docs/learn/digital-assets/migrate-erc721-to-lsp8.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ sidebar_position: 8
description: Learn how to migrate your ERC721 token to the LSP8 Identifiable Digital Asset standard on LUKSO.
---

import Erc721LSP8Table from '@site/src/components/Erc721LSP8Table';

# 🖼️ Migrate ERC721 to LSP8

[LSP8IdentifiableDigitalAsset](../../standards/tokens/LSP8-Identifiable-Digital-Asset.md) is a new token standard that offers a wider range of functionality compared to [ERC721](https://eips.ethereum.org/EIPS/eip-721), as described in the [standard section](../../standards/tokens/LSP8-Identifiable-Digital-Asset.md). For migrating from ERC721 to LSP8, developers need to be aware of several key differences.

:::info

If you need more details about the interface differences between ERC721 and LSP8, please visit our [contract overview](../../contracts/overview/DigitalAssets/#comparisons-with-erc20--erc721) page.

:::

## Smart Contract Building

Usually, to create an ERC721 token, `ERC721` is imported from [@openzeppelin/contracts](https://www.npmjs.com/package/@openzeppelin/contracts) package, and inherited.
Expand Down Expand Up @@ -76,20 +84,7 @@ To check function definitions and explanations of behavior and each parameter, c

To interact with LSP8IdentifiableDigitalAsset contract, different functions should be called. This is a table comparing function definitions:

| ERC721 Function | LSP8 Equivalent |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `name()` | `getData(bytes32 dataKey)` with `dataKey = keccak256('LSP4TokenName')` |
| `symbol()` | `getData(bytes32 dataKey)` with `dataKey = keccak256('LSP4TokenSymbol')` |
| `balanceOf(address owner)` | `balanceOf(address tokenOwner)` |
| `ownerOf(uint256 tokenId)` | `tokenOwnerOf(bytes32 tokenId)` |
| `approve(address to, uint256 tokenId)` | `authorizeOperator(address operator, bytes32 tokenId, bytes memory data)` |
| `getApproved(uint256 tokenId)` | `getOperatorsOf(bytes32 tokenId)` |
| `setApprovalForAll(address operator, bool approved)` | _No direct equivalent_ (Use `authorizeOperator` for each token) |
| `isApprovedForAll(address owner, address operator)` | `isOperatorFor(address operator, bytes32 tokenId)` |
| `transferFrom(address from, address to, uint256 tokenId)` | `transfer(address from, address to, bytes32 tokenId, bool force, bytes memory data)` |
| `safeTransferFrom(address from, address to, uint256 tokenId)` | `transfer(address from, address to, bytes32 tokenId, bool force, bytes memory data)` |
| _No equivalent_ | `revokeOperator(address operator, bytes32 tokenId, bool notify, bytes memory data)` |
| _No equivalent_ | `batchCalls(bytes[] memory data)` |
<Erc721LSP8Table/>

## dApps and Indexers

Expand Down
176 changes: 176 additions & 0 deletions src/components/Erc20LSP7Table/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import React from 'react';

export default function Erc20LSP7Table() {
return (
<table width="100%">
<thead>
<tr>
<th>ERC20 Function</th>
<th>LSP7 Equivalent</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>name()</code>
</td>
<td>
<code>getData(bytes32 dataKey)</code> with <br />{' '}
<code>dataKey = keccak256('LSP4TokenName')</code>
</td>
</tr>
<tr>
<td>
<code>symbol()</code>
</td>
<td>
<code>getData(bytes32 dataKey)</code> with <br />{' '}
<code>dataKey = keccak256('LSP4TokenSymbol')</code>
</td>
</tr>
<tr style={{ backgroundColor: '#dcfce7' }}>
<td>
<code>decimals()</code>
</td>
<td>
<code>decimals()</code>
</td>
</tr>
<tr style={{ backgroundColor: '#dcfce7' }}>
<td>
<code>totalSupply()</code>
</td>
<td>
<code>totalSupply()</code>
</td>
</tr>
<tr style={{ backgroundColor: '#dcfce7' }}>
<td>
<code>balanceOf(address account)</code>
</td>
<td>
<code>balanceOf(address account)</code>
</td>
</tr>
<tr>
<td>
<code>approve(address spender, uint256 amount)</code>
</td>
<td>
<code>
authorizeOperator(address spender,
<br />
uint256 amount,
<br />
bytes memory data)
</code>
</td>
</tr>
<tr>
<td>
<code>allowance(address owner, address spender)</code>
</td>
<td>
<code>
authorizedAmountFor(address spender,
<br />
address owner)
</code>
</td>
</tr>
<tr>
<td>
<i>No equivalent</i>
</td>
<td>
<code>getOperatorsOf(address owner)</code>
</td>
</tr>
<tr>
<td>
<i>No equivalent</i>
</td>
<td>
<code>
revokeOperator(address spender,
<br />
bytes memory data)
</code>
</td>
</tr>
<tr>
<td>
<i>No equivalent</i>
</td>
<td>
<code>
increaseAllowance(address spender,
<br />
uint256 addedAmount,
<br />
bytes memory data)
</code>
</td>
</tr>
<tr>
<td>
<i>No equivalent</i>
</td>
<td>
<code>
decreaseAllowance(address spender,
<br />
uint256 subtractedAmount,
<br />
bytes memory data)
</code>
</td>
</tr>
<tr>
<td>
<code>transfer(address to, uint256 amount)</code>
</td>
<td>
<code>
transfer(address from,
<br />
address to,
<br />
uint256 amount,
<br />
bool force
<br />
bytes memory data)
</code>
</td>
</tr>
<tr>
<td>
<code>transferFrom(address from, address to, uint256 amount)</code>
</td>
<td>
<code>
transfer(address from,
<br />
address to,
<br />
uint256 amount,
<br />
bool force
<br />
bytes memory data)
</code>
</td>
</tr>
<tr>
<td>
<i>No equivalent</i>
</td>
<td>
<code>batchCalls(bytes[] memory data)</code>
</td>
</tr>
</tbody>
</table>
);
}
Loading

0 comments on commit 7c45eb8

Please sign in to comment.