arrows-up-to-line5.3 Submit DApp to InsuranceDAO.World

Now that your setup is complete, you’re ready to integrate InsuranceDAO.World into your DApp. This chapter guides you through submitting your DApp for insurance coverage, purchasing and verifying Verified Nodes, and ensuring your DApp is properly insured.

To integrate your DApp with InsuranceDAO.World, you need to register your DApp through the InsuranceDAO smart contracts. This process links your DApp to an appropriate Verified Node for coverage. Here’s how to submit your DApp for insurance:

Step 1: Register Your DApp

To start, you need to register your DApp with InsuranceDAO.World by interacting with the smart contract. This registration ensures that your DApp is linked to the correct insurance pool for coverage.

Code Example: Register DApp

// const anchor = require('@project-serum/anchor');
const { PublicKey, SystemProgram } = require('@solana/web3.js');

async function submitDAppToInsuranceDAO(connection, payer, dappId, insurancePoolId) {
  const program = anchor.workspace.InsuranceDAO;
  const dapp = await program.account.dApp.fetch(dappId); // Fetch DApp details

  const transaction = new anchor.web3.Transaction();
  
  // Step 1: Initialize DApp registration
  transaction.add(
    program.instruction.submitDApp(
      dappId, 
      insurancePoolId, 
      {
        accounts: {
          dApp: dapp.publicKey,
          payer: payer.publicKey,
          systemProgram: SystemProgram.programId,
        },
      }
    )
  );

  // Step 2: Send the transaction to register the DApp
  const signature = await connection.sendTransaction(transaction, [payer], { skipPreflight: false, preflightCommitment: 'confirmed' });
  console.log(`Transaction confirmed with signature: ${signature}`);
}

Explanation:

• The submitDAppToInsuranceDAO function submits your DApp for registration.

dappId and insurancePoolId are used to identify your DApp and the corresponding insurance pool.

• The submitDApp function handles the registration within InsuranceDAO.World.

Last updated