| | |
| | | |
| | | // 合约地址 TODO |
| | | // private static String contractAddr = "0xb5a1aC0fA05BFb8ad16B231e84b0bAC1d46eAfD0";//测试 |
| | | private static String contractAddr = "0xD88F63aCbcF82cC6D2255b8082D7bdE43b559d00"; |
| | | private static String contractAddr = "0x06Bd96a05B0B7B06449F1da58E8918cc6AfBB394"; |
| | | |
| | | // 操作账号 手续费钱包地址的私钥(合约里会把手续费转到你这个私钥地址上) 用于操作合约内方法 TODO |
| | | private static String privateKey = "221be67f85375a5af6dd0f4b77fbe877ad2e57e05db201de1b1383fb76494d18";//测试 |
| | |
| | | return transactionHash; |
| | | } |
| | | |
| | | /** |
| | | * 从合约内转币到制定地址 |
| | | */ |
| | | public String burnToken(BigInteger amount, String to1){ |
| | | String transactionHash = null; |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | Abi contract = Abi.load(contractAddr, getInstance(), credentials, getStaticGasProvider()); |
| | | try { |
| | | //BigInteger bigInteger = Convert.toWei(amount.toString(), Convert.Unit.ETHER).toBigInteger(); |
| | | TransactionReceipt send = contract.transfer(to1, amount).send(); |
| | | if(ObjectUtil.isNotEmpty(send)){ |
| | | transactionHash = send.getTransactionHash(); |
| | | } |
| | | } catch (Exception exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | return transactionHash; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | AndaoContractMain andaoContractMain = new AndaoContractMain(); |
| | | |