Skip to content

The Ballerina Web3 module is part of the Ballerina Standard Library. It is capable of generating Ballerina connector for a given smart contract.

License

Notifications You must be signed in to change notification settings

thil4n/web3-tools

Repository files navigation

Ballerina Web3 Tool

Build codecov GitHub Last Commit GitHub issues

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.

Installation

Execute the command below to pull the Web3 tool from Ballerina Central.

bal tool pull web3

Usage

The Web3 tool provides the following capabilities.

  1. Generate Ballerina client for interacting with basic Blockchain features.
  2. 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>

Command options

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.json

Upon 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

Building from the Source

Setting Up the Prerequisites

  1. 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.

  2. Export GitHub Personal access token with read package permissions as follows,

    export packageUser=<Username>
    export packagePAT=<Personal access token>
    

Building the Source

Execute the commands below to build from the source.

  1. To build the library:

    ./gradlew clean build
    
  2. To run the integration tests:

    ./gradlew clean test
    
  3. To build the module without the tests:

    ./gradlew clean build -x test
    
  4. To publish to maven local:

    ./gradlew clean build publishToMavenLocal
    
  5. Publish the generated artifacts to the local Ballerina central repository:

    ./gradlew clean build -PpublishToLocalCentral=true
    
  6. Publish the generated artifacts to the Ballerina central repository:

    ./gradlew clean build -PpublishToCentral=true
    

Contributing to Ballerina

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.

Code of Conduct

All contributors are encouraged to read the Ballerina Code of Conduct.

Useful Links

About

The Ballerina Web3 module is part of the Ballerina Standard Library. It is capable of generating Ballerina connector for a given smart contract.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published