I’ve imported all web3J library and utilizing tried utilizing java_version 16,17 and 20. Each time I’m going through problem. After I compiled that script in VSCode. I’m going through the identical problem. Can somebody please assist 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.Switch
import org.web3j.utils.Convert
import org.web3j.protocol.core.strategies.response.TransactionReceipt
import org.web3j.crypto.Credentials
def web3 = Web3j.construct(new HttpService("API_URL"))
String PRIVATE_KEY = 'b33ccb143751577968f32575ee690eb3873e49f27935708dbdea52fe36b6ba76'
RawTransactionManager rawTransactionManager = new RawTransactionManager(web3, Credentials.create(PRIVATE_KEY))
Switch switch = new Switch(web3, rawTransactionManager)
println "switch: ${switch}"
TransactionReceipt receipt = switch.sendFunds("0x7de3280c66ecee8f4cbd8fb78850229d8f10d22f", (Convert.toWei("1", Convert.Unit.ETHER).toBigInteger()), Convert.Unit.WEI, 30000, 1000000108).ship()
println("Transaction Hash: ${receipt.transactionHash}")
println("Block Hash: ${receipt.blockHash}")
println("Block Quantity: ${receipt.blockNumber}")
println("Fuel Used: ${receipt.gasUsed}")
println("Contract Tackle: ${receipt.contractAddress}")