ethereum - How to get one value from struct of array in solidity?
问题描述
I want to get the value that is inside of struct in Solidity, but I have no idea how to get it.
pragma solidity >=0.4.21 <0.6.0;
contract PlaceList {
struct hoge {
uint id;
address user;
}
hoge[] public hoges;
constructor() public {
admin = msg.sender;
}
function set(uint id) public {
hoges.push(hoge(id, msg.sender));
}
function getId() public view returns(uint) {
return (hoges[0].id);
}
}
When I call getId
, console command say this,
ƒ () {
if (abiItemModel.isOfType('constructor')) {
return target.executeMethod(abiItemModel, arguments, 'contract-deployment');
}
return targe…
Could you give me any advise how to get id
by using solidity function, please?
解决方案
推荐阅读
- vue.js - mount () vuejs 中的服务器端获取未呈现
- javascript - 带有动态数据下拉菜单的可编辑 html 表格
- python - 为什么 CNN 模型可以识别没有字符段的图像中的字符?
- excel - 为什么工作表副本省略单元格
- java - 字节数组到Java中的非文本文件
- c - 将 char** 传递给 void** 函数参数时,与指针类型不兼容的指针类型警告
- php - 如何将 YAML 扩展安装到 PHP 7.4?
- r - 如何在 R 中传播数据集,保留每列的名称
- linux - 配置根项目“android”时出现问题
- python - Python Pynput 不循环