Friday, June 27, 2025
No Result
View All Result
Coins League
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Metaverse
  • Web3
  • Scam Alert
  • Regulations
  • Analysis
Marketcap
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Metaverse
  • Web3
  • Scam Alert
  • Regulations
  • Analysis
No Result
View All Result
Coins League
No Result
View All Result

How to compile smart contracts against different EVM versions using Web3j

March 14, 2025
in Web3
Reading Time: 3 mins read
0 0
A A
0
Home Web3
Share on FacebookShare on TwitterShare on E Mail


What’s web3j-solidity-gradle plugin?

Web3j-solidity-gradle-plugin is a helpful software and extension of web3j library. You should use it for integrating Solidity good contract compilation into your Gradle mission. It simplifies the method of constructing and managing good contracts inside a Java or Android mission that makes use of Web3j. It gives varied configurations for compiling and makes use of web3j-sokt behind the scenes.

Web3j-Sokt is a Kotlin wrapper for the Solidity compiler (solc). Given a solidity file, it will possibly determine the perfect compiler model to make use of from the pragma assertion on the high of the file. It will possibly then obtain, set up and invoke the compiler. Somewhat than utilizing Dockerized variations of Solc, Sokt makes use of native builds and is suitable with Mac, Home windows and Linux.

For extra data on web3j-sokt examine right here – https://github.com/hyperledger/web3j-sokt

The right way to use web3j-solidity-gradle plugin?

Step 1: Apply the Plugin

First, you have to apply the web3j-solidity-gradle plugin to your Gradle mission. You are able to do this by including the next traces to your construct.gradle file:

plugins {
id ‘org.web3j.solidity.gradle.plugin’ model ‘x.y.z’
}

Step 2: Configure the Plugin

After making use of the plugin, you’ll be able to configure the compilation flags. Right here is an instance configuration:

solidity {
// Elective: Specify the Solidity compiler model
solcVersion = ‘v0.5.16’

// Elective: Configure the optimizer
outputComponents = [BIN, ABI, ASM_JSON]
optimizeRuns = 500
}

Step 3: Add Solidity Recordsdata

By default, all .sol information in $projectDir/src/predominant/solidity and $projectDir/src/check/solidity can be processed by the plugin. To specify and add completely different supply units, use the sourceSets DSL. You can even set your most popular output listing for compiled code.

sourceSets {
predominant {
solidity {
srcDir {
“my/customized/path/to/solidity”
}
output.resourcesDir = file(‘out/bin/compiledSol’)
}
}
}

Step 4: Construct Contracts

To compile your Solidity contracts, run the next command in your terminal:

./gradlew buildOr you’ll be able to simply run the compileSolidity gradle process 

./gradlew compileSolidity

This command triggers the compilation of Solidity contracts and generates binary and ABI information within the specified vacation spot listing.

Step 5: Combine with Web3j

After compiling your contracts, you might need to generate Java wrappers to work together with them. You possibly can combine the web3j library to your mission and use the Web3j CLI or Web3j Gradle plugin to generate these wrappers. Right here’s a information on how one can add Web3j-gradle-plugin to your Gradle mission: https://docs.web3j.io/4.11.0/plugins/web3j_gradle_plugin/

Then, use the plugin to generate Java wrappers that correspond to your good contracts.

Step 6: Run and Take a look at

Lastly, use the generated Java wrappers in your Java or Android mission to deploy, work together with, and check your good contracts.

Introducing New Options within the Web3j-Solidity-Gradle Plugin

The Web3j Solidity Gradle plugin permits for outlining completely different supply units. Nevertheless, the Solidity compilation configuration is world. It can’t be set individually for every supply set.

Here is an instance of how supply units together with solidity flags are presently configured:

sourceSets {
predominant {
solidity {
srcDir {
“my/customized/path/to/solidity”
}
output.resourcesDir = file(‘out/bin/compiledSol’)
}
}
}

