Java Code Examples for org.web3j.rlp.RlpEncoder#encode()

The following examples show how to use org.web3j.rlp.RlpEncoder#encode() . 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: PrivateTransaction.java    From ethsigner with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] rlpEncode(final SignatureData signatureData) {
  final RawPrivateTransaction rawTransaction = createTransaction();
  final List<RlpType> values =
      PrivateTransactionEncoder.asRlpValues(rawTransaction, signatureData);
  final RlpList rlpList = new RlpList(values);
  return RlpEncoder.encode(rlpList);
}
 
Example 2
Source File: EthTransaction.java    From ethsigner with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] rlpEncode(final SignatureData signatureData) {
  final RawTransaction rawTransaction = createTransaction();
  final List<RlpType> values = TransactionEncoder.asRlpValues(rawTransaction, signatureData);
  final RlpList rlpList = new RlpList(values);
  return RlpEncoder.encode(rlpList);
}
 
Example 3
Source File: ContractUtils.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *  Generate a smart contract address. This enables you to identify what address a
 *  smart contract will be deployed to on the network.
 *
 * @param address of sender
 * @param nonce of transaction
 * @return the generated smart contract address
 */
public static byte[] generateContractAddress(byte[] address, BigInteger nonce) {
    List<RlpType> values = new ArrayList<>();

    values.add(RlpString.create(address));
    values.add(RlpString.create(nonce));
    RlpList rlpList = new RlpList(values);

    byte[] encoded = RlpEncoder.encode(rlpList);
    byte[] hashed = Hash.sha3(encoded);
    return Arrays.copyOfRange(hashed, 12, hashed.length);
}
 
Example 4
Source File: ContractUtils.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
/**
 *  Generate a smart contract address. This enables you to identify what address a
 *  smart contract will be deployed to on the network.
 *
 * @param address of sender
 * @param nonce of transaction
 * @return the generated smart contract address
 */
public static byte[] generateContractAddress(byte[] address, BigInteger nonce) {
    List<RlpType> values = new ArrayList<>();

    values.add(RlpString.create(address));
    values.add(RlpString.create(nonce));
    RlpList rlpList = new RlpList(values);

    byte[] encoded = RlpEncoder.encode(rlpList);
    byte[] hashed = Hash.sha3(encoded);
    return Arrays.copyOfRange(hashed, 12, hashed.length);
}
 
Example 5
Source File: ContractUtils.java    From web3j with Apache License 2.0 5 votes vote down vote up
/**
 * Generate a smart contract address. This enables you to identify what address a smart contract
 * will be deployed to on the network.
 *
 * @param address of sender
 * @param nonce of transaction
 * @return the generated smart contract address
 */
public static byte[] generateContractAddress(byte[] address, BigInteger nonce) {
    List<RlpType> values = new ArrayList<>();

    values.add(RlpString.create(address));
    values.add(RlpString.create(nonce));
    RlpList rlpList = new RlpList(values);

    byte[] encoded = RlpEncoder.encode(rlpList);
    byte[] hashed = Hash.sha3(encoded);
    return Arrays.copyOfRange(hashed, 12, hashed.length);
}
 
Example 6
Source File: TransactionEncoder.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
private static byte[] encode(RawTransaction rawTransaction, Sign.SignatureData signatureData) {
    List<RlpType> values = asRlpValues(rawTransaction, signatureData);
    RlpList rlpList = new RlpList(values);
    return RlpEncoder.encode(rlpList);
}
 
Example 7
Source File: NodeIdTool.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
private static byte[] encode(PlatonBlock.Block block) {
    List<RlpType> values = asRlpValues(block);
    RlpList rlpList = new RlpList(values);
    return RlpEncoder.encode(rlpList);
}
 
Example 8
Source File: TransactionEncoder.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
private static byte[] encode(RawTransaction rawTransaction, Sign.SignatureData signatureData) {
    List<RlpType> values = asRlpValues(rawTransaction, signatureData);
    RlpList rlpList = new RlpList(values);
    return RlpEncoder.encode(rlpList);
}
 
Example 9
Source File: KeystoreAccountService.java    From alpha-wallet-android with MIT License 4 votes vote down vote up
private static byte[] encode(RawTransaction rawTransaction, Sign.SignatureData signatureData) {
    List<RlpType> values = TransactionEncoder.asRlpValues(rawTransaction, signatureData);
    RlpList rlpList = new RlpList(values);
    return RlpEncoder.encode(rlpList);
}
 
Example 10
Source File: PrivateTransactionEncoder.java    From web3j with Apache License 2.0 4 votes vote down vote up
private static byte[] encode(
        final RawPrivateTransaction rawTransaction, final Sign.SignatureData signatureData) {
    final List<RlpType> values = asRlpValues(rawTransaction, signatureData);
    final RlpList rlpList = new RlpList(values);
    return RlpEncoder.encode(rlpList);
}
 
Example 11
Source File: TransactionEncoder.java    From web3j with Apache License 2.0 4 votes vote down vote up
private static byte[] encode(RawTransaction rawTransaction, Sign.SignatureData signatureData) {
    List<RlpType> values = asRlpValues(rawTransaction, signatureData);
    RlpList rlpList = new RlpList(values);
    return RlpEncoder.encode(rlpList);
}
 
Example 12
Source File: TransactionRepository.java    From alpha-wallet-android with MIT License 2 votes vote down vote up
/**
 * From Web3j to encode a constructor
 * @param rawTransaction
 * @param signatureData
 * @return
 */
private static byte[] encode(RawTransaction rawTransaction, Sign.SignatureData signatureData) {
	List<RlpType> values = TransactionEncoder.asRlpValues(rawTransaction, signatureData);
	RlpList rlpList = new RlpList(values);
	return RlpEncoder.encode(rlpList);
}