xiaoyong931011
2023-08-08 11f6a8c911c5ef241f42953976661a249aa8b83e
src/main/java/cc/mrbird/febs/dapp/contract/ContractMain.java
@@ -20,6 +20,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
@@ -37,6 +38,7 @@
@Component
@ConditionalOnProperty(prefix = "system", name = "chain-listener", havingValue = "true")
public class ContractMain {
    @Autowired
@@ -84,17 +86,13 @@
    }
    // 区块链节点地址 TODO
//    private static String blockchainNode = "https://bsc-dataseed.binance.org";
    private static String blockchainNode = "https://bsc-dataseed1.ninicoin.io";
    // 合约地址 TODO
//    private static String contractAddr = "0xb5a1aC0fA05BFb8ad16B231e84b0bAC1d46eAfD0";//测试
    private static String contractAddr = "0x532B0F9554D92b8BF1bdE85DD4E8b86E4228DE27";
    // 操作账号 手续费钱包地址的私钥(合约里会把手续费转到你这个私钥地址上) 用于操作合约内方法 TODO
    private static String privateKey = "221be67f85375a5af6dd0f4b77fbe877ad2e57e05db201de1b1383fb76494d18";//测试
//    private static String privateKey = AppContants.FEE_ADDRESS_KEY.get("feeAddressKey").toString() ;
    private static String privateKey = AppContants.FEE_ADDRESS_KEY.get("feeAddressKey").toString() ;
    private EthFilter getFilter(BigInteger startBlock) {
        if (startBlock != null) {
@@ -176,7 +174,6 @@
        ContractMain contractMain = new ContractMain();
        String address = "0xA60AaC0da34C76F3f60207ee09e9F75043319ab4";
//        String address = "0x785D5Aa2951Ac4C6f28Dc593AF0b0536Dd3E82Fe";
        BigInteger bigInteger = new BigInteger(Convert.toWei("0.001", Convert.Unit.ETHER).setScale(0).toString());
        String hash = contractMain.trans(bigInteger,address);
        System.out.println(hash);