Search in sources :

Example 1 with ResTrans

use of com.bsnbase.sdk.entity.resp.fiscobcos.ResTrans in project PCNGateway-Java-SDK by BSNDA.

the class TransactionService method trans.

/**
 * Invoke the smart contract in Public Key Upload Mode
 * When the off-chain business system connects to the BSN gateway, it needs to add the corresponding parameters in the request message according to the interface description. After invoking the gateway, the gateway will return the execution result of the smart contract.
 * In the transaction of public key upload mode, the private key of the on-chain transaction is generated and saved by the user, and then the client will assemble and sign the on-chain data locally, and upload the signed data to the node gateway.
 * The gateway forwards the data to the corresponding blockchain node to initiate the transaction request. In this mode, the ABI of the contract and the contract address are required to assemble the data.
 * The ABI of the contract is obtained by compiling the contract when developing the contract, and the contract address can be obtained from the details page of the participated service.
 * The method to assemble the on-chain data has been implemented in the SDK of the gateway, and it can be called directly.
 */
public static ResTrans trans(ReqTransData reqTransData) throws Exception {
    ReqTrans reqTrans = FiscoTransUtil.buildTrans(reqTransData);
    String api = Config.config.getApi() + PathUtil.FISCOBCOS_NODE_TRANS;
    BaseReqModel<ReqTrans> req = new BaseReqModel<>(reqTrans);
    req.setReqHeader(Config.config.getUserCode(), Config.config.getAppCode());
    HttpService<ReqTrans, ResTrans> httpService = new HttpService();
    BaseResModel<ResTrans> res = httpService.post(req, api, ResTrans.class);
    return res.getBody();
}
Also used : BaseReqModel(com.bsnbase.sdk.entity.base.BaseReqModel) ResTrans(com.bsnbase.sdk.entity.resp.fiscobcos.ResTrans) ReqTrans(com.bsnbase.sdk.entity.req.fiscobcos.ReqTrans) HttpService(com.bsnbase.sdk.util.common.HttpService)

Aggregations

BaseReqModel (com.bsnbase.sdk.entity.base.BaseReqModel)1 ReqTrans (com.bsnbase.sdk.entity.req.fiscobcos.ReqTrans)1 ResTrans (com.bsnbase.sdk.entity.resp.fiscobcos.ResTrans)1 HttpService (com.bsnbase.sdk.util.common.HttpService)1