请填写你的反馈内容
org.web3j core 4.5.18 okhttp com.squareup.okhttp
function arrTest(bytes32[] memory arr) public view returns(string memory) {return bytes32ToString(arr[0]);}function bytes32ToString(bytes32 bname) view public returns(string memory){// 此处要加上memory// 先将有效字符计算出来bytes memory bytesChar = new bytes(bname.length);uint charCount = 0;for(uint i = 0;i < bname.length; i++){bytes1 char = bname[i];if(char != 0){charCount++;}}// 新建数组,指定长度为有效字节长度bytes memory bytesName = new bytes(charCount);for(uint j = 0;j < charCount;j++){bytesName[j] = bname[j];}return string(bytesName);}
public static Bytes32 stringToBytes32(String string) {byte[] byteValue = string.getBytes();byte[] byteValueLen32 = new byte[32];System.arraycopy(byteValue, 0, byteValueLen32, 0, byteValue.length);return new Bytes32(byteValueLen32);}public RemoteCallarrTest(List data) {//首先把String转换成Bytes32Bytes32[] _dataBytes32 = new Bytes32[data.size()];List _dataUint = new ArrayList<>();for(int i = 0 ; i < data.size() ; i++) {_dataBytes32[i] = stringToBytes32(data.get(i));}//需要使用DynamicArray 进行参数传递其他传递方式均出现错误 如: 直接传入参数dataBytes32 的数组,程序报错 ;List形式传参,程序报错DynamicArray inputDataByte32 = new DynamicArray (Bytes32.class , _dataBytes32);final Function function = new Function("arrTest",Arrays. asList(//错误示例//dataBytes32//正确示例inputDataByte32),Arrays.asList(new TypeReference () {}));return executeRemoteCallSingleValueReturn(function);}
请先登陆或注册
2909.0
LK币
4
粉丝
75
笔记
感谢"Diva"
这篇精彩的笔记,目前已经帮助
公司名称:北京链客行科技有限公司
联系方式:010-67707199
ICP备案号:京ICP备18032136号
Copyright:链客区块链技术问答社区 版权所有
感谢您的提问,问题被社区永久收入以便新人查看。一定要记得采纳最佳答案哦!加油!
感谢您的善举,每一次解答会成为新人的灯塔,回答被采纳后获得20算力和相应的LK币奖励
您将赞赏给对方2LK币的奖励哦!感谢您的赞赏!
您将赞赏给对方2LK币的奖励哦!感谢您的赞赏!