-
https://0x74d15156b20f6e79eb62a73d1c23cf71d86adfa8.5.w3link.io/flag?returns=(struct)
合约如下: struct Flag {
uint256 id;
address flager;
string flag;
address[] bettors; // up to 100 bettors
}
function flag() public view returns(Flag memory) {
address[] memory bettors = new address[](5); // Placeholder for up to 100 bettors
// bettors.push(msg.sender);
bettors[0] = msg.sender;
Flag memory newFlag = Flag({
id: 1, // This is an example id
flag: "EAT ALL!",
flager: msg.sender, // The person who calls the function is the 'flager'
bettors: bettors // Empty array of 'bettors'
});
return newFlag;
} 如果直接访问 https://0x74d15156b20f6e79eb62a73d1c23cf71d86adfa8.5.w3link.io/flag
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
使用
返回了一堆字节码,不知道咋看 lol |
Beta Was this translation helpful? Give feedback.
-
感觉我走了个弯路,如果把合约当后端的话,是不是用 web3.js 这种请求会更好? |
Beta Was this translation helpful? Give feedback.
-
解析复杂数据类型比如struct或者array应该也可以支持,比如类似这样https://0x74d15156b20f6e79eb62a73d1c23cf71d86adfa8.5.w3link.io/flag?returns=(uint,string,address,address[]),但是现在spec里面应该还不支持 |
Beta Was this translation helpful? Give feedback.
-
做了一个测试,返回一个结构体,是可以支持的,比如这个 https://0x6a019daa1c05fe89e274801d9f164316a1ad46bf.5.w3link.io/testFn?returns=(uint256,uint256,uint256) , 源码如下:
|
Beta Was this translation helpful? Give feedback.
-
Flag的定义可以贴一下吗? |
Beta Was this translation helpful? Give feedback.
这样拼URL: https://0x74d15156b20f6e79eb62a73d1c23cf71d86adfa8.5.w3link.io/flag?returns=(uint256,address,string,(address[]))