I'm trying to build a Student Management System Dapp,where data of students are taken from frontend and stored in smart contract. Why I'm getting this error,while I try to set value(name) to the field-name.What changes do I need to make? The below is my code please check what's wrong with it. The below is my App.js code


import React, { useState } from 'react';
import Web3 from 'web3';
import { simpleStorageAbi } from './abi/abis';
import './App.css';
const web3 = new Web3(Web3.givenProvider);
// contract address is provided by Truffle migration
const contractAddr = '0xd9145CCE52D386f254917e481eB44e9943F39138';
const SimpleContract = new web3.eth.Contract(simpleStorageAbi, contractAddr);
function App() {
  const [name, setName] = useState();
  const [getName, setGetName] = useState();

  //const [dept, setDept] = useState();
  //const [getDept, setGetDept] = useState();

  const handleSet = async (e) => {
    const accounts = await window.ethereum.enable();
    const account = accounts[0];
    const gas = await SimpleContract.methods.set(name).estimateGas();
    const result = await SimpleContract.methods.set(name).send({
      from: account,

  const handleGet = async (e) => {
    const result = await SimpleContract.methods.get().call();

return (
  <div className="App">
    <header className="App-header">
      <form onSubmit={handleSet}>
            onChange={ e => setName(e.target.value) } />
        <input type="submit" value="Set Name" />
        type="button" > 
        Get Name 
      { getName }
export default App;

The below is my Solidity code. SimpleStorage.sol

pragma solidity >=0.4.22 <0.9.0;
contract SimpleStorage{
    string name;
    string dept;
    uint phonenumber;
    string addresshome;
    string emailid;
    uint aadhar;
    string ipfshash1;
    string ipfshash2;
    string ipfshash3;
    string ipfshash4;
    constructor() public {
    function setname(string memory _name) public  returns(string memory){
    function getname() public view returns(string memory){
        return name;
    function getdept(string memory _dept) public pure returns(string memory){
        return _dept;
    function getphonenumber(uint _phonenumber) public pure returns(uint){
        return _phonenumber;
    function getaddresshome(string memory _addresshome) public pure returns(string memory){
        return _addresshome;
    function getemailid(string memory _emailid) public pure returns(string memory){
        return _emailid;
    function getaadhar(uint _aadhar) public pure returns(uint){
        return _aadhar;

1 Answer 1


Your contract has no function named set().

Your contract has a function named setname() instead.

(The same holds true for get() -> getname().)

  • oops ya I found that. My doubt now is where can I get my contract address in solidity?
    – Shru
    Commented Jun 4, 2021 at 13:39
  • index.js:298 Uncaught (in promise) Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced. Am getting this when I try to get my name back
    – Shru
    Commented Jun 4, 2021 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.