Skip to content

Latest commit

 

History

History

readme.md

Escrow

Escrow contract facilitates the secure exchange of assets between two parties by acting as a trusted intermediary that holds the assets until the conditions of the agreement are met.

The escrow smart contract allows two parties to exchange assets securely. The contract holds the assets until both parties agree and sign off on the transaction.

There are 4 actions available to interact with this smart contract:

  • initiate escrow and deposit assets
  • deposit assets
  • complete escrow
  • cancel escrow

Read more and live demo

Usage

To initialize the escrow, we need to initialize a provider, MeshTxBuilder and MeshEscrowContract.

import { BlockfrostProvider, MeshTxBuilder } from '@meshsdk/core';
import { MeshEscrowContract } from '@meshsdk/contracts';
import { useWallet } from '@meshsdk/react';

const { connected, wallet } = useWallet();

const provider = new BlockfrostProvider(APIKEY);

const meshTxBuilder = new MeshTxBuilder({
  fetcher: provider,
  submitter: provider,
});

const contract = new MeshEscrowContract({
  mesh: meshTxBuilder,
  fetcher: provider,
  wallet: wallet,
  networkId: 0,
});