|
@@ -12,17 +12,10 @@ import lombok.SneakyThrows;
|
|
import org.web3j.abi.FunctionEncoder;
|
|
import org.web3j.abi.FunctionEncoder;
|
|
import org.web3j.abi.datatypes.Function;
|
|
import org.web3j.abi.datatypes.Function;
|
|
import org.web3j.abi.datatypes.generated.Uint256;
|
|
import org.web3j.abi.datatypes.generated.Uint256;
|
|
-import org.web3j.crypto.Credentials;
|
|
|
|
import org.web3j.crypto.RawTransaction;
|
|
import org.web3j.crypto.RawTransaction;
|
|
-import org.web3j.crypto.TransactionEncoder;
|
|
|
|
import org.web3j.protocol.Web3j;
|
|
import org.web3j.protocol.Web3j;
|
|
-import org.web3j.protocol.core.DefaultBlockParameterName;
|
|
|
|
-import org.web3j.protocol.core.Response;
|
|
|
|
import org.web3j.protocol.core.methods.request.Transaction;
|
|
import org.web3j.protocol.core.methods.request.Transaction;
|
|
-import org.web3j.protocol.core.methods.response.EthSendTransaction;
|
|
|
|
import org.web3j.protocol.http.HttpService;
|
|
import org.web3j.protocol.http.HttpService;
|
|
-import org.web3j.utils.Convert;
|
|
|
|
-import org.web3j.utils.Numeric;
|
|
|
|
|
|
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -60,26 +53,6 @@ public class Erc21TestScript extends IScript {
|
|
BigInteger.valueOf(0),
|
|
BigInteger.valueOf(0),
|
|
mintEncoder);
|
|
mintEncoder);
|
|
|
|
|
|
- Credentials credentials = Web3Util.getCredentials(airdropWallet);
|
|
|
|
- byte[] signMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
|
|
|
|
- String hexValue = Numeric.toHexString(signMessage);
|
|
|
|
- //发送交易
|
|
|
|
- EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).send();
|
|
|
|
- Response.Error error = ethSendTransaction.getError();
|
|
|
|
- if (error != null) {
|
|
|
|
- throw new RuntimeException(error.getMessage());
|
|
|
|
- }
|
|
|
|
- org.web3j.protocol.core.methods.response.Transaction transaction = web3j
|
|
|
|
- .ethGetTransactionByHash(ethSendTransaction.getTransactionHash())
|
|
|
|
- .send()
|
|
|
|
- .getTransaction()
|
|
|
|
- .get();
|
|
|
|
- BigInteger gasAmount = transaction.getGas().multiply(transaction.getGasPrice());
|
|
|
|
- SResult sResult = new SResult();
|
|
|
|
- BigInteger balance = web3j.ethGetBalance(airdropWallet.getAddress(), DefaultBlockParameterName.LATEST).send().getBalance();
|
|
|
|
- sResult.setGas(gasAmount.toString());
|
|
|
|
- sResult.setTxId(transaction.getHash());
|
|
|
|
- sResult.setCurrentBalance(balance.toString());
|
|
|
|
- return sResult;
|
|
|
|
|
|
+ return sendTx(airdropWallet, web3j, rawTransaction);
|
|
}
|
|
}
|
|
}
|
|
}
|