Hi,
I’m using Moralis from a chrome extension using chrome-extension-cli
Everything works fine except the createBuyOrder
Here is what it’s showing:
The code:
const createMetaMaskProvider = require('metamask-extension-provider')
const Moralis = require('moralis');
const tokenAddress = '0x2542881b4ba691ab72e35670911de29f1e4ba166';
const tokenId = '24';
const userAddress = '0x8Daa2DE23ACD0e6571a91d4285C2877bFe901401';
const network = 'testnet';
class customConnector extends Moralis.AbstractWeb3Connector {
async activate() {
const provider = createMetaMaskProvider();
if (!provider) {
console.error("MetaMask provider not detected.");
throw new Error("MetaMask provider not detected.");
}
const [accounts, chainId] = await Promise.all([
provider.request({
method: 'eth_requestAccounts',
}),
provider.request({ method: 'eth_chainId' }),
]);
const account = accounts[0] ? accounts[0].toLowerCase() : null;
this.chainId = provider.chainId;
this.account = provider.selectedAddress;
this.provider = provider;
this.subscribeToEvents(provider);
return { provider, chainId, account };
}
}
async function main(){
const appId = "*********";
const serverUrl = "***********";
Moralis.start({ serverUrl, appId });
await Moralis.initPlugins();
await Moralis.authenticate({ connector: customConnector })
console.log('NEXT ')
await Moralis.Plugins.opensea.createBuyOrder({
network: 'testnet',
tokenAddress: tokenAddress,
tokenId: tokenId,
tokenType: 'ERC721',
amount: 0.0001,
userAddress: userAddress,
paymentTokenAddress: '0xc778417e063141139fce010982780140aa0cd5ab',
});
};
main();