Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

606
Views
Error: Transaction reverted without a reason string

Solidity File:-


import "hardhat/console.sol";

contract DStorage {
  string public name = 'DStorage';
  uint public fileCount;
  mapping(uint => File) public files;

  struct File {
    uint fileId;
    string fileHash;
    uint fileSize;
    string fileType;
    string fileName;
    string fileDescription;
    uint uploadTime;
    address  uploader;
  }

  event FileUploaded(
    uint fileId,
    string fileHash,
    uint fileSize,
    string fileType,
    string fileName,
    string fileDescription,
    uint uploadTime,
    address  uploader
  );

  constructor() { // <——— Has 0 arguments
        fileCount=0;
    }

  function uploadFile(string memory _fileHash, uint _fileSize, string memory _fileType,
  string memory _fileName, string memory _fileDescription) public {
    // Make sure the file hash exists
    require(bytes(_fileHash).length > 0);
    // Make sure file type exists
    require(bytes(_fileType).length > 0);
    // Make sure file description exists
    require(bytes(_fileDescription).length > 0);
    // Make sure file fileName exists
    require(bytes(_fileName).length > 0);
    // Make sure uploader address exists
    require(msg.sender!=address(0));
    // Make sure file size is more than 0
    require(_fileSize>0);

    // Increment file id
    fileCount ++;
    // Add File to the contract
    files[fileCount] = File(fileCount, _fileHash, _fileSize, _fileType, _fileName, _fileDescription, block.timestamp,msg.sender);
    // Trigger an event
    emit FileUploaded(fileCount, _fileHash, _fileSize, _fileType, _fileName, _fileDescription, block.timestamp,msg.sender);
  }
}

Calling By Ether.js:-

  const upload = async () => {
    const reader = new window.FileReader();
    reader.readAsArrayBuffer(inputfile);
    reader.onload = async () => {
      const result = await ipfs.add(reader.result);
      contract.uploadFile(result.path, result.size, type, name, "Upload by Ankit")
        
    };
  };

<button onClick={upload} className="upload-btn">
        Upload
      </button>

When i Clicked Upoad button Upload function called and i have file details which i am uploading to ipfs and send the details to blockchain by contract.upload(....details) but i am getting error

{code: -32603, message: 'Internal JSON-RPC error.', data: {…}}
code: -32603
data: {code: -32603, message: 'Error: Transaction reverted without a reason string'}
message: "Internal JSON-RPC error."
[[Prototype]]: Object**

image:- ERROR IMAGE

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!