what is the abi? can you pun only the abi specific to that function?
here is function ABI
{
"inputs":[
{
"components":[
{
"internalType":"uint256",
"name":"profileId",
"type":"uint256"
},
{
"internalType":"string",
"name":"contentURI",
"type":"string"
},
{
"internalType":"address",
"name":"collectModule",
"type":"address"
},
{
"internalType":"bytes",
"name":"collectModuleInitData",
"type":"bytes"
},
{
"internalType":"address",
"name":"referenceModule",
"type":"address"
},
{
"internalType":"bytes",
"name":"referenceModuleInitData",
"type":"bytes"
}
],
"internalType":"struct DataTypes.PostData",
"name":"vars",
"type":"tuple"
}
],
"name":"post",
"outputs":[
{
"internalType":"uint256",
"name":"",
"type":"uint256"
}
],
"stateMutability":"nonpayable",
"type":"function"
},
:point_right:
[
this seems like a complex abi, you could try to edit the abi and remove that tuple so that it is a simple abi
Im also facing same issue here is code
address: DogAdress,
function_name: 'createCollectible',
abi: Abi,
Params: {_tokenURI: url },
};
// const price = ethers.utils.parseUnits(formInput.price, 'ether')
const mint =await Moralis.executeFunction(options)
console.log(mint)
await mint.wait()
thats my abi
```const Abi= {
"inputs": [
{
"internalType": "string",
"name": "_tokenURI",
"type": "string"
}
],
"name": "createCollectible",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
You should have your abi as such rather
[
{
"inputs": [
{
"internalType": "string",
"name": "_tokenURI",
"type": "string"
}
],
"name": "createCollectible",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
ok also Ive a question can we call contract function that require signer to sign a transaction but I dont why this method isnt working with wallet connect in mobile
this function need signer and still getting the same error
What is the error? Does it work in browser with MetaMask?
no jani Im posting whole code
// const Market = new ethers.Contract(marketplaceAddress, Marketplace.abi, library.getSigner())
// const Dog = new ethers.Contract(
// DogAdress,
// NFTDog.abi,
// library.getSigner()
// );
// // const price = ethers.utils.parseUnits(formInput.price, 'ether')
// const collectible = await Dog.createCollectible(url);
const Abi=[
{
"inputs": [
{
"internalType": "string",
"name": "_tokenURI",
"type": "string"
}
],
"name": "createCollectible",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
const options={
address: DogAdress,
function_name: 'createCollectible',
abi: Abi,
Params: {_tokenURI: url },
};
// const price = ethers.utils.parseUnits(formInput.price, 'ether')
const mint =await Moralis.executeFunction(options)
console.log(mint)
await mint.wait()
} else {
toast.error("O'ops youre missing a field");
setloading(false);
}
} else {
toast.error("connect wallet or check network");
setloading(false);
}
};```
what is the error that you get? what cause that error?
match undefined
MoralisWeb3.js:1681 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘match’)
at Function. (MoralisWeb3.js:1681:1)
at tryCatch (runtime.js:63:1)
at Generator.invoke [as _invoke] (runtime.js:294:1)
at Generator.next (runtime.js:119:1)
at asyncGeneratorStep (asyncToGenerator.js:5:1)
at _next (asyncToGenerator.js:27:1)
at asyncToGenerator.js:34:1
at new Promise ()
at new Wrapper (export.js:18:1)
at Function. (asyncToGenerator.js:23:1)
(anonymous) @ MoralisWeb3.js:1681
tryCatch @ runtime.js:63
invoke @ runtime.js:294
(anonymous) @ runtime.js:119
asyncGeneratorStep @ asyncToGenerator.js:5
_next @ asyncToGenerator.js:27
(anonymous) @ asyncToGenerator.js:34
Wrapper @ export.js:18
(anonymous) @ asyncToGenerator.js:23
(anonymous) @ MoralisWeb3.js:1849
main @ CreateProduct.js:201
await in main (async)
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4070
executeDispatch @ react-dom.development.js:8243
processDispatchQueueItemsInOrder @ react-dom.development.js:8275
processDispatchQueue @ react-dom.development.js:8288
dispatchEventsForPlugins @ react-dom.development.js:8299
(anonymous) @ react-dom.development.js:8508
batchedEventUpdates$1 @ react-dom.development.js:22396
batchedEventUpdates @ react-dom.development.js:3745
dispatchEventForPluginEventSystem @ react-dom.development.js:8507
attemptToDispatchEvent @ react-dom.development.js:6005
dispatchEvent @ react-dom.development.js:5924
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
discreteUpdates$1 @ react-dom.development.js:22413
discreteUpdates @ react-dom.development.js:3756
dispatchDiscreteEvent @ react-dom.development.js:5889
for authentication I was using web3-react but It wasnt working properly on mobile
are you sure this is the syntax with Params instead of params?
ok Ill try Thank you I will disturb you after
changed the syntax but still getting same error
sytax seem to be fine
this seems to work:
abi = [
{
"inputs": [
{
"internalType": "string",
"name": "_tokenURI",
"type": "string"
}
],
"name": "createCollectible",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
options = {
contractAddress: "0xaa462106dA447C0440a4bE29614c19387a59A331",
functionName: 'createCollectible',
abi: abi,
params: {_tokenURI: "32423" },
};
mint =await Moralis.executeFunction(options)
You could try to read documentation to see the exact parameters.
https://v1docs.moralis.io/moralis-dapp/web3/web3#example-of-calling-a-write-contract-method
I was putting (function_name )instead of functionName: ‘createCollectible’,
again saying uri is requried but Im passing uri in string format
I didn’t get any error with the code that I tested