5 web3j对solidity里面的struct对象, java中如何传参呢

solidity结构体 contract test { struct Demo { uint64 uid; uint64 amount; } function send(Demo calldata demo) public {} }

java使用web3j构建参数 : @Data class Demo extends StaticStruct { public Uint64 uid; public Uint64 amount; public Demo(long uid, long amount) { super(new Type[]{new Uint64(uid),new Uint64(amount)}); } 构建参数可以用这种方式吗? 现在发现上链死活失败 Function function = new Function( "send", List.of(new Demo(1,2)), Collections.emptyList());

第二个问题是 java种怎么打印出来传输的参数呢?
像js就直接是json串 { "uid":1, "amount":2 }

请先 登录 后评论

2 个回答

Wade - Footprint Analytics CTO
  擅长:数据分析,GameFi,NFT
请先 登录 后评论
Wade - Footprint Analytics CTO
  擅长:数据分析,GameFi,NFT
请先 登录 后评论
  • 2 关注
  • 0 收藏,350 浏览
  • 约队 提出于 2024-08-30 16:45