Транзакция многоугольника работает нормально в Мумбаи, но не в основной сети

Здравствуйте, я пытаюсь создать NFT с помощью Polygon, и он отлично работает в Мумбаи, но как только я переключаюсь на основную сеть, транзакция занимает 5 минут вместо 5 секунд, хотя я использую тот же самый контракт, только что развернутый в основной сети вместо Мумбаи и код тоже. Все, что я делаю, это переключаю адрес контракта и URL-адрес rpc, но по какой-то причине он просто не работает в основной сети Polygon, ниже - это код, который я использую.

      // Init contract
        const contractABI = require('../../contract-abi.json');
        const contractAddress = config.mintingContractAddress;
        const contract = await new this.web3.eth.Contract(contractABI, contractAddress);
        // Mint NFT
        const nft = contract.methods.mintNFT(user.walletAddress, metadataUploadURL, user.paymentAddress).encodeABI();
        // Get gas pricing
        const priorityFees = await axios.get('https://gasstation-mainnet.matic.network');
        const estBaseGas = await this.web3.eth.estimateGas({
          data: nft,
          to: contractAddress,
        });
        console.log('USING GAS: ' + estBaseGas);
        // Sign NFT minting transaction
        const totalGas = estBaseGas + priorityFees.data.standard;
        console.log('TOTALGAS: ', Math.round(totalGas).toString());
        const transaction = await this.web3.eth.accounts.signTransaction(
          {
            from: user.walletAddress,
            to: contractAddress,
            nonce: await this.web3.eth.getTransactionCount(user.walletAddress, 'pending'), // Get count of all transactions sent to the contract from this address including pending ones
            data: nft,
            // maxPriorityFee: priorityFees.data.average, Not supported on Polygon MATIC yet
            gas: Math.round(totalGas).toString(),
            gasPrice: await this.web3.eth.getGasPrice(),
          },
          wallet.privateKey,
        );
        this.logger.silly('Finished signing NFT transaction');
        // Send the transaction that we signed
        const mintT = await this.web3.eth.sendSignedTransaction(transaction.rawTransaction);
        this.logger.silly('Sent transaction');
        console.log(mintT);

Также пробовал это для подписи

      // Get gas pricing
        const priorityFees = await axios.get('https://gasstation-mainnet.matic.network');
        const estBaseGas = await this.web3.eth.estimateGas({
          data: nft,
          to: contractAddress,
        });
        console.log('USING GAS: ' + estBaseGas);
        // Sign NFT minting transaction
        const totalGas = estBaseGas + priorityFees.data.standard;
        console.log('TOTALGAS: ', Math.round(totalGas).toString());
        console.log('P', priorityFees.data.standard);
        const gp = this.web3.utils.toWei(priorityFees.data.standard.toString(), 'Gwei').toString();
        console.log('GP', gp);
        const transaction = await this.web3.eth.accounts.signTransaction(
          {
            from: user.walletAddress,
            to: contractAddress,
            nonce: await this.web3.eth.getTransactionCount(user.walletAddress, 'pending'), // Get count of all transactions sent to the contract from this address including pending ones
            data: nft,
            // maxPriorityFee: priorityFees.data.average, Not supported on Polygon MATIC yet
            gas: '1000000',
            gasPrice: gp,
          },
          wallet.privateKey,
        );

Обозреватель Mempool для транзакций, которые занимают много времени и почти мгновенно. Навсегда:Мгновенно:Один в основной сети, который использовал 30 гвэй газа:Кто-нибудь знает, почему это происходит? Также да, я знаю, что у быстрого есть 2 дополнительных gwei в газе, но даже если установить его вручную, это все равно займет вечность, и, согласно https://polygonscan.com/gastracker, даже с одним gwei он должен быть обработан в течение 30 секунд . Даже при использовании 50 Gwei кажется, что на обработку уходит часы или, может быть, он падает? Кажется, что транзакции даже не доходят до контракта, они просто застревают где-то в цепочке. адрес контракта: 0xa915E82285e6F82eD10b0579511F48fD716a2043

1 ответ

Вы можете протестировать с помощью простого кода, просто чтобы создать один NFT. Добавление параметров gasPrice и gasLimit непосредственно в функцию минтинга может помочь

       const hre = require("hardhat");
 async function main() {
     const NFT = await hre.ethers.getContractFactory("NFTNAME");
     const WALLET_ADDRESS = "0xxxxxxxxxxxxxx"
     const CONTRACT_ADDRESS = "0xa915E82285e6F82eD10b0579511F48fD716a2043"
     const contract = NFT.attach(CONTRACT_ADDRESS);
     mintedNFT = await contract.mintNFT(WALLET_ADDRESS,{ gasLimit: 285000, gasPrice: ethers.utils.parseUnits('30', 'gwei')});
     console.log("NFT minted:", mintedNFT);

}
main().then(() => process.exit(0)).catch(error => {
  console.error(error);
  process.exit(1);
});
Другие вопросы по тегам