0

I am very new to Ethereum smart contract solidity programming. Currently, I have been facing this issue when I try to pass a variable from my Node.js servlet to the smart contract I deployed using Truffle Suite, specifically with accounts provided by Ganache.

Following is the JavaScript I used to connect and call the smart contract method:

if (this.state.contract) {
            this.state.contract.methods.searchKeyword(searchToken.toString())
                .send({from: this.state.account, gas: 210000, gasPrice: 50000}, function (err, res) {
                    if (err) {
                        console.log("Error", err)
                        return
                    }
                    console.log(res)
                })
        }

Following is the Solidity code in smart contract:

function searchKeyword (string memory searchToken) public {
        searchWord = searchToken;
    }

Whenever I call the function and pass searchToken , the following error pops up. I have tried setting the gas and gasPrice over, within, below the gasLimit of my MetaMask wallet but I am still getting errors like Exceeds block gas limit. I have tried without setting the gas and gasPrice but I am still getting the similar issue.

enter image description here

Any genius please help me this noob beginner who trying so hard to debug just a small little function. Thank you guys in advance :D

1
  • Did you try using more gas? I'd start with 5M gas, string are expensive.
    – Ismael
    Jul 17 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.