I created a smart contract and using the transaction function that We are using the free infura key(mainnet - https) for the provider. but the transaction takes 3 to 5 days. We send transaction less than five only per day, We have more balance in the account. Is any problem with the Free infura account?
We share our code here? Please help us
I created a smart contract and using the transaction function that We are using the free infura key(mainnet - https) for the provider. but the transaction takes 3 to 5 days. We send transaction less than five only per day, We have more balance in the account. Is any problem with the Free infura account? We share our code here? Please help us
`const { web3, Tx } = require("../includes/web3")
async function sendSignedTransactionsForContracts(data, senderAddress, senderPrivateKey) { let txObject = {}; let nonce = null; let gasPrice = null; return new Promise(async (resolve, reject) => { await Promise.all([web3.eth.getTransactionCount(senderAddress), web3.eth.getGasPrice()]) .then(result => { nonce = result[0]; gasPrice = result[1]; gasPrice = (parseInt(gasPrice) + parseInt(gasPrice / 2)).toString(); console.log(gasPrice); txObject = { from: senderAddress, nonce: web3.utils.toHex(nonce), data: data }; return web3.eth.estimateGas(txObject); }) .then(estimateGas => { txObject.gasPrice = web3.utils.toHex(gasPrice); txObject.gas = web3.utils.toHex(estimateGas); const tx = new Tx.Transaction(txObject, {'chain':'ropsten'}); const privateKey = Buffer.from(senderPrivateKey, 'hex'); tx.sign(privateKey); const serializedTx = tx.serialize(); const raw = '0x' + serializedTx.toString('hex'); web3.eth.sendSignedTransaction(raw, async (err, txHash) => { if (err) { reject(err) return } console.log('err:', err, 'txHash:', txHash) let getTransaction = setInterval(async () => { web3.eth.getTransactionReceipt(txHash, async function (error, result) { if (error) { clearInterval(getTransaction) console.log({ 'errrr': error }) reject(error) }
}
async function sendSignedTransactionsForMethods(data, contract_address, senderAddress, senderPrivateKey) {
} module.exports = { sendSignedTransactionsForContracts, sendSignedTransactionsForMethods }`