[SOLVED] Params passed through write method of Moralis.executeFunction is not being read by smart contract

what is the error that you get? when you get that error?
can you provide full code?

It is not really an error but the parameter to is not being read by the initializeBundle function inside smart contract, so it is returing to is required.

Code

          const options = {
            functionName: 'initializeBundle',
            contractAddress: '0x19',
            abi: AssetWrapperABI.abi,
            params: { 
              to: nft.token_address
            }
          }

          const bundle = await Moralis.executeFunction(options)

          await bundle.wait(3);

try this:

const options = {
            functionName: 'initializeBundle',
            contractAddress: '0x19',
            abi: AssetWrapperABI.abi,
            to: nft.token_address
          }

Did tried that, but the issue remains the same, and by the way smart contract and server are up in Rinkeby testnet, if that helps.

did you try with runContractFunction?

I think runContractFunction is for read only functions, but I did tried it is throwing you can use only readOnly functions alike.

ok, you can try to use this for the abi:

{
  "inputs": [
    {
      "internalType": "address",
      "name": "to_2",
      "type": "address"
    }
  ],
  "name": "initializeBundle",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}

Same issue persists after testing your solution.

how did you test it? what is the error now?

I did made changes to smart contract as you suggested in abi redeployed the smart contract and tested, same to_2 is required is the message returned after request.

you didn’t have to redeploy the smart contract, only to change the abi

what parameters are you using now?

As you suggested the abi changes

can you paste the parameters that you use for executeFunction now?

Everything is same as above and just the change is abi as you suggested and I ran it by passing to_2 in params as well as outside as you suggested both the methods return same message to_2 is required.

can you give an exact example, so that I can test? maybe you deployed the smart contract somewhere on a testnet

I did deploy it on Rinkeby
testnet

ok, then if you provide the contract address and the parameters, I could easily test to see if it works or not

0x5988c47081265bef38b2f45c089b8c9f440fdbb1

Sorry for late reply

I didn’t get any error for this code:

abi1 = [{
  "inputs": [
    {
      "internalType": "address",
      "name": "to2",
      "type": "address"
    }
  ],
  "name": "initializeBundle",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}]

options = {
            functionName: 'initializeBundle',
            contractAddress: '0x5988c47081265bef38b2f45c089b8c9f440fdbb1',
            abi: abi1,
            params: { 
              to2: '0x5988c47081265bef38b2f45c089b8c9f440fdbb1'
            }
          }

bundle = await Moralis.executeFunction(options)

Works now I still didn’t get what was the problem here