diff --git a/README.md b/README.md index 1bb282d..985cc19 100644 --- a/README.md +++ b/README.md @@ -2,34 +2,25 @@ 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. -### IPFS Servers - -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: - -- IPFS Gateway: `https://api.universalprofile.cloud/ipfs` - -> LUKSO does not provide an official gateway for uploading asset data. - ## Contents -- [`convenience`](./convenience): Address Checks and EOA creation -- [`create-profile`](./create-profile): Universal Profile Creation +- [`universal-profile`](./universal-profile): Universal Profile - [`extract-data`](./extract-data): Extract LSP3 and LSP4 JSON Data - [`fetch-asset`](./fetch-asset): Asset-related Data Fetches and Operations -- [`fetch-profile`](./fetch-profile): Profile-related Data and Controller Fetches - [`hardhat-deploy`](./hardhat-deploy): Smart Contract Deployment Setup and 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 Exetnsion - [`transfer-token`](./transfer-token/): Token Transfers for Backend and Exetnsion -- [`update-profile`](./update-profile/): Update Universal Profile Data ### LUKSO Libraries -- [`@erc725/erc725.js`](https://docs.lukso.tech/tools/erc725js/getting-started): 0.22.0 -- [`@lukso/lsp-factory.js`](https://docs.lukso.tech/tools/lsp-factoryjs/getting-started): 3.1.1 -- [`@lukso/lsp-smart-contracts`](https://docs.lukso.tech/tools/lsp-smart-contracts/getting-started): 0.14.0 +- [`@erc725/erc725.js`](https://docs.lukso.tech/tools/erc725js/getting-started) +- [`@lukso/lsp-factory.js`](https://docs.lukso.tech/tools/lsp-factoryjs/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 @@ -53,6 +44,14 @@ Run the Typescript code of one file within the terminal using `bun`. bun file-path/script.ts ``` +## 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: + +- IPFS Gateway: `https://api.universalprofile.cloud/ipfs` + +> LUKSO does not provide an official gateway for uploading asset data. + ### Run in browser Open this project on [StackBlitz](https://stackblitz.com/github/lukso-network/lukso-playground) and start coding right away. diff --git a/convenience/check_address.ts b/convenience/check_address.ts deleted file mode 100644 index 03ccf76..0000000 --- a/convenience/check_address.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Imports -import { ethers } from 'ethers'; - -// Static variables -const SAMPLE_PROFILE_ADDRESS = '0x9139def55c73c12bcda9c44f12326686e3948634'; - -/* - * Check if input is a valid blockchain address - * - * @param address input - * @return boolean result - */ -async function isValidAddress(address) { - try { - // Create an Ethereum Address object - const ethereumAddress = ethers.utils.getAddress(address); - - // Check if the address is a valid Ethereum address - return ethereumAddress === address; - } catch (error) { - return false; - } -} - -// Debug -isValidAddress(SAMPLE_PROFILE_ADDRESS) - .then((result) => console.log(result)) - .catch((error) => console.error(error)); diff --git a/convenience/create-eoa.js b/convenience/create-eoa.js deleted file mode 100644 index 475e585..0000000 --- a/convenience/create-eoa.js +++ /dev/null @@ -1,8 +0,0 @@ -// Imports -import { ethers } from 'ethers'; - -// Create an Ethereum wallet -const wallet = ethers.Wallet.createRandom(); - -// Print the wallet information -console.log(wallet); diff --git a/extract-data/extract-asset-data.ts b/extract-data/extract-asset-data.ts index 6a50ff2..56b0d38 100644 --- a/extract-data/extract-asset-data.ts +++ b/extract-data/extract-asset-data.ts @@ -1,4 +1,3 @@ -// Imports import { ERC725 } from '@erc725/erc725.js'; import LSP4Schema from '@erc725/erc725.js/schemas/LSP4DigitalAsset.json'; import 'isomorphic-fetch'; diff --git a/hardhat-deploy/README.md b/hardhat-deploy/README.md index a2f9035..2cf39b7 100644 --- a/hardhat-deploy/README.md +++ b/hardhat-deploy/README.md @@ -1,6 +1,6 @@ # Basic sample hardhat project -This project is used as a guide to show how to setup hardhat to work with LUKSO. You can find more info here: [Hardhat guide](https://docs.lukso.tech/guides/hardhat-walkthrough/hardhat-base-setup) +This project is used as a guide to show how to setup hardhat to work with LUKSO. You can find more info here: [Hardhat guide](https://docs.lukso.tech/learn/smart-contract-developers/getting-started) ```bash npm i diff --git a/interface-detection/erc165-interface-check.ts b/interface-detection/erc165-interface-check.ts index a55edfd..a508b81 100644 --- a/interface-detection/erc165-interface-check.ts +++ b/interface-detection/erc165-interface-check.ts @@ -1,10 +1,11 @@ -// Imports import { ethers } from 'ethers'; import { ERC725 } from '@erc725/erc725.js'; import lsp4Schema from '@erc725/erc725.js/schemas/LSP4DigitalAsset.json'; import UniversalProfile from '@lukso/lsp-smart-contracts/artifacts/UniversalProfile.json'; import { INTERFACE_IDS } from '@lukso/lsp-smart-contracts'; +// https://docs.lukso.tech/contracts/interface-ids + // Asset Example const myAsset = new ERC725( lsp4Schema, diff --git a/key-manager/README.md b/key-manager/README.md new file mode 100644 index 0000000..6c2a5b6 --- /dev/null +++ b/key-manager/README.md @@ -0,0 +1,4 @@ +# Key Manager + +- [What is the Key Manager?](https://docs.lukso.tech/standards/universal-profile/lsp6-key-manager) +- diff --git a/key-manager/set-permissions.ts b/key-manager/set-permissions.ts index 16fcb34..6522f54 100644 --- a/key-manager/set-permissions.ts +++ b/key-manager/set-permissions.ts @@ -1,4 +1,3 @@ -// Imports import { ethers } from 'ethers'; import { PERMISSIONS, diff --git a/transfer-lyx/README.md b/transfer-lyx/README.md new file mode 100644 index 0000000..7f536b1 --- /dev/null +++ b/transfer-lyx/README.md @@ -0,0 +1,3 @@ +# Transfer LYX + +- https://docs.lukso.tech/learn/dapp-developer/transfer-lyx diff --git a/transfer-lyx/backend-lyx-transaction.ts b/transfer-lyx/backend-lyx-transaction.ts index 9af0f75..15b5280 100644 --- a/transfer-lyx/backend-lyx-transaction.ts +++ b/transfer-lyx/backend-lyx-transaction.ts @@ -1,4 +1,3 @@ -// Imports import { ethers } from 'ethers'; import UniversalProfile from '@lukso/lsp-smart-contracts/artifacts/UniversalProfile.json'; diff --git a/transfer-lyx/regular-lyx-transaction.ts b/transfer-lyx/regular-lyx-transaction.ts index 0465c2e..b7b9478 100644 --- a/transfer-lyx/regular-lyx-transaction.ts +++ b/transfer-lyx/regular-lyx-transaction.ts @@ -1,9 +1,11 @@ -// Imports import { ethers } from 'ethers'; // Check if the Ethereum provider is available +// @ts-expect-error This is for the browser const provider = new ethers.BrowserProvider(window.ethereum); +// https://docs.lukso.tech/learn/dapp-developer/transfer-lyx + try { // Request user accounts (connect to wallet) const accounts = await provider.send('eth_requestAccounts', []); diff --git a/transfer-token/README.md b/transfer-token/README.md new file mode 100644 index 0000000..f561b63 --- /dev/null +++ b/transfer-token/README.md @@ -0,0 +1,3 @@ +# Transfer tokens + +- https://docs.lukso.tech/learn/dapp-developer/transfer-lsp7-token diff --git a/transfer-token/backend-token-transaction.ts b/transfer-token/backend-token-transaction.ts index fe3fac6..d46d513 100644 --- a/transfer-token/backend-token-transaction.ts +++ b/transfer-token/backend-token-transaction.ts @@ -1,4 +1,3 @@ -// Imports import { ethers } from 'ethers'; import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json'; import UniversalProfile from '@lukso/lsp-smart-contracts/artifacts/UniversalProfile.json'; diff --git a/transfer-token/regular-token-transaction.ts b/transfer-token/regular-token-transaction.ts index 9941392..35c6e88 100644 --- a/transfer-token/regular-token-transaction.ts +++ b/transfer-token/regular-token-transaction.ts @@ -2,6 +2,7 @@ import { ethers } from 'ethers'; import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json'; // Connect to Ethereum via MetaMask or similar +// @ts-expect-error This is for the browser const provider = new ethers.BrowserProvider(window.ethereum); try { diff --git a/universal-profile/README.md b/universal-profile/README.md new file mode 100644 index 0000000..04e996f --- /dev/null +++ b/universal-profile/README.md @@ -0,0 +1,3 @@ +# Universal Profile + +- https://docs.lukso.tech/standards/universal-profile/introduction diff --git a/create-profile/create-EOA.ts b/universal-profile/create-EOA.ts similarity index 98% rename from create-profile/create-EOA.ts rename to universal-profile/create-EOA.ts index 006e8d4..c1f9084 100644 --- a/create-profile/create-EOA.ts +++ b/universal-profile/create-EOA.ts @@ -1,4 +1,3 @@ -// Imports import { ethers } from 'ethers'; // Static variables diff --git a/create-profile/create-up.ts b/universal-profile/create-up.ts similarity index 93% rename from create-profile/create-up.ts rename to universal-profile/create-up.ts index 16ab3b2..3ab1863 100644 --- a/create-profile/create-up.ts +++ b/universal-profile/create-up.ts @@ -1,10 +1,9 @@ -// Imports import { LSPFactory } from '@lukso/lsp-factory.js'; import { ethers } from 'ethers'; -// Static variables +// https://docs.lukso.tech/networks/testnet/parameters const RPC_ENDPOINT = 'https://rpc.testnet.lukso.network'; -const CHAIN_ID = 4201; +const CHAIN_ID = 4201; // LUKSO testnet const PRIVATE_KEY = '0x...'; // Add the private key of your EOA from ../convenience/create-eoa.js // Initialize ethers.js provider diff --git a/extract-data/extract-profile-data.ts b/universal-profile/extract-profile-data.ts similarity index 96% rename from extract-data/extract-profile-data.ts rename to universal-profile/extract-profile-data.ts index 574ef27..de75433 100644 --- a/extract-data/extract-profile-data.ts +++ b/universal-profile/extract-profile-data.ts @@ -1,4 +1,3 @@ -// Imports import { ERC725 } from '@erc725/erc725.js'; import erc725schema from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.json'; import 'isomorphic-fetch'; @@ -13,12 +12,12 @@ const SAMPLE_PROFILE_ADDRESS = '0x9139def55c73c12bcda9c44f12326686e3948634'; const config = { ipfsGateway: IPFS_GATEWAY }; // Fetchable metadata information -let name; -let description; -let links = []; -let firstLinkTitle; -let firstLinkURL; -let tags = []; +let name: string; +let description: string; +let links: any = []; +let firstLinkTitle: string; +let firstLinkURL: string; +let tags: string[] = []; let firstTag; // Fetchable picture information diff --git a/fetch-profile/fetch-json-data.ts b/universal-profile/fetch-json-data.ts similarity index 100% rename from fetch-profile/fetch-json-data.ts rename to universal-profile/fetch-json-data.ts diff --git a/fetch-profile/get-controller-permissions.ts b/universal-profile/get-controller-permissions.ts similarity index 100% rename from fetch-profile/get-controller-permissions.ts rename to universal-profile/get-controller-permissions.ts diff --git a/fetch-profile/get-data-keys.ts b/universal-profile/get-data-keys.ts similarity index 100% rename from fetch-profile/get-data-keys.ts rename to universal-profile/get-data-keys.ts diff --git a/update-profile/sample-metadata.json b/universal-profile/sample-metadata.json similarity index 100% rename from update-profile/sample-metadata.json rename to universal-profile/sample-metadata.json diff --git a/update-profile/update-profile-data.ts b/universal-profile/update-profile-data.ts similarity index 98% rename from update-profile/update-profile-data.ts rename to universal-profile/update-profile-data.ts index bc7f328..a614e47 100644 --- a/update-profile/update-profile-data.ts +++ b/universal-profile/update-profile-data.ts @@ -1,4 +1,3 @@ -// Imports import { ethers } from 'ethers'; import { ERC725 } from '@erc725/erc725.js'; import { LSPFactory } from '@lukso/lsp-factory.js'; @@ -8,7 +7,7 @@ import KeyManager from '@lukso/lsp-smart-contracts/artifacts/LSP6KeyManager.json // Static variables const RPC_ENDPOINT = 'https://rpc.testnet.lukso.gateway.fm'; const IPFS_GATEWAY = 'https://api.universalprofile.cloud/ipfs'; -const CHAIN_ID = 2828; +const CHAIN_ID = 4201; const PRIVATE_KEY = '0x...'; // Replace with your private key const UNIVERSAL_PROFILE_ADDRESS = '0x...'; // Replace with the Universal Profile address