0

使用 drizzle/react-components 中的 ContractData 尝试调用从结构返回多个参数的读取函数

我的组件.js

                <div>
                    <h2>Get Participant Details</h2>
                        <ContractData
                            drizzle={drizzle}
                            drizzleState={drizzleState}
                            contract="supplyChain"
                            method="getParticipantDetails"
                            methodArgs={[1, "modelNumber"]}
                        />

Solidity 合约

 struct participant {
    string userName;
    string password;
    string participantType;
    address participantAddress;
}
function getParticipantDetails(uint32 _p_id) public view returns (string,address,string) {
    return (participants[_p_id].userName, participants[_p_id].participantAddress, participants[_p_id].participantType);
}

不确定如何用 Drizzle 准确读取元组

4

1 回答 1

0

可以帮助你https://github.com/trufflesuite/drizzle/blob/develop/ui-tests/react-redux/src/MyComponent.js

从第 188 行开始,用于合同 ComplexStorage

但我看到 methodArgs add 的错误标签:
Add :methodArgs="[1, "modelNumber"]"

<ContractData drizzle={drizzle} drizzleState={drizzleState} contract="supplyChain" method="getParticipantDetails" :methodArgs="[1,"modelNumber"]" />

于 2021-12-01T15:04:54.043 回答