Coder Social home page Coder Social logo

didi-ssi-blockchain-manager's Introduction

Blockchain manager

This library is intented to support multiblockchain configuration for the functionalities provided by uPort libraries (here). Based on the received DID and its prefix, it will select the blockchain to connect and support the uPort functions. Below there is a description of how to implement it.


Class Name

BlockchainManagerConfig

Parameters to instanciate the class

The class takes three parameters:

  • config: An object containing: { gasPrice: number, providerConfig: { object: PROVIDER_CONFIG} }
  • gasSafetyValue: A safety value to increment the gas to prevent the estimation getting short (type number)
  • gasPriceSafetyValue: A safety value to increment the gas price for the same reason (type number)

gasPrice: It's the gas price. For testing purposes a value of 10000 can be safely used.

providerConfig: It's a JSON object containing the network configurations to use when receiving the DID. The DIDs follow certain format and it should look like this:

did:ethr:0x0d0fa2cd3813412e94597103dbf715c7afb8c038
The above DID will route to the variable specified in mainnet

did:ethr:lacchain:0x0d0fa2cd3813412e94597103dbf715c7afb8c038
The above DID will route to the variable specified in lacchain

The providerConfig JSON must be similar to this:

PROVIDER_CONFIG = {
  networks: [
    { 
      name: 'mainnet', 
      rpcUrl: BLOCKCHAIN_URL_MAIN, 
      registry: BLOCKCHAIN_CONTRACT_MAIN
    },
    {
      name: 'lacchain',
      rpcUrl: BLOCKCHAIN_URL_LAC,
      registry: BLOCKCHAIN_CONTRACT_LAC
    },
    {
      name: 'bfa',
      rpcUrl: BLOCKCHAIN_URL_BFA,
      registry: BLOCKCHAIN_CONTRACT_BFA
    },
    {
      name: 'rsk',
      rpcUrl: BLOCKCHAIN_URL_RSK,
      registry: BLOCKCHAIN_CONTRACT_RSK
    }
  ]
};

NOTE 1: It is important to put the prefix on the DID, equal to the one in the JSON name attribute in order to route right. (for mainnet, no prefix must be entered)

NOTE 2: All of these variables must be defined in the .env file in the root folder.

Gas Increment value to increase the gas in the transaction for safeguard. By default is 1.1 (10%). This value can be defined in the ENV file as GAS_INCREMENT


For more information about DIDI project, see the documentation

didi-ssi-blockchain-manager's People

Contributors

fedelmar avatar awolfsdorf avatar matiasos avatar fsawadyatix avatar dbale-atix avatar doloresgarciae avatar claudio-uslenghi avatar csutherzircon 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.