0

I'm using a private network for deploying smart contracts and i want to interact with the deployed contracts that i have.

Soo im trying with this smart contract

    // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

contract saveDoc {
    

mapping (string => string) date;
mapping (string => string) filename;
mapping (string => address) owner;
mapping (string => string) savedHash;


function AddDoc(string calldata _hash, string calldata _filename, string calldata _date) public returns(string memory,string memory,string memory){
    string storage existsFile = savedHash[_filename];
    string storage existsHash = filename[_hash];
    require( keccak256(bytes(existsFile)) == keccak256(bytes("")), "File Already exists" );
    require( keccak256(bytes(existsHash)) == keccak256(bytes("")), "Hash Already exists" );
    date[_hash] = _date;
    filename[_hash] = _filename;
    owner[_filename] = msg.sender;
    savedHash[_filename] = _hash; 
    return(string(_date),string(_filename),string(_hash));
   
}

function GetDocbyHash(string memory _hash) public view returns (string memory , string memory , address) {
    string storage Rfilename = filename[_hash];
    string storage Rdate = date[_hash];
    address Rowner = owner[Rfilename];
    return (Rfilename , Rdate , Rowner);
}

function GetDocbyFile(string memory _filename) public view returns (string memory , string memory , address) {
   string storage RsavedHash = savedHash[_filename];
   string storage Rdate = date[RsavedHash];
   address Rowner = owner[_filename];
   
   return (RsavedHash , Rdate , Rowner);
}

}

There's no problem there , so it compiles and everything is good but when i try to interact with it i get the title error so i was searching of how i can get that raw transaction but i dont wo anywhere . Hope u can help with these..

3
  • Hi Clippo! Welcome to the Ethereum Stackexchange! What language are you using to interact with the contract? javascript, python, java... Usually you have to use a middleware to sign the transactions. For example with web3js you could use @truffle/hdwallet-provider.
    – Ismael
    Nov 24 at 5:27
  • I'm intented to only use javascript , if so can u gave a further explanation of it? In the docs they use eth_signer but i don't get it how to use it.
    – Clippo
    Dec 3 at 19:40
  • In general people use web3js + hdwallet-provider, another js alternative is ethers.js. The @truffle/hdwallet-provider examples are quite good.
    – Ismael
    2 days ago

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.