Saturday, March 22, 2025

efficiency testing – Web3J library isn’t supporting in groovy script. I’ve to ship transaction by way of groovy script and test check load in JMETER


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}")
      


Error while compiling in VSCode

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles