Skip to main content

MarketplaceHelper

The MarketplaceHelper class provides methods to interact with the MarketplaceHelper smart contract, including adding liquidity, registering media, and swapping tokens. This class is designed to facilitate interactions with Uniswap pools and manage media assets within a decentralized marketplace.

Class: MarketplaceHelper

The MarketplaceHelper class allows developers to interact with the MarketplaceHelper contract on the blockchain, enabling actions like adding liquidity to Uniswap pools, registering media, and executing token swaps.

Constructor

The constructor initializes an instance of the MarketplaceHelper class.

Parameters

  • sdkInstance: Sdk An instance of the SDK containing configuration details for interacting with the blockchain.

Throws

  • An error if the MarketplaceHelper contract address is not found for the current network ID.

Usage

const marketplaceHelper = new MarketplaceHelper(sdkInstance);

Attributes

config: SdkConfig

Contains the configuration for the SDK, which includes:

  • walletClient: A client used for managing wallet-based blockchain transactions.
  • publicClient: A client used for performing read-only interactions with the blockchain.

The config attribute is initialized using an instance of the Sdk class. It holds essential configuration details required for interacting with the MarketplaceHelper contract, facilitating both read and write operations within the blockchain environment. This attribute ensures that the class methods have access to the correct network, wallet, and public client configurations necessary for executing and simulating smart contract functions.

Methods

view

Reads data from the MarketplaceHelper contract.

  • Parameters:

  • functionName: string The name of the function to call.

  • args: any[] The arguments to pass to the function.

  • Returns: Promise<any> The result of the contract call.

  • Throws: Will throw an error if the contract call fails.

execute

Executes a transaction on the MarketplaceHelper contract.

  • Parameters:

  • functionName: string The name of the function to call.

  • args: any[] The arguments to pass to the function.

  • value: bigint (default: 0n) The value to send with the transaction.

  • Returns: Promise<any> The result of the transaction.

  • Throws: Will throw an error if the transaction fails.

wethToMedia

Encodes a Uniswap path to trade WETH for MEDIA with a given pool fee.

  • Parameters:

  • fee: FeeAmount The fee amount.

  • Returns: string The encoded path.

mediaToWeth

Encodes a Uniswap path to trade MEDIA for WETH with a given pool fee.

  • Parameters:

  • fee: FeeAmount The fee amount.

  • Returns: string The encoded path.

addLiquidityAndRegisterWithETH

Adds liquidity to the MEDIA/WETH Uniswap pool using ETH and utilizes the resulting NFT to register as provider of a given marketplace.

addLiquidityAndRegister

Adds liquidity to the MEDIA/WETH Uniswap pool using an ERC20 Token and utilizes the resulting NFT to register as provider of a given marketplace.

swapAndCreateDeal

Swaps tokens and creates a deal.

swapAndCreateDealWithETH

Swaps tokens and creates a deal using ETH.

swapAndCreateDeals

Swaps tokens and creates multiple deals.

swapAndCreateDealsWithETH

Swaps tokens and creates multiple deals using ETH.