코틀린에서 caver-java 1.6.3 사용해서 SCN으로 sendRawTransaction 하면
Caused by: java.lang.RuntimeException: insufficient funds of the sender for value
가 발생합니다.
아래는 작성한 코드인데 확인 좀 해주세요
val caver = Caver(wallet.endpoint)
val file = File("/home/uk/UTC--2021-12-24T04-46-43.641884982Z--327f7f32454ff278d710c303503da5aeb7c0ca37")
val objectMapper = ObjectMapperFactory.getObjectMapper()
val keyStore = objectMapper.readValue(file, KeyStore::class.java)
val keyring = KeyringFactory.decrypt(keyStore, "")
caver.wallet.add(keyring);
// val value = BigInteger(Utils.convertToPeb(BigDecimal.ONE, "KLAY"))
val valueTransfer = ValueTransfer.Builder()
.setKlaytnCall(caver.rpc.getKlay())
.setFrom(keyring.address)
.setNonce(BigInteger.valueOf(nonce))
.setTo(address.toCanonicalForm())
.setChainId(BigInteger.valueOf(1000))
.setValue(data as String)
.setGas(BigInteger.valueOf(1000000000))
.setGasPrice(BigInteger.valueOf(0))
.build()
logger.debug("nonce: {}, chainId: {}, gasPrice: {}", valueTransfer.nonce,valueTransfer.chainId, valueTransfer.gasPrice)
valueTransfer.sign(keyring)
val result = caver.rpc.klay.sendRawTransaction(valueTransfer?.rawTransaction).send()