在React中使用坚固的功能
我有一个坚固的功能来添加数据 因此,我想在React中创建一些文本框和一个按钮,以将文本框数据添加到区块链中,
有我的固体代码
pragma solidity 0.6.4;
contract Storage{
uint [] public ids;
string [] public activityNames;
string [] public authorNames;
string [] public activityTypes;
function add(uint id, string memory activityName, string memory authorName, string memory activityType) public {
ids.push(id);
activityNames.push(activityName);
authorNames.push(authorName);
activityTypes.push(activityType);
}
,这是我的React SET处理程序代码,但仅添加一个值 因此,我想让设置处理程序添加所有4个值,不仅是一个
const setHandler = (event) => {
event.preventDefault();
contract.add(event.target.setText.value);
}
感谢
I have a solidity function to add data
so I wanna create some textbox and a button in react to add the textbox data to blockchain
there is my solidity code
pragma solidity 0.6.4;
contract Storage{
uint [] public ids;
string [] public activityNames;
string [] public authorNames;
string [] public activityTypes;
function add(uint id, string memory activityName, string memory authorName, string memory activityType) public {
ids.push(id);
activityNames.push(activityName);
authorNames.push(authorName);
activityTypes.push(activityType);
}
and this is my react set handler code but only adds one value
So I wanna make the set handler add all the 4 values not only one
const setHandler = (event) => {
event.preventDefault();
contract.add(event.target.setText.value);
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的合同签名期望有4个值,但是当您调用它时,您只会传递一个值,填写预期的其余值,并且应该有效。
your contract signature is expecting 4 values but you are only passing a single one in when you call it, fill out the rest of the values expected and it should work.