The Ballerina-Web3-Tool is a development toolkit designed to simplify the integration of Web3 functionalities into Ballerina applications. It provides a seamless experience for developers to interact with Ethereum-based blockchains, enabling smart contract interactions, account management, and transaction processing.
Execute the command below to pull the Web3 tool from Ballerina Central.
bal tool pull web3The Web3 tool provides the following capabilities.
- Generate Ballerina client for interacting with basic Blockchain features.
- Generate Ballerina connector for specific Smart contract.
The client generated from a smart contract can be used to call the methods defined in the solidity smart contract.
The following command will generate Ballerina client for the given smart contract.
bal web3 -a <abi-file-path> -o <output-file-path>| Option | Description | Mandatory/Optional |
|---|---|---|
<abi-file-path> |
The path of the Solidity ABI file. | Mandatory |
<output-path> |
The path of the output directory. If not provided, the current working directory will be used. | Optional |
For example,
bal web3 -a Token.jsonUpon successful execution, the following files will be created inside the default module in the Ballerina project.
client.bal (There can be multiple client files depending on the Web3 file)
utils.bal-
OpenJDK 21 (Adopt OpenJDK or any other OpenJDK distribution)
Info: You can also use Oracle JDK. Set the JAVA_HOME environment variable to the pathname of the directory into which you installed JDK.
-
Export GitHub Personal access token with read package permissions as follows,
export packageUser=<Username> export packagePAT=<Personal access token>
Execute the commands below to build from the source.
-
To build the library:
./gradlew clean build -
To run the integration tests:
./gradlew clean test -
To build the module without the tests:
./gradlew clean build -x test -
To publish to maven local:
./gradlew clean build publishToMavenLocal -
Publish the generated artifacts to the local Ballerina central repository:
./gradlew clean build -PpublishToLocalCentral=true -
Publish the generated artifacts to the Ballerina central repository:
./gradlew clean build -PpublishToCentral=true
As an open-source project, Ballerina welcomes contributions from the community.
You can also check for open issues that interest you. We look forward to receiving your contributions.
For more information, go to the contribution guidelines.
All contributors are encouraged to read the Ballerina Code of Conduct.
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.
- View the Ballerina performance test results.