Please check the Internal JSON RPC error

serverUrl = "https://myynzxr4i3m3.usemoralis.com:2053/server";
      appId = "KGwKgRJMd9ot6LcLRsMJDkMryITFbNtjnCI6C3vc";
      Moralis.start({ serverUrl, appId });


      /* Authentication code */

        async function login() {

              var user = await Moralis.authenticate({signingMessage:"Welcome to RWD Family,truly Karan Chaurasiya", chainId: 80001});
              if(user){
                console.log(user);
                console.log(user.get('ethAddress'));
                document.getElementById("btn-login").innerHTML=user.get('ethAddress');
                const ERC20_ABI2 = [
                {
                constant: true,
                inputs: [{ internalType: "address", name: "who", type: "address" }],
                name: "customStakingBalance",
                outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
                payable: false,
                stateMutability: "view",
                type: "function",
                },
                ];
                async function tsuply() {
                let res = await Moralis.Web3API.native.runContractFunction({
                chain: "mumbai",
                address: "0xf8aDc852F8CaE4395d03AaBF5534051Bf4AEFAD1",
                function_name: "customStakingBalance",
                abi: ERC20_ABI2,
                params: { who:user.get('ethAddress')},
                });
                console.log(res);
                const nu= Moralis.Units.FromWei(res, 9);
                console.log(nu)


                document.getElementById("res").innerHTML=nu+"RWD";
                const der = nu*0.137/100;
                const deci = der.toFixed(2);
                
                console.log(deci);
                document.getElementById("der").innerHTML= deci+"RWD";

                




              }
                tsuply();
                const ERC20_AI2 = [
                {
                constant: true,
                inputs: [{ internalType: "address", name: "wh", type: "address" }],
                name: "balanceOf",
                outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
                payable: false,
                stateMutability: "view",
                type: "function",
                },
                ];
                async function tsuly() {
                let re = await Moralis.Web3API.native.runContractFunction({
                chain: "mumbai",
                address: "0x72Eb2743691F486B795B582E350C16335B356998",
                function_name: "balanceOf",
                abi: ERC20_AI2,
                params: { wh:user.get('ethAddress')},
                });
                console.log(re);
                const num= Moralis.Units.FromWei(re, 9);
                console.log(num)


                document.getElementById("re").innerHTML=num+"RWD";



                }
                tsuly();


              }
            }



      document.getElementById("btn-login").onclick = login;

      ERC20_ABI = [
{
constant: true,
inputs: [],
name: "customTotalStaked",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
payable: false,
stateMutability: "view",
type: "function",
},
];
async function tsupply(){
x = await Moralis.Web3API.native.runContractFunction({
chain: "mumbai",
address: "0xf8aDc852F8CaE4395d03AaBF5534051Bf4AEFAD1",
function_name: "customTotalStaked",
abi: ERC20_ABI,

})
console.log(x);
const nub= Moralis.Units.FromWei(x, 9);
console.log(nub)


document.getElementById("x").innerHTML=nub+"RWD";}
tsupply();



</script>
<script>




async function run() {
await Moralis.enableWeb3();
var amt=document.getElementById("inpt").value*1000000000;
const bsc40_abi = [
{
 constant: false,
 inputs: [
   {
     internalType: 'address',
     name: '_spender',
     type: 'address',
   },
   {
     internalType: 'uint256',
     name: '_value',
     type: 'uint256',
   },
 ],
 name: 'approve',
 outputs: [
   {
     internalType: 'bool',
     name: 'success',
     type: 'bool',
   },
 ],
 payable: false,
 stateMutability: 'nonpayable',
 type: 'function',
},
];

let a = await Moralis.executeFunction({
contractAddress: '0x72Eb2743691F486B795B582E350C16335B356998',
functionName: 'approve',
abi: bsc40_abi,
params: {
 _spender: '0xf8aDc852F8CaE4395d03AaBF5534051Bf4AEFAD1',
 _value:amt,
},
});

const result = await a.wait();
console.log("result successful", result)
document.getElementById('approve').style.display = 'none';
document.getElementById('stake').style.display = 'inline';
document.getElementById('unstake').style.display = 'inline';


}
async function stake() {
await Moralis.enableWeb3();
var amt=document.getElementById("inpt").value*1000000000;
var adr=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:"0x4830edd0c016c556b48c0847e3b0b6b767f20de1",
 _amount:amt,
},
});
}

i am getting below error please help me with that and i am using the above js codeCapture

That error is directly from the contract. For what parameters do you get that error?

Customs taking function
Parameters address amount

Ok, so this one should be. Did you call approve before that?

This function should transfer an erc20 token for stake?

It could also fail on any other check that the function does in the contract.

Yaa approve is working fine

Doublecheck all your executeFunction parameters. It looks like customStaking does not take an address parameter, it only takes _amount.

You can post your contract code also, it may be an issue with the code.

Yes it takes 1 parameter but from where it should it take address

I got the result thanks bro

1 Like