Skip to content

Easy deployments of LSP3UniversalProfile and LSP4DigitalCertificate contracts

License

Notifications You must be signed in to change notification settings

Parametry-ai/tools-lsp-factory

 
 

Repository files navigation

lsp-factory.js · GitHub license npm version PRs Welcome

@lukso/lsp-factory.js

Helper library to allow simple deployments of LSP3UniversalProfiles and LSP7 and LSP8 Digital Assets.

For more information see Documentation.

Install

npm install @lukso/lsp-factory.js

Setup

import { LSPFactory } from '@lukso/lsp-factory.js';

const provider = 'https://rpc.l14.lukso.network'; // RPC url used to connect to the network

const lspFactory = new LSPFactory(provider, {
  deployKey: '0x...'; // Private key of the account which will deploy UPs
  chainId: 22, // Chain Id of the network you want to connect to
});

Usage

Deploying an ERC725Account (Universal Profile)

// Deploy LSP3 Account
const myContracts = await lspFactory.LSP3UniversalProfile.deploy({
    controllerAddresses: ['0x...'], // Address which will controll the UP
    lsp3Profile: {
      json: {
        LSP3Profile: {
          name: "My Universal Profile",
          description: "My cool Universal Profile",
          profileImage: [
            {
              width: 500,
              height: 500,
              hashFunction: "keccak256(bytes)",
              // bytes32 hex string of the image hash
              hash: "0xfdafad027ecfe57eb4ad047b938805d1dec209d6e9f960fc320d7b9b11cbed14",
              url: "ipfs://QmPLqMFHxiUgYAom3Zg4SiwoxDaFcZpHXpCmiDzxrtjSGp",
            },
          ],
          backgroundImage: [
            {
              width: 500,
              height: 500,
              hashFunction: "keccak256(bytes)",
              // bytes32 hex string of the image hash
              hash: "0xfdafad027ecfe57eb4ad047b938805d1dec209d6e9f960fc320d7b9b11cbed14",
              url: "ipfs://QmPLqMFHxiUgYAom3Zg4SiwoxDaFcZpHXpCmiDzxrtjSGp",
            },
          ],
          tags: ['Fashion', 'Design'],
          links: [{ title: "My Website", url: "www.my-website.com" }],
        },
      },
      url: "",
    },
  });

const myUPAddress = myContracts.ERC725Account.address;

Using Deployment events

The deployReactive option can be used to for real-time frontend updates.

const profileDeploymentEvents = [];

const myUPAccount = await lspFactory.LSP3UniversalProfile.deploy({
    deployReactive: true
}).subscribe({
  next: (deploymentEvent: DeploymentEvent) => {
    profileDeploymentEvents.push(deploymentEvent);
  },
  error: (error) => {
    console.error(error);
  },
  complete: () => {
    console.log(profileDeploymentEvents);
  },
});

Contributing

Please check CONTRIBUTING.

License

lsp-factory.js is Apache 2.0 licensed.

About

Easy deployments of LSP3UniversalProfile and LSP4DigitalCertificate contracts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.2%
  • JavaScript 0.8%