admin管理员组

文章数量:1333616

I am trying to use a function I made in solidity in python. The call in python calls a function in responder.sol, which then calls a function in patient_hospital.sol. I need help find why my code goves an error of type error. I'm a beginner and have no idea what this issue could be from and I need some help! If anyone could give me an idea of how to debug and find what my error could be from, that would be greatly appreciated. Is it an issue of me using interface and calling another function from another file? How do I fix that if that is the case. Or is it because I'm using the wrong variables somewhere ?

Code in python:

from brownie import accounts, EMSights, Responder
    dispatcher = accounts[0]
    responder_owner = accounts[1]
    patient = accounts[2]
    responder2_owner = accounts[3]
    patient2 = accounts[4]

    # Deploy the EMSights contract
    print("\nDeploying EMSights contract...")
    emsights_contract = EMSights.deploy({"from": dispatcher})
    print("Dispatcher:", dispatcher)

    # Deploy a Patient_Hospital contract for patient information retrieval
    print("\nDeploying Patient_Hospital contract for patient information retrieval...")
    patient_hospital_contract = Patient_Hospital.deploy(
        responder_owner, 
        "ResponderPublicKeyTEST", 
        patient, 
        {"from": dispatcher}
    )
    print("Mock Hospital Address:", patient_hospital_contract.address)

    # Create a responder contract instance with EMSights
    print("\nCreating Responder One contract...")
    responder_one_tx = emsights_contract.createResponderContract(
        "Responder One",
        "privateIPFSAddress",
        responder_owner.address, 
        patient.address,
        patient_hospital_contract.address,
        "patientPublicKey",
        {"from": dispatcher}
    )

    # Create a second responder contract instance for testing transfer
    print("\nCreating Responder Two contract...")
    responder_two_tx = emsights_contract.createResponderContract(
        "Responder Two",                   
        "privateIPFSAddress2",                 
        responder2_owner.address, 
        patient2.address,                  
        patient_hospital_contract.address,
        "NewResponderPublicKey",           
        {"from": dispatcher}               
    )

     # Test patient information retrieval via responder contract
    print("\nTesting patient info retrieval...")
    print("responder 2 patient public key:", responder_contract_one.responderInfo(responder_owner.address)["assignedPatientPublicKey"])
    
    print("test get assigned patient public key:", responder_contract_one.getAssignedPatientPublicKey(responder_owner))
    patient_info = responder_contract_one.getPatientInfo(responder_owner.address, {"from": responder_owner})
    print("Patient Info:", patient_info)

 
def main():
    test_emsights_responder()

Responder.sol:

interface IPatientHospital {
    function requestInformation() external view returns (string memory, string memory);
} 
contract Responder{
    struct ResponderInfo{
        string name;
        string privateIPFSAddress;
        address EMSights;
        address contractOwner;
        address assignedPatient;
        address assignedPatientHospital;
        string assignedPatientPublicKey;
    }
    
    mapping(address => ResponderInfo) public responderInfo;
   
    function getName() public view returns (string memory) {
        return responderInfo[msg.sender].name;
    }
    function getAssignedPatientPublicKey() public view returns (string memory) {
        return responderInfo[msg.sender].assignedPatientPublicKey;
    }
    function getPatientInfo() public view returns (string memory, string memory) {
        IPatientHospital patientHospitalContract = IPatientHospital(responderInfo[msg.sender].assignedPatientHospital);
        return patientHospitalContract.requestInformation();
    }

}`


patient_hospital.sol:
`    function requestInformation() public view  returns (string memory, string memory){
        string memory responderName = responderContract.getName();
        string memory assignedPatientPublicKey = responderContract.getAssignedPatientPublicKey();
        return (responderName, assignedPatientPublicKey);
    }

This is my error:

Testing patient info retrieval...

Testing patient info retrieval...
responder 2 patient public key: patientPublicKey
test get assigned patient public key: patientPublicKey
  File "C:\Users\Ashley\Documents\GitHub\EMSights\.venv\Lib\site-packages\brownie\_cli\run.py", line 51, in main
    return_value, frame = run(
  File ".\emsights_responder.py", line 103, in test_emsights_responder
    patient_info = responder_contract_one.getPatientInfo(responder_owner.address, {"from": responder_owner})
  File "C:\Users\Ashley\Documents\GitHub\EMSights\.venv\Lib\site-packages\brownie\network\multicall.py", line 139, in _proxy_call
    result = ContractCall.__call__(*args, **kwargs)  # type: ignore
  File "C:\Users\Ashley\Documents\GitHub\EMSights\.venv\Lib\site-packages\brownie\network\contract.py", line 1833, in __call__
    return self.call(*args, block_identifier=block_identifier, override=override)
  File "C:\Users\Ashley\Documents\GitHub\EMSights\.venv\Lib\site-packages\brownie\network\contract.py", line 1633, in call
    raise VirtualMachineError(e) from None
VirtualMachineError: revert: Unknown typed error: 0x
Terminating local RPC client...

本文标签: pythonVirtualMachineError revert Unknown typed error 0x How do I fix my codeStack Overflow