我想要使用React the表单来显示一个可以接受多个数据元素的表单,即显示姓名和国籍的输入框。所以这是一个简单的例子,它稍微扩展了一下drizzle 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有没有人可以告诉我我做错了什么,或者给我指出任何代码示例的方向,这些代码示例涉及到涉及多个输入元素的毛毛雨合同表单。非常感谢。
发布于 2021-06-14 00:23:27
看起来你错过了编译和部署合同。
truffle编译&& truffle迁移
将编译并部署您的合同
https://stackoverflow.com/questions/62107085
复制相似问题