I have this piece of code working in nodeJS but when I try to run it in the plugin editor it does nothing and the console says it’s waiting for a promise.
I read about adding context.async but when I do that the plugin editor says it is invalid javascript. Can anyone help me format this correctly for Bubble to return the promise and execute the function, please?
const createDirectListing = async () => {
// The contract address of the NFT that will be auctioned
const nftCollectionAddress = "<collectionaddress>";
await marketplace.createDirectListing({
assetContractAddress: nftCollectionAddress,
buyoutPricePerToken: ethers.utils.parseUnits("1000"),
currencyContractAddress: "0xeb8f08a975Ab53E34D8a0330E0D34de942C95926",
listingDurationInSeconds: 60 * 60 * 24,
quantity: 1,
startTimeInSeconds: Math.floor(Date.now() / 1000),
tokenId: 0,
})
.then((data) => console.log(data))
.catch((error) => console.error(error));
};
assuming the “marketplace” variable is pre-defined, and that “< collectionaddress >” is just a placeholder for the actual fetch link that you don’t want to expose.
edit: resp.json should be resp.json()
You may have to JSON.Stringify() or .String() stuff and format things back and forth from JSON.