When transferring Ether using the transfer function in Solidity, the funds are sent out of the sending address and are received by the contract address, as expected. However, instead of being passed on to the receiving address, the funds stay at the contract address and get stuck there.

I am on the Ropsten testnet and am using Truffle and Infura in this project.

This question has the exact same problem as I do, but neither of the answers solve my problem. In that question, the OP fixed their issue by deploying to Ropsten (however, they were on Remix), but I have already done that. I also don't think that my code is wrong, as it all compiles.

Smart Contract Code

struct Document {
  address payable uploader;
  // ...

Document[] public documents;

function purchaseDocument(uint256 docIndex) public payable {
  require(msg.sender != documents[docIndex].uploader && !isDocumentPurchased(docIndex), "Please purchase this document first");
  require(msg.value == documents[docIndex].fee, "Invalid amount paid");

  // Pay the uploader

  // ...

JSX File

purchaseDocument() {
  window.ethereum.enable().then(() => {
    web3.eth.getAccounts().then((accounts) => {
      this.account = accounts[0];
      this.DocuPay = new web3.eth.Contract(DocuPay.abi, DocuPay.address);

      // Purchase the document
        from: this.account,
        value: this.state.fee,
        gas: 5000000,
      .then(() => {
        this.setState({ canView: true });

How do I solve this? Thank you for your help!

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.