solidity {
outputComponents = [BIN, ABI, ASM_JSON]
optimizeRuns = 500
}

This strategy will be problematic for customers who need completely different configurations for compiling good contracts throughout supply units, as compilation settings are restricted to world values.

To deal with this, we’ve launched new options that permit customers configure parameters like Solidity model, EVM model, optimization settings, and optimization runs per supply set.

Instance with the brand new function:

sourceSets {
predominant {
solidity {
srcDir {
“my/customized/path/to/solidity”
}
output.resourcesDir = file(‘out/bin/compiledSol’)
setEvmVersion(‘ISTANBUL’)
setOptimize(true)
setOptimizeRuns(200)
setVersion(‘0.8.12’)
}
}
}

Builders who need to discover this new performance can observe the associated pull request: https://github.com/hyperledger/web3j-solidity-gradle-plugin/pull/69. These options can be obtainable within the upcoming launch of the Web3j-Solidity-Gradle plugin v0.4.2.

Customers and builders can discover the mission code supply right here – https://github.com/hyperledger/web3j-solidity-gradle-plugin

The Web3j-Solidity-Gradle plugin gives a seamless improvement expertise from good contract coding to Java software integration. The brand new options let customers apply completely different compilation settings for good contracts throughout varied supply units, making it simpler to handle project-specific necessities successfully.



Source link

Tags: compileContractsEVMSmartVersionsWeb3j
Previous Post

EigenLayer’s EIGEN Airdrop Might Signal Demise of Once-Popular ‘Points’

Next Post

Trader Says Bitcoin (BTC), Chainlink (LINK) and One Ethereum Rival Setting Up for Rallies

Related Posts

Myriad Moves: Will Trump Drop Another F-Bomb? Plus Predictions on Ethereum and Wimbledon
Web3

Myriad Moves: Will Trump Drop Another F-Bomb? Plus Predictions on Ethereum and Wimbledon

June 26, 2025
Can AI Crack the Cat Code? Baidu Thinks So
Web3

Can AI Crack the Cat Code? Baidu Thinks So

June 25, 2025
XRP Ledger unveils update to challenge Ethereum’s dominance
Web3

XRP Ledger unveils update to challenge Ethereum’s dominance

June 25, 2025
Crypto Scam Markets Thrive Again After Telegram’s Cleanup Attempt: Report
Web3

Crypto Scam Markets Thrive Again After Telegram’s Cleanup Attempt: Report

June 24, 2025
This Week in Crypto Games: B3’s Self-Destruct PC, Avalanche Battle Pass
Web3

This Week in Crypto Games: B3’s Self-Destruct PC, Avalanche Battle Pass

June 22, 2025
Book Genres List
Web3

Book Genres List

June 23, 2025
Next Post
Trader Says Bitcoin (BTC), Chainlink (LINK) and One Ethereum Rival Setting Up for Rallies

Trader Says Bitcoin (BTC), Chainlink (LINK) and One Ethereum Rival Setting Up for Rallies

What Could Trigger More Losses?

What Could Trigger More Losses?

Most Trending Cryptos on Ethereum Chain Today – Arky, Pepe, Kendu Inu

Most Trending Cryptos on Ethereum Chain Today - Arky, Pepe, Kendu Inu

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Twitter Instagram LinkedIn RSS Telegram
Coins League

Find the latest Bitcoin, Ethereum, blockchain, crypto, Business, Fintech News, interviews, and price analysis at Coins League

CATEGORIES

  • Altcoin
  • Analysis
  • Bitcoin
  • Blockchain
  • Crypto Exchanges
  • Crypto Updates
  • DeFi
  • Ethereum
  • Metaverse
  • NFT
  • Regulations
  • Scam Alert
  • Uncategorized
  • Web3

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 Coins League.
Coins League is not responsible for the content of external sites.

No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Metaverse
  • Web3
  • Scam Alert
  • Regulations
  • Analysis

Copyright © 2023 Coins League.
Coins League is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In