Cómo transferir ether de una cuenta a otra usando EthereumJ

Para propósitos de prueba en la red de prueba, estamos creando una cuenta dinámicamente usando ethereum java (EcKey). Tengo una cuenta que contiene suficientes éteres. ¿Cómo puedo transferir ether de la cuenta de origen a la cuenta recién creada usando ethereum java? Por favor recomiende.

Respuestas (2)

Verifique cualquier muestra del directorio de origen de muestras sobre cómo tratar las Transacciones, por ejemplo, esta: CreateContractSample.java ,

Su llamada de transacción debería ser algo como esto:

// Amount in ether to send
BigInteger etherToSend = BigInteger.valueOf(100);
// Weis in 1 ether
BigInteger weisInEther = BigInteger.valueOf(1_000_000_000_000_000_000L);
BigInteger weisToSend = weisInEther.multiply(etherToSend);
BigInteger nonce = ethereum.getRepository().getNonce(senderKey.getAddress());

Transaction tx = new Transaction(
      ByteUtil.bigIntegerToBytes(nonce),
      ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()),
      ByteUtil.longToBytesNoLeadZeroes(3_000_000),  // Gas limit
      receiveAddress,
      ByteUtil.bigIntegerToBytes(weisToSend),  // Amount in weis
      new byte[0]  // We don't need to send any data
     ); 
tx.sign(senderKey);
ethereum.submitTransaction(tx);

Use la clase Transaction.java, cree el objeto con la información necesaria (el constructor, toma información como from, to address, nonce, gas y value to transfer) y finalmente firme la transacción y envíela.