首页 > 其他分享 >FISCO-BCOS[WeBASEUtils工具类]

FISCO-BCOS[WeBASEUtils工具类]

时间:2023-10-17 18:33:44浏览次数:33  
标签:set FISCO hutool WeBASEUtils BCOS import post data String

package priv.pront.PetStore.utils;

import cn.hutool.core.lang.Dict;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-09-11 15:16
 */
@Service
public class WeBASEUtils {

    public Dict commonReq(String userAddress, String funcName, List funcParam, String ABI, String contractName, String contractAddress) {
        JSONArray abiJSON = JSONUtil.parseArray(ABI);
        JSONObject data = JSONUtil.createObj();
        data.set("groupId", "1");
        data.set("user", userAddress);
        data.set("contractName", contractName);
        data.set("version", "V1.0");
        data.set("funcName", funcName);
        data.set("funcParam", funcParam);
        data.set("contractAddress", contractAddress);
        data.set("contractAbi", abiJSON);
        data.set("useAes", false);
        data.set("useCns", false);
        data.set("cnsName", "Adoption");
        String dataString = JSONUtil.toJsonStr(data);
        HttpRequest post = HttpRequest.post("http://60.204.221.191:5002/WeBASE-Front/trans/handle");
        post = post.header(Header.CONTENT_TYPE, "application/json");
        post = post.body(dataString);
        HttpResponse execute = post.execute();
        String responseBody = execute.body();
        System.out.println(responseBody);
//
        Dict retDict = new Dict();
        retDict.set("result", responseBody);
        return retDict;
    }
}

标签:set,FISCO,hutool,WeBASEUtils,BCOS,import,post,data,String
From: https://www.cnblogs.com/pronting/p/17770389.html

相关文章