Coder Social home page Coder Social logo

pinkdiamond1 / tools-lsp-factory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukso-network/tools-lsp-factory

0.0 1.0 0.0 4.79 MB

Easy deployments of LSP3UniversalProfile and LSP4DigitalCertificate contracts

License: Apache License 2.0

TypeScript 99.14% JavaScript 0.86%

tools-lsp-factory's Introduction

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 method can be used to for real-time frontend updates.

const profileDeploymentEvents = [];

const myUPAccount = await lspFactory.LSP3UniversalProfile.deployReactive({
    ...
}).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.

tools-lsp-factory's People

Contributors

callumgrindle avatar cj42 avatar dependabot[bot] avatar frozeman avatar hugoo avatar rryter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.