Help wit calling Moralis.executeFunction, 'address is required' error

async function stake() {
await Moralis.enableWeb3();
var amt=document.getElementById("inpt").value*1000000000;
var add=document.getElementById("btn-login").value;
const bsc40_abi2 = [
{
 constant: false,
 inputs: [
   {
     internalType: 'address',
     name: 'address',
     type: 'address',
   },
   {
     internalType: 'uint256',
     name: '_amount',
     type: 'uint256',
   },
 ],
 name: 'customStaking',
 outputs: [
   {
     internalType: 'bool',
     name: 'success',
     type: 'bool',
   },
 ],
 payable: false,
 stateMutability: 'nonpayable',
 type: 'function',
},
];

let b = await Moralis.executeFunction({
contractAddress: '0xf8aDc852F8CaE4395d03AaBF5534051Bf4AEFAD1',
functionName: 'customStaking',
abi: bsc40_abi2,
params: {
 address:add,
 _amount:amt,
},
});
}

issue with this code showing (index):701

   Uncaught (in promise) ['address is required']0: "address is required"length: 1[[Prototype]]: Array(0)

stake @ (index):701
await in stake (async)
onclick @ (index):223

try to add some logging to see what is the value of those variables

Plzz help me with this code by giving me a preformated code

I can not do that, you have to be able to do basic debugging/logging. So that you understand what happens there.

This way you are going to ask for every small issue to give you an entire solution.

1 Like

I added address from ethaddress while amt with input box what i think is the error of abi there is written add which is adr

try to add logging with console.log to see if the input data has the expected value, you can also check in network tab in browser to see what parameters were sent to that web3api request, you can also log the parameters

after you log the parameters, you can check if they have the values that you expect them to have

Plzz help me i tried a lot but does not got it plzz help :sob::sob::sob::sob:

What does your code look like now and what error(s) are you getting?

My code is in html and js

What is your HTML/JS code and error? You need to add more details.