我有一个如下结构:
struct Document {
address[] haveAccess;
}
mapping(uint => Document) public documents;
address[] public arr;
constructor() {
documentsCount++;
documents[documentsCount] = Document(arr);
}
从truffle编译后从web3 js访问不会返回地址数组hasAccess。甚至不返回空数组。 web3调用是这样的
instance.documents(0).then(document=>{
//dosomething with document
});
我需要数组有访问权限。
尝试使用括号而不是括号进行调用。而且你还需要添加.call
。看看here。