execute takes one Argument as NearExecuteOptions and also one or more NearContractCall
exporttypeNearExecuteOptions= {// wallet wallet:Wallet;// contract address account:Account;// the page url that you want the user to be redirected after the success of the transaction. Must include full url ex:// https://www.mintbase.xyz/success callbackUrl?:string;// Object that accepts desired arguments to be passed through the URL so you can get them to use in the success page callbackArgs?: { arg:string arg2:number }; }
callbackUrl:
this argument can be set within mbjs.config ( globally ), thus if passed globally theres no need to be passed in the first obj argument. or in the execute method. it must be passed in full url. ex: "https://www.yourwebsite.xyz/success"
callbackArgs:
Optional object that will be passed as an argument on the url, ex: "https://www.yourwebsite.xyz/success?signMeta=arg1:XYZ"
React example
Example usage of list method in a hypothetical React component:
ListComponent.ts
import { useState } from'react';import { useWallet } from'@mintbase-js/react';import { execute, list, ListArgs } from'@mintbase-js/sdk';exportconstListComponent= ({ contractAddress, marketAddress , tokenId, price }:ListArgs):JSX.Element=> {const { selector } =useWallet();consthandleList=async ():Promise<void> => {constwallet=awaitselector.wallet();constcallBackArgs= { autotransfer:true, metadataId: id, contractId: address, }constcallback= { args: callBackArgs, type:TransactionSuccessEnum.SIMPLE_SALE_LIST }// 1. using callbackUrl + callbackArgsconstreceipt=awaitexecute( {wallet, callbackUrl:'https://www.mintbase.xyz/success', callbackArgs},list({ contractAddress: nftContractId, marketAddress: marketId, tokenId: tokenId, price: price }) )// 2. using callbackArgs, and set mbjs.config({callbackUrl: 'https://www.mintbase.xyz/success' }) on main app.tsxconstreceipt=awaitexecute( {wallet, callbackArgs},list({ contractAddress: nftContractId, marketAddress: marketId, tokenId: tokenId, price: price }) )// 3.not using callbackArgs neither callbackUrl// IF You decide to go by this approach:// - Browser Wallets (Near Wallet, My Near Wallet): will redirect to the previous page with transactionsHash param// - Injected Wallets (Meteor,Sender, etc) will return a receipt objectconstreceipt=awaitexecute( {wallet},list({ contractAddress: nftContractId, marketAddress: marketId, tokenId: tokenId, price: price }) )console.log(receipt,'receipt')return ( <div><button onClick={handleList}> DeployContract with name= {name} and owner= {owner}</button></div> );};