从另一个智能合约读取大小可变的数据

时间:2019-02-27 11:05:14

标签: solidity smartcontracts

我有两个合同,如下所示。我正在通过DocInfo合同将文档详细信息保存到文档合同中。但是,当我尝试通过docINfo合同获取详细信息时,却得到了空洞的结果。我在这里想念什么吗?

pragma solidity 0.5.0;

contract DocumentContract {

    struct Document{ 
        string DocumentNo;
        address DigitalID;
    }

    mapping(string=>Document) doc; 

    function CreateDocument(string calldata DocumentNo,address DigitalID) external {

        doc[DocumentNo] = Document({
            DocumentNo: DocumentNo,
            DigitalID: DigitalID
        });
    }

    function GetDocument(string calldata documentNumber) external view returns(address) {    
        Document memory document = doc[documentNumber]; 
        return (document.DigitalID);        
    }   
}

contract DocInfo {

    function CreateDocument(address digitalID,string memory documentId) public  returns (bool success) {

        address contractAddress =<<Document contract address>>; 
        DocumentContract doc = DocumentContract(contractAddress);
        doc.CreateDocument(documentId,digitalID);

        return true;
    }

    function GetDocument(string memory documentId) 
    public view returns (address) {  

        address contractAddress = <<Document contract address>>;  
        DocumentContract doc = DocumentContract(contractAddress);
        address digitalId = doc.GetDocument(documentId);  
        return digitalId;
    }        
}

0 个答案:

没有答案