Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/sass-1.77.8
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Jul 22, 2024
2 parents 337f411 + d4ed4f6 commit 18ba122
Show file tree
Hide file tree
Showing 21 changed files with 917 additions and 524 deletions.
6 changes: 3 additions & 3 deletions docs/contracts/contracts/LSP6KeyManager/LSP6KeyManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ Retrieve the permission required to set some AllowedCalls for a controller.
| ---------------------------------------- | :-------: | ------------------------------------------------------------------------------------------- |
| `controlledContract` | `address` | The address of the ERC725Y contract from which to fetch the value of `dataKey`. |
| `dataKey` | `bytes32` | A data key ion the format `AddressPermissions:AllowedCalls:<controller-address>`. |
| `dataValue` | `bytes` | The updated value for the `dataKey`. MUST be a bytes32[CompactBytesArray] of Allowed Calls. |
| `dataValue` | `bytes` | The updated value for the `dataKey`. MUST be a `bytes[CompactBytesArray]` of Allowed Calls. |
| `hasBothAddControllerAndEditPermissions` | `bool` | - |

#### Returns
Expand Down Expand Up @@ -1537,13 +1537,13 @@ error InvalidEncodedAllowedERC725YDataKeys(bytes value, string context);

_Error when reading the Allowed ERC725Y Data Keys. Reason: `context`, Allowed ERC725Y Data Keys value read: `value`._

Reverts when `value` is not encoded properly as a `bytes32[CompactBytesArray]`. The `context` string provides context on when this error occurred (\_e.g: when fetching the `AllowedERC725YDataKeys` to verify the permissions of a controller, or when validating the `AllowedERC725YDataKeys` when setting them for a controller).
Reverts when `value` is not encoded properly as a `bytes[CompactBytesArray]`. The `context` string provides context on when this error occurred (\_e.g: when fetching the `AllowedERC725YDataKeys` to verify the permissions of a controller, or when validating the `AllowedERC725YDataKeys` when setting them for a controller).

#### Parameters

| Name | Type | Description |
| --------- | :------: | ---------------------------------------------------------- |
| `value` | `bytes` | The value that is not a valid `bytes32[CompactBytesArray]` |
| `value` | `bytes` | The value that is not a valid `bytes[CompactBytesArray]` |
| `context` | `string` | A brief description of where the error occurred. |

<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/contracts/overview/KeyManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ If controller has `CALL` permission but has no `AllowedCalls`, controller will n

:::

Key Manager allows for restricting controller addresses to be able to call specific functions on specific addresses which should be of a specific standard. In order to achieve such functionallity one could encode a set of type calls, addresses, standards and functions to [`bytes32[CompactBytesArray]`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#bytesncompactbytesarray), and store them under the [Allowed Calls](../../standards/universal-profile/lsp6-key-manager.md#allowed-calls) data key.
Key Manager allows for restricting controller addresses to be able to call specific functions on specific addresses which should be of a specific standard. In order to achieve such functionallity one could encode a set of type calls, addresses, standards and functions to [`bytes[CompactBytesArray]`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#bytesncompactbytesarray), and store them under the [Allowed Calls](../../standards/universal-profile/lsp6-key-manager.md#allowed-calls) data key.

_E.g._

Expand Down
1 change: 1 addition & 0 deletions docs/faq/network/network-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ You can find more information about firewall and port settings within the specif
- [Geth Port Specification](https://geth.ethereum.org/docs/fundamentals/security)
- [Erigon Port Specification](https://github.com/ledgerwatch/erigon#default-ports-and-firewalls)
- [Nethermind Port Specification](https://docs.nethermind.io/fundamentals/security/#networking-security)
- [Besu Port Specification](https://besu.hyperledger.org/development/public-networks/how-to/connect/configure-ports)
- [Prysm Port Specification](https://docs.prylabs.network/docs/prysm-usage/p2p-host-ip#configure-your-firewall)
- [Lighthouse Port Specification](https://lighthouse-book.sigmaprime.io/advanced_networking.html#how-to-open-ports)
- [Teku Port Specification](https://docs.teku.consensys.io/how-to/find-and-connect/improve-connectivity)
Expand Down
4 changes: 3 additions & 1 deletion docs/faq/network/node-setup.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_label: 'Node Setup'
sidebar_position: 4
description: 'LUKSO node setup and supported clients: Geth, Erigon, Nethermind, Prysm, Lighthouse, Teku.'
description: 'LUKSO node setup and supported clients: Geth, Erigon, Nethermind, Besu, Prysm, Lighthouse, Teku.'
---

# Node Setup
Expand All @@ -20,6 +20,8 @@ Currently, LUKSO officially supports Geth, Erigon, Lighthouse, and Prysm. All cl

- **[Nethermind](https://github.com/NethermindEth/nethermind)** is an Ethereum execution client built on .NET framework and developed by Nethermind. Its plugin system makes it especially easy to configure and use it. Combining this with a very stable runtime, this makes it a great client to use on the network.

- **[Besu](https://github.com/hyperledger/besu)** is an Ethereum execution client written in Java and developed by Hyperledger. It supports both public and private networks, offering features like Proof of Authority and Proof of Work consensus, advanced privacy options, and robust monitoring tools.

- **[Prysm](https://github.com/prysmaticlabs/prysm)** is an Ethereum consensus client written in Go and developed by Prysmatic Labs. Validators widely use it. Performance-wise, Prysm leverages optimized processes and data structures, offering a smooth experience for validators. The client had rigorous testing and auditing processes to ensure the client was secure against potential threats. It also comes with an excellent user-friendly terminal interface.

- **[Lighthouse](https://github.com/sigp/lighthouse)** is an Ethereum consensus client written in Rust and developed by Sigma Prime. From a security perspective, Lighthouse leverages Rust's safety features and undergoes regular security audits to protect against potential vulnerabilities. Regarding efficiency, Lighthouse is designed to perform well even on low-spec hardware, making it accessible to a wide range of users with different skill levels.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
label: '🌅 Create an NFT Collection'
collapsed: true
position: 3
position: 5
214 changes: 214 additions & 0 deletions docs/learn/digital-assets/migrate-erc20-to-lsp7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
---
sidebar_label: '💰 Migrate ERC20 to LSP7'
sidebar_position: 7
description: Learn how to migrate your ERC20 token to the LSP7 Digital Asset standard on LUKSO.
---

# 🪙 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.

## 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.

```solidity title="ERC20 Token"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyERC20Token is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
// Your constructor logic
}
}
```

To create an LSP7 token, `LSP7` is imported from [@lukso/lsp7-contracts](https://www.npmjs.com/package/@lukso/lsp7-contracts) package, and inherited.

The constructor arguments definitions can be found explained in the [constructor API](../../contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md#constructor) section.

```solidity title="LSP7 Token"
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.15;
import "@lukso/lsp7-contracts/contracts/LSP7DigitalAsset.sol";
contract MyLSP7Token is LSP7DigitalAsset {
constructor(
string memory name, // Name of the token
string memory symbol, // Symbol of the token
address tokenOwner, // Owner able to add extensions and change metadata
uint256 lsp4tokenType, // 0 if representing a fungible token, 1 if representing an NFT
bool isNonDivisible // false for decimals equal to 18, true for decimals equal to 0
) LSP7DigitalAsset(name, symbol, tokenOwner, lsp4tokenType, isNonDivisible) {
// _mint(to, amount, force, data)
// force: should be set to true to allow EOA to receive tokens
// data: only relevant if the `to` is a smart contract supporting LSP1.
_mint(tokenOwner, 200000, true, "");
}
}
```

## Behavior

Below are the function signatures of the transfer functions for ERC20 and LSP7, respectively.

ERC20: `function transferFrom(address from, address to, uint256 amount);`

LSP7: `function transfer(address from, address to, uint256 amount, bool force, bytes data);`

- For LSP7, **mint and transfer functions will have a `force` additional field**. For full compatibility with ERC20 behavior (where the recipient can be any address), set this to `true`. Setting it to `false` will only allow the transfer to smart contract addresses supporting the LSP1 interfaceId. (Check [LSP1UniversalReceiver section](../../standards/tokens/LSP7-Digital-Asset.md#lsp1-token-hooks) in LSP7DigitalAsset for more info).

- For LSP7, **mint, transfer, and burn functions will have `data` as an additional field**. For full compatibility with ERC20 behavior, set this to empty bytes. This data will only be relevant when the recipient is a smart contract address supporting the LSP1 interfaceId (Check [LSP1UniversalReceiver section](../../standards/tokens/LSP7-Digital-Asset.md#lsp1-token-hooks) in LSP7DigitalAsset for more info), where the data will be sent and the recipient can act on it (e.g., reject the transfer, forward the tokens to a vault, etc.).

- **LSP7 metadata is generic**, in contrast to ERC20 where the metadata is limited to name and symbol. The [generic key-value store](../../standards/lsp-background/erc725.md#erc725y-generic-data-keyvalue-store) in LSP7 allows for storing any possible data.

## Interacting with Contracts

:::info

To check function definitions and explanations of behavior and each parameter, check [API Reference](../../contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md) section.

:::

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)` |

## dApps and Indexers

:::info

To check event definitions and explanations of behavior and each parameter, check [API Reference](../../contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md) section.

:::

The table below shows the different event definitions that should be used to track activity on an LSP7-DigitalAsset contract.

| ERC20 Event | LSP7 Event |
| ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `Transfer(address indexed from, address indexed to, uint256 value)` | `Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data)` |
| `Approval(address indexed owner, address indexed spender, uint256 value)` | `OperatorAuthorizationChanged(address indexed operator, address indexed tokenOwner, uint256 indexed amount, bytes operatorNotificationData)` |
| _No equivalent_ | `OperatorRevoked(address indexed operator, address indexed tokenOwner, bool indexed notified, bytes operatorNotificationData)` |

## Metadata Management

### Basic Token Information

In ERC20, the name and symbol of a token can be retrieved by calling their own function:

```javascript
// ERC20
const name = await token.name();
const symbol = await token.symbol();
```

In LSP7, the token name and symbol can be retrieved with [getData](../../contracts/contracts/ERC725/ERC725.md#getdata) function, since LSP7 uses a generic metadata key value store:

```javascript
// LSP7
const nameKey = ethers.keccak256(ethers.toUtf8Bytes('LSP4TokenName'));
const symbolKey = ethers.keccak256(ethers.toUtf8Bytes('LSP4TokenSymbol'));

const nameValue = await token.getData(nameKey);
const symbolValue = await token.getData(symbolKey);

const name = ethers.toUtf8String(nameValue);
const symbol = ethers.toUtf8String(symbolValue);
```

### Extended Token Metadata

:::info

To learn more about setting and creating the LSP4Metadata JSON, check the [metadata](../digital-assets/metadata-management/metadata-preparation.md) section.

:::

LSP7 allows for more flexible and extensive metadata storage. You can store a JSON object containing additional token information:

```javascript
const metadataKey = ethers.keccak256(ethers.toUtf8Bytes('LSP4Metadata'));
const storedMetadata = await token.getData(metadataKey);
const retrievedJsonMetadata = JSON.parse(ethers.toUtf8String(storedMetadata));

// JSON Stored:

{
LSP4Metadata: {
description: 'The first digital golden pig.',
links: [
{ title: 'Twitter', url: 'https://twitter.com/goldenpig123' },
{ title: 'goldenpig.org', url: 'https://goldenpig.org' }
],
icon: [
{
width: 256,
height: 256,
url: 'ifps://QmW5cF4r9yWeY1gUCtt7c6v3ve7Fzdg8CKvTS96NU9Uiwr',
verification: {
method: 'keccak256(bytes)',
data: '0x01299df007997de92a820c6c2ec1cb2d3f5aa5fc1adf294157de563eba39bb6f',
}
}
],
images: [ // COULD be used for LSP8 NFT art
[
{
width: 1024,
height: 974,
url: 'ifps://QmW4wM4r9yWeY1gUCtt7c6v3ve7Fzdg8CKvTS96NU9Uiwr',
verification: {
method: 'keccak256(bytes)',
data: '0xa9399df007997de92a820c6c2ec1cb2d3f5aa5fc1adf294157de563eba39bb6e',
}
},
... // more image sizes
],
... // more images
],
assets: [{
verification: {
method: 'keccak256(bytes)',
data: '0x98fe032f81c43426fbcfb21c780c879667a08e2a65e8ae38027d4d61cdfe6f55',
},
url: 'ifps://QmPJESHbVkPtSaHntNVY5F6JDLW8v69M2d6khXEYGUMn7N',
fileType: 'fbx'
}],
attributes: [
{
key: 'Standard type',
value: 'LSP',
type: "string"
},
{
key: 'Standard number',
value: 4,
type: "number"
},
{
key: '🆙',
value: true,
type: "boolean"
}
]
}
}
```
Loading

0 comments on commit 18ba122

Please sign in to comment.