How do I call a function of a deployed smart contract? Here is the deployed contract with a call function having two input parameters - user address and email id and it returns the user details. How do I make a new smart contract which gets the user details from a deployed smart contract without giving any input parameter (in this case - user address and email id)?

  //deployed contract
  struct User  {
    address  wallet_address;  
    string  userId;
    string  first_name;
    string  last_name;
    string  email_id;
    bool set;
    string private_key;


  mapping(address => User)  users; 
  mapping(string => address) walletAccount;
  mapping(address => uint) public balanceOf;

  function getUser(address _userAddress,string memory _emailId) public view returns(address,string memory,string memory,string memory,string memory,string memory){
       User memory user = users[_userAddress];

Thanks in advance

1 Answer 1

  1. You can send JSON RPC requests to the blockchain. For example:
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675",
"gas": "0x76c0", // 30400,
"gasPrice": "0x9184e72a000", // 10000000000000
"value": "0x9184e72a", // 2441406250
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"

Your function call details is in the data parameter.

This is the very manual way.

  1. There is some libraries like ethers or web3js. You can look at them, if you call your function programatically.

  2. You can also call remix or truffle etc. Google it like: remix call a deployed contract.

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.