Java Code Examples for org.web3j.utils.Numeric#prependHexPrefix()

The following examples show how to use org.web3j.utils.Numeric#prependHexPrefix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrivateTransactionRequest.java    From besu with Apache License 2.0 6 votes vote down vote up
public PrivateTransactionRequest(
    final String from,
    final BigInteger nonce,
    final BigInteger gasPrice,
    final BigInteger gasLimit,
    final String to,
    final BigInteger value,
    final String data,
    final String privateFrom,
    final List<String> privateFor,
    final String restriction) {
  this.from = from;
  this.to = to;
  this.gas = gasLimit;
  this.gasPrice = gasPrice;
  this.value = value;
  this.data = data == null ? null : Numeric.prependHexPrefix(data);
  this.nonce = nonce;
  this.privateFrom = privateFrom;
  this.privateFor = privateFor;
  this.restriction = restriction;
}
 
Example 2
Source File: PrivateTransactionRequest.java    From besu with Apache License 2.0 6 votes vote down vote up
public PrivateTransactionRequest(
    final String from,
    final BigInteger nonce,
    final BigInteger gasPrice,
    final BigInteger gasLimit,
    final String to,
    final BigInteger value,
    final String data,
    final String privateFrom,
    final String privacyGroupId,
    final String restriction) {
  this.from = from;
  this.to = to;
  this.gas = gasLimit;
  this.gasPrice = gasPrice;
  this.value = value;
  this.data = data == null ? null : Numeric.prependHexPrefix(data);
  this.nonce = nonce;
  this.privateFrom = privateFrom;
  this.privacyGroupId = privacyGroupId;
  this.restriction = restriction;
}
 
Example 3
Source File: ImportWalletActivity.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
@Override
public void onPrivateKey(String privateKey)
{
    try
    {
        BigInteger key = new BigInteger(privateKey, 16);
        if (!WalletUtils.isValidPrivateKey(privateKey)) throw new Exception(getString(R.string.invalid_private_key));
        ECKeyPair keypair = ECKeyPair.create(key);
        String address = Numeric.prependHexPrefix(Keys.getAddress(keypair));

        if (importWalletViewModel.keystoreExists(address))
        {
            queryReplaceWalletPrivateKey(address);
        }
        else
        {
            importWalletViewModel.importPrivateKeyWallet(address, this, this);
        }
    }
    catch (Exception e)
    {
        keyImportError(e.getMessage());
    }
}
 
Example 4
Source File: Transaction.java    From web3j with Apache License 2.0 6 votes vote down vote up
public Transaction(
        String from,
        BigInteger nonce,
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        BigInteger value,
        String data,
        BigInteger gasPremium,
        BigInteger feeCap) {
    this.from = from;
    this.to = to;
    this.gas = gasLimit;
    this.gasPrice = gasPrice;
    this.value = value;

    if (data != null) {
        this.data = Numeric.prependHexPrefix(data);
    }

    this.nonce = nonce;
    this.gasPremium = gasPremium;
    this.feeCap = feeCap;
}
 
Example 5
Source File: Transaction.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
public Transaction(String from, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit,
                   String to, BigInteger value, String data) {
    this.from = from;
    this.to = to;
    this.gas = gasLimit;
    this.gasPrice = gasPrice;
    this.value = value;

    if (data != null) {
        this.data = Numeric.prependHexPrefix(data);
    }

    this.nonce = nonce;
}
 
Example 6
Source File: Transaction.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public Transaction(String from, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit,
                   String to, BigInteger value, String data) {
    this.from = from;
    this.to = to;
    this.gas = gasLimit;
    this.gasPrice = gasPrice;
    this.value = value;

    if (data != null) {
        this.data = Numeric.prependHexPrefix(data);
    }

    this.nonce = nonce;
}
 
Example 7
Source File: Credentials.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
public static Credentials create(ECKeyPair ecKeyPair) {
    String address = Numeric.prependHexPrefix(Keys.getAddress(ecKeyPair));
    return new Credentials(ecKeyPair, address);
}
 
Example 8
Source File: Credentials.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public static Credentials create(ECKeyPair ecKeyPair) {
    String address = Numeric.prependHexPrefix(Keys.getAddress(ecKeyPair));
    return new Credentials(ecKeyPair, address);
}
 
Example 9
Source File: Credentials.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static Credentials create(ECKeyPair ecKeyPair) {
    String address = Numeric.prependHexPrefix(Keys.getAddress(ecKeyPair));
    return new Credentials(ecKeyPair, address);
}