Skip to content

Commit

Permalink
Merge branch 'main' into update-issued-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
YamenMerhi committed Jul 30, 2024
2 parents fcecdca + 455ccfc commit d4564a9
Show file tree
Hide file tree
Showing 20 changed files with 12,876 additions and 41 deletions.
95 changes: 68 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@

Convenient code snippets to interact with [LSP](https://docs.lukso.tech/standards/standards-roadmap) standards on LUKSO. Code examples are taken from the [LUKSO Tech Docs](https://docs.lukso.tech/) and are working as standalone scripts.

## Contents
## Getting started

- [`universal-profile`](./universal-profile): Universal Profile related scripts
- [`digital-assets`](./digital-assets/): Digital assets (LSP7/8) scripts
- [`interface-detection`](./interface-detection): Verify EIP165 Standard Compatibility
- [`key-manager`](./key-manager): Permission Management of Controller Keys
- [`metadata-detection`](./metadata-detection): Verify ERC725Y Storage Compatability
- [`transfer-lyx`](./transfer-lyx): Coin Transfers for Backend and Extension

### 📑 Smart contracts

- [`smart-contracts-hardhat`](./smart-contracts-hardhat): Hardhat Smart Contract Deployment Setup and Scripts

### LUKSO Libraries

- [`@erc725/erc725.js`](https://docs.lukso.tech/tools/erc725js/getting-started)
- [`@lukso/lsp-smart-contracts`](https://docs.lukso.tech/tools/lsp-smart-contracts/getting-started)

Please check the versions used in the [`package.json`](./package.json)

## Development
### Installation

> A lot of these scripts should run with `ts-node` in development environnements, but you might be encountering issues because of ESM dependencies.
Expand All @@ -36,24 +18,83 @@ git clone https://github.com/lukso-network/lukso-playground.git
cd lukso-playground && bun install
```

### Set the private environment variables
### Run examples

If you want to deploy something directly from your TS files, you will have to import a private key and profile address. You can simply copy the example environment files within the folders to access private data.
Run the TypeScript code of one file within the terminal using `bun`.

```bash
cp .env.example .env
bun run file-path/script.ts
```

> **INFO** Make sure to add the private key of an EOA for deployment. Optionally, you can provide a private key of a controller and a Universal Profile address to deploy contracts using your smart contract account.
🆙 🔍 For example, to run the code example to fetch various metadata on a Universal Profile:

### Run locally
```bash
bun run universal-profile/fetch-json-data.ts
```

Run the TypeScript code of one file within the terminal using `bun`.
🗃️ This might return you among the values a list of `LSP5ReceivedAssets[]`:

```bash
bun file-path/script.ts
# ...
{
key: "0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b",
name: "LSP5ReceivedAssets[]",
value: [
"0x8b08eeb9183081De7e2D4ae49fAD4afb56E31Ab4", "0xD9079930Be38bf4CF44cbd54Dbd7417DFc363d0A",
"0xAB0A093104b6d2d4999Ad40C96d410Bc9601A71F", "0xa289935a2f0e66b0dCB97e95c6c91B0D33280Fa0",
"0xC94f4b542914e86B8e46c4610CC5A7d06b97aFd4", "0xb52Dc4537AC17f4ab673EEf6645c12425fC5792F",
"0x0514A829C832639Afcc02D257154A9DaAD8fa21B", "0x2dF821A905A2d007433669AA176EE543b8b73D66",
"0x631308F794E73Ae9786EE24247aEB1a2ea37D024", "0xa579F6C4F94E03131d7f48Ea4EcFAa7c5b1629be",
"0xAB84fe1dDF79BEcF2D675d7Ec001Ad1be32Fc9B5", "0xF8E6E921E602301360482CF6CD182232D7EDf39A",
"0xB64a1A593830De953Cf0f7D1EE18f02C47b54481", "0xD9079930Be38bf4CF44cbd54Dbd7417DFc363d0A"
],
}
```

🪙 🔍 Let's now inspect the metadata of the first Digital Asset. In the file ``, adjust the address here as follow:

```ts
async function fetchJSONData() {
// Instantiate erc725.js
const erc725js = new ERC725(
lsp4Schema,
'0x<asset-address>', // <== Change this line with the asset address
'https://4201.rpc.thirdweb.com',
{
ipfsGateway: 'https://api.universalprofile.cloud/ipfs',
},
);

// rest of the code from this file...
}
```

Then run the script to fetch the asset data

```bash
bun run digital-assets/extract-asset-data.ts
```

## Contents

- [`universal-profile`](./universal-profile): Universal Profile related scripts
- [`digital-assets`](./digital-assets/): Digital assets (LSP7/8) scripts
- [`interface-detection`](./interface-detection): Verify EIP165 Standard Compatibility
- [`key-manager`](./key-manager): Permission Management of Controller Keys
- [`metadata-detection`](./metadata-detection): Verify ERC725Y Storage Compatability
- [`transfer-lyx`](./transfer-lyx): Coin Transfers for Backend and Extension

### 📑 Smart contracts

- [`smart-contracts-hardhat`](./smart-contracts-hardhat): Hardhat Smart Contract Deployment Setup and Scripts

### LUKSO Libraries

- [`@erc725/erc725.js`](https://docs.lukso.tech/tools/erc725js/getting-started)
- [`@lukso/lsp-smart-contracts`](https://docs.lukso.tech/tools/lsp-smart-contracts/getting-started)

Please check the versions used in the [`package.json`](./package.json)

## IPFS Server

We highly recommend that developers fetch and store profile or asset data using **their own IPFS gateway** solutions like [Pinata](https://docs.pinata.cloud/docs/welcome-to-pinata) or [Infura](https://docs.infura.io/networks/ipfs). For development purposes, this repository uses the following RPC to fetch mainnet and testnet data:
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions digital-assets/backend-token-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ try {
'0x', // Additional data
]);

// Call the execute function of the profile to send the LYX transaction
// Call the execute function of the profile to then call the token contract
// Will forward to the LSP6 Key Manager to check permissions of the controller
const transaction = await myUniversalProfile.execute(
0, // Operation of type CALL
'0x...', // Recipient address including profiles and vaults
tokenAddress, // Target contract to call, on the behalf of this profile
0, // Amount in LYX
tokenCalldata, // Contract calldata, empty for regular transfer
{ gasLimit: 500000, from: controller }, // Gas limit of the transaction and sender address
Expand Down
4 changes: 2 additions & 2 deletions digital-assets/extract-asset-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import LSP4Schema from '@erc725/erc725.js/schemas/LSP4DigitalAsset.json';
import { FetchDataOutput } from '@erc725/erc725.js/build/main/src/types/decodeData.js';

// https://docs.lukso.tech/networks/mainnet/parameters
const RPC_ENDPOINT = 'https://42.rpc.thirdweb.com';
const RPC_ENDPOINT = 'https://4201.rpc.thirdweb.com';
const IPFS_GATEWAY = 'https://api.universalprofile.cloud/ipfs';

// 💡 Note: You can debug any smart contract by using the ERC725 Tools
// 👉 https://erc725-inspect.lukso.tech/inspector?address=0x61b083f1fb63ba2F064990f01B233B547ED4F5Cb&network=mainnet
const SAMPLE_ASSET_CONTRACT_ADDRESS =
'0x61b083f1fb63ba2F064990f01B233B547ED4F5Cb';
'0x8b08eeb9183081De7e2D4ae49fAD4afb56E31Ab4';

// Parameters for the ERC725 instance
const config = { ipfsGateway: IPFS_GATEWAY };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function fetchJSONData() {
// Instantiate erc725.js
const erc725js = new ERC725(
lsp4Schema,
'0x0514A829C832639Afcc02D257154A9DaAD8fa21B', // LSP7 Address
'0xbA712C92C6e10f22d7C737f9BC7dAa22B65548F7', // Asset address (LSP7 or LSP8)
'https://4201.rpc.thirdweb.com',
{
ipfsGateway: 'https://api.universalprofile.cloud/ipfs',
Expand Down Expand Up @@ -47,7 +47,7 @@ async function fetchJSONData() {
{
keyName: 'LSP4CreatorsMap:<address>',
// Sample creator address
dynamicKeyParts: '0x9139def55c73c12bcda9c44f12326686e3948634',
dynamicKeyParts: (assetCreatorsList.value as string[])[0],
},
]);
console.log(creatorInformation);
Expand Down
4 changes: 2 additions & 2 deletions interface-detection/erc165-interface-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { INTERFACE_IDS } from '@lukso/lsp-smart-contracts';
// 💡 Note: You can debug any smart contract by using the ERC725 Tools
// 👉 https://erc725-inspect.lukso.tech/inspector?address=0x61b083f1fb63ba2F064990f01B233B547ED4F5Cb&network=mainnet
const SAMPLE_ASSET_CONTRACT_ADDRESS =
'0x61b083f1fb63ba2F064990f01B233B547ED4F5Cb';
'0xbA712C92C6e10f22d7C737f9BC7dAa22B65548F7';

// https://docs.lukso.tech/networks/mainnet/parameters
const RPC_URL = 'https://42.rpc.thirdweb.com';
const RPC_URL = 'https://4201.rpc.thirdweb.com';

const myAsset = new ERC725(lsp4Schema, SAMPLE_ASSET_CONTRACT_ADDRESS, RPC_URL, {
ipfsGateway: 'https://api.universalprofile.cloud/ipfs',
Expand Down
2 changes: 1 addition & 1 deletion key-manager/execute-relay-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const eip191Signer = new EIP191Signer();
/**
* Create signature of the transaction payload using:
* - Key Manager Address
* - Message (LSP6 version, chain ID, noce, timestamp, value, payload)
* - Message (LSP6 version, chain ID, nonce, timestamp, value, payload)
* - private key of the controller
*/
const { signature } = await eip191Signer.signDataWithIntendedValidator(
Expand Down
4 changes: 2 additions & 2 deletions metadata-detection/digital-asset-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import lsp4Schema from '@erc725/erc725.js/schemas/LSP4DigitalAsset.json';

// 💡 Note: You can debug any smart contract by using the ERC725 Tools
// 👉 https://erc725-inspect.lukso.tech/inspector?address=0x86e817172b5c07f7036bf8aa46e2db9063743a83&network=mainnet
const assetContractAddress = '0x86e817172b5c07f7036bf8aa46e2db9063743a83';
const assetContractAddress = '0xbA712C92C6e10f22d7C737f9BC7dAa22B65548F7';

// Initatiate erc725.js
const erc725js = new ERC725(
lsp4Schema,
assetContractAddress,
'https://42.rpc.thirdweb.com',
'https://4201.rpc.thirdweb.com',
{},
);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint:fix": "eslint . --fix"
},
"devDependencies": {
"@erc725/erc725.js": "^0.24.2",
"@erc725/erc725.js": "^0.27.0",
"@lukso/lsp-smart-contracts": "^0.14.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
Expand Down
2 changes: 1 addition & 1 deletion smart-contracts-hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ npx hardhat --network luksoTestnet run scripts/deployUP.ts
Verify your contracts with the blockscout API and their constructor parameters:

```bash
npx hardhat verify <myContractAddress> --constructor-args ./verify/myContractParameters.ts --network luksoTestnet
npx hardhat verify <myContractAddress> --constructor-args ./verify/myCustomToken.ts --network luksoTestnet
```

## Packages
Expand Down
Loading

0 comments on commit d4564a9

Please sign in to comment.