Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a little Getting Started flow on the README #59

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 73 additions & 22 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

- [`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
## Getting started

- [`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,14 +18,83 @@ git clone https://github.com/lukso-network/lukso-playground.git
cd lukso-playground && bun install
```

### Run locally
### Run examples

Run the TypeScript code of one file within the terminal using `bun`.

```bash
bun file-path/script.ts
bun run file-path/script.ts
```

🆙 🔍 For example, to run the code example to fetch various metadata on a Universal Profile:

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

🗃️ This might return you among the values a list of `LSP5ReceivedAssets[]`:

```bash
# ...
{
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.
6 changes: 3 additions & 3 deletions digital-assets/extract-asset-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { ERC725 } from '@erc725/erc725.js';
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';
// https://docs.lukso.tech/networks/network/parameters
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
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
Loading