我想使用 React Drizzle 合同表单来显示一个可以采用多个数据元素的表单,即会显示一个输入框来输入姓名和国籍。所以这是一个简单的例子,稍微扩展了 drizzle unbox react 例子中的 set 和 get 方法,它只是获取和设置一个变量。可在此处获取https://github.com/truffle-box/react-box
我的智能合约是..
pragma solidity 0.5.16;
contract PersonContract {
uint256 public peopleCount = 0;
mapping(uint => Person) public people;
struct Person {
uint256 _id;
string _firstname;
string _lastname;
}
function addPerson(string memory _firstname, string memory _lastname) public{
incrementPeopleCount();
people[peopleCount] = Person(peopleCount, _firstname, _lastname);
}
function incrementPeopleCount() internal {
peopleCount +=1;
}
}
我在 MyComponent 中的 React 代码是......
<div className="section">
<h2>Person Contract</h2>
<p>
<ContractData
drizzle={drizzle}
drizzleState={drizzleState}
contract="PersonContract"
method="Person"
/>
</p>
<ContractForm drizzle={drizzle} contract="PersonContractTwo" method="addPerson" />
</div>
当我运行此代码时,ContractData 和 ContractForm 都出现错误。
对于ContractForm,我得到...
drizzle-react-components.js:392 Uncaught TypeError: Cannot read property 'methods' of undefined
对于ContractForm,我得到..
index.js:1406 uncaught at initializeDrizzle TypeError: Cannot read property 'abi' of undefined
谁能告诉我我做错了什么或指出任何涉及涉及多个输入元素的 Drizzle 合同表单的代码示例的方向。非常感激。