callsparameter required by the Brydge widget is simply a list of the necessary function calls that are executed in order to purchase and transfer any NFT to your customer. These calls should be quite similar to the external calls made to an ERC721 (or ERC1155) exchange protocol in a traditional NFT marketplace, except that Brydge handles the execution internally. To achieve this, we use a simple struct, the ICall, to organize the data. The following example will demonstrate how to create the array of ICalls needed to integrate the Brydge widget into your NFT marketplace.
NFTowned by address
buyerwith WETH using Zora's exchange contracts defined below:
sellerhas already created an ask for
NFTusing Zora's asks module, listing it for
setApprovalForModulefunction before they can create the ask.
setApprovalForAllfunctions before Zora can sell the token on behalf of the user. A buyer that is purchasing an NFT using an ERC20 token must approve the ERC20 transfer helper for the given currency and amount before Zora can execute the transaction.
fillAskfunction in Zora's AsksV1_1 contract
fillAskmethod cannot succeed because the Asks module will not be approved by the buyer yet.
encodeFunctionData(fragment, [values])method available in Ethers.js contract interfaces.
approvemethod from the WETH contract:
fillAsk. This method takes in 5 parameters: The NFT address, the token ID number of the specific NFT being purchased, the address of the currency used to purchase, the price of the NFT, and the finder's address (in our example there is no finder or finder's fee, so we set this to the zero address).
_valueparameter will simply be 0 because we are not making any calls that require a native currency.
callscan now be passed into the Brydge widget, and your customers can purchase NFTs straight from your marketplace cross-chain and cross-currency!