I wrote a program in Java, that create a request for a transaction and sends it through RPC API. My test network - Rinkeby.
This is request:
curl -X POST --data '{"method":"personal_sendTransaction","params":[{"from":"0x52f0bd94bddabe81111dfc283265933f64069f91","to":"0x31b98d14007bdee637298086988a0bbd31184523","gas":"0x40d4820000000000","gasPrice":"0x3e55798ee2308c3a","value":"0x3ff0000000000000"},"password"],"id":1,"jsonrpc":"2.0"}' http://localhost:8545
where:
String value = "0x"+Long.toHexString(Double.doubleToLongBits(1.0));//**0x3ff0000000000000**
String gasPrice = "0x"+Long.toHexString(Double.doubleToLongBits(0.00000002));//**0x3e55798ee2308c3a**
String gas = "0x"+Long.toHexString(Double.doubleToLongBits(Double.parseDouble("21000")));//**0x40d4820000000000**
But I get the error:
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"exceeds block gas limit"}}.
Maybe I'm not correctly translating numbers into hex values?
doubleToLongBits
, from the java documentation: > Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout. But smart contracts in Ethereum only accept integers. In the case of values and gasPrice they are fixed point integers with 18 decimals. – Ismael Jan 19 '18 at 16:48