Hi, I have a gas error, if I put the gas in it the transaction is never executed, but if I remove the gasLimit or price it stays and never exits the function, I attach the connected contract what it returns, i need tokenId the function return tokenId.
function:
async function mintNFTEmail(metadataUrl: string, tokenAddress: string) {
try {
const ethers = Moralis.web3Library;
console.log('resTx')
const royal = 20 * 2000;
const ethAddress = userRender.attributes?.ethAddress ? userRender.attributes.ethAddress.toString().toLowerCase() : "";
const privateKey = userRender.attributes?.privateKey
? userRender.attributes.privateKey
: "";
const mnemonic = userRender.attributes?.mnemonic ? userRender.attributes.mnemonic : "";
const contractTokenKNRT = contracts.token.toString().toLowerCase();
const collectionAddress = tokenAddress.toString().toLowerCase();
const provider = new ethers.providers.JsonRpcProvider(`${urlProvider}${apiAlchemy}`);
const signer = new ethers.Wallet(privateKey, provider);
const sendOptions2 = [
ethAddress,
ethAddress,
royal,
ethAddress,
metadataUrl,
0,
contractTokenKNRT,
'0',
'0',
'0x0000000000000000000000000000000000000000000000000000000000000000'
]
const contract = new ethers.Contract(tokenAddress, tokenErc721, provider);
const tx = await contract.connect(signer).createItem(sendOptions2, { gasLimit: 9000000, gasPrice: 1000000 });
const tokenId = await tx.wait(1);
// console.log('resTx', parseInt(tokenId.events[1].args[1]._hex, 16).toString())
return 123 //parseInt(tokenId.events[1].args[1]._hex, 16).toString()
}catch (e: any) {
console.log("ErrorMintNFT1", e)
console.log("ErrorMintNFT2", e.message)
return "-1";
}
}
tx response:
mintNFTEmail ~ tx
{type: 2, chainId: 80001, nonce: 71, maxPriorityFeePerGas: BigNumber, maxFeePerGas: BigNumber, …}
accessList: []
chainId: 80001
confirmations: 0
data: “0x52258eaf0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000f7fdd1a239a6fbca88ac8aaf97a174831d91bde3000000000000000000000000f7fdd1a239a6fbca88ac8aaf97a174831d91bde30000000000000000000000000000000000000000000000000000000000009c40000000000000000000000000f7fdd1a239a6fbca88ac8aaf97a174831d91bde30000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011142365ddbc92c3547b8a074289409b5432ca8b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005068747470733a2f2f697066732e6d6f72616c69732e696f3a323035332f697066732f516d62726f50465168395147354d31625157443438326d645a3838784a6b517a6d3657413835654a53444d69763900000000000000000000000000000000”
from: “0xf7fDd1a239A6FBCA88ac8AaF97A174831d91bDe3”
gasLimit: BigNumber
1. _hex: "0x0dbba0" 2. _isBigNumber: true 3. [[Prototype]]: Object
- gasPrice: null
- hash: “0x53153545def65e90ee6a4fcb1f5e0869ea17fc9904e48a6bf18eb84f61542b64”
- maxFeePerGas: BigNumber
1. _hex: "0x0f4240" 2. _isBigNumber: true 3. [[Prototype]]: Object
- maxPriorityFeePerGas: BigNumber
1. _hex: "0x0f4240" 2. _isBigNumber: true 3. [[Prototype]]: Object
- nonce: 71
- r: “0x8307fc3e44c29b9d52a46f6048adec9be9dbe5c813c95c42a309f6d94f708fd5”
- s: “0x06c85b4c7193043d604d806f493c4237f3ff30cc9271638f1d83e253d8bce9a6”
- to: “0x1C7d04C4DDEE4d13c31E800568039AcEabDCc3C8”
- type: 2
- v: 1
- value: BigNumber
1. _hex: "0x00" 2. _isBigNumber: true 3. [[Prototype]]: Object
- wait: (confirmations) => {…}
1. length: 1 2. name: "" 3. arguments: (...) 4. caller: (...) 5. [[FunctionLocation]]: index.js:236 6. [[Prototype]]: ƒ ()
- [[Prototype]]: Object