I have imported all web3J library and using tried using java_version 16,17 and 20. Every time I am facing issue. When I compiled that script in VSCode. I am facing the same issue. Can someone please help me with groovy script?
import org.web3j.protocol.Web3j
import org.web3j.protocol.core.DefaultBlockParameterName
import org.web3j.protocol.http.HttpService
import org.web3j.tx.RawTransactionManager
import org.web3j.tx.Transfer
import org.web3j.utils.Convert
import org.web3j.protocol.core.methods.response.TransactionReceipt
import org.web3j.crypto.Credentials
def web3 = Web3j.build(new HttpService("API_URL"))
String PRIVATE_KEY = 'b33ccb143751577968f32575ee690eb3873e49f27935708dbdea52fe36b6ba76'
RawTransactionManager rawTransactionManager = new RawTransactionManager(web3, Credentials.create(PRIVATE_KEY))
Transfer transfer = new Transfer(web3, rawTransactionManager)
println "transfer: ${transfer}"
TransactionReceipt receipt = transfer.sendFunds("0x7de3280c66ecee8f4cbd8fb78850229d8f10d22f", (Convert.toWei("1", Convert.Unit.ETHER).toBigInteger()), Convert.Unit.WEI, 30000, 1000000108).send()
println("Transaction Hash: ${receipt.transactionHash}")
println("Block Hash: ${receipt.blockHash}")
println("Block Number: ${receipt.blockNumber}")
println("Gas Used: ${receipt.gasUsed}")
println("Contract Address: ${receipt.contractAddress}")
Source: Read More