{"id":20934387,"url":"https://github.com/harmony-one/harmonyj","last_synced_at":"2026-03-01T04:08:56.548Z","repository":{"id":36169723,"uuid":"222042927","full_name":"harmony-one/harmonyj","owner":"harmony-one","description":"Harmony Java SDK","archived":false,"fork":false,"pushed_at":"2025-03-14T00:27:17.000Z","size":180,"stargazers_count":28,"open_issues_count":3,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-12T13:05:20.776Z","etag":null,"topics":["blockchain","harmony","java","libarary","sharding","staking"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harmony-one.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-16T03:45:22.000Z","updated_at":"2025-03-14T00:27:21.000Z","dependencies_parsed_at":"2022-07-25T19:48:20.926Z","dependency_job_id":null,"html_url":"https://github.com/harmony-one/harmonyj","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harmony-one/harmonyj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-one%2Fharmonyj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-one%2Fharmonyj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-one%2Fharmonyj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-one%2Fharmonyj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harmony-one","download_url":"https://codeload.github.com/harmony-one/harmonyj/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-one%2Fharmonyj/sbom","scorecard":{"id":455977,"data":{"date":"2025-08-11","repo":{"name":"github.com/harmony-one/harmonyj","commit":"c22711406ade45ef65106ec997e393cfc3e64796"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 2/20 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T09:41:19.157Z","repository_id":36169723,"created_at":"2025-08-19T09:41:19.157Z","updated_at":"2025-08-19T09:41:19.157Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29960236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","harmony","java","libarary","sharding","staking"],"created_at":"2024-11-18T22:09:09.550Z","updated_at":"2026-03-01T04:08:56.516Z","avatar_url":"https://github.com/harmony-one.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Harmony Java SDK\n\nHarmonyJ is a light-weight Java library for interacting with [Harmony](https://harmony.one) blockchain. For high-level information about Harmony and its goals, visit [harmony.one](https://harmony.one). \nThe [harmony white paper](https://harmony.one/pdf/whitepaper.pdf) provides a complete conceptual overview.\n\n## Features\n* Partial implementation of Harmony's JSON-RPC client API over HTTP with features\n* Local key management\t\n* Accounts and getting balance\n* Creating, signing, and sending transactions\n\nDependencies\n* [web3j](https://github.com/web3j/web3j/)\n* [bitcoinj](https://github.com/bitcoinj/bitcoinj)\n* Java 8 and Gradle 5.6.4\n\n## Getting started\n\nTo get started, it is best to have the latest JDK and Gradle installed.\n\n### Installation\nAdd the following Maven dependency to your project's `pom.xml`:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eone.harmony\u003c/groupId\u003e\n  \u003cartifactId\u003eharmonyj\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.20\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Building from the command line\n\nTo perform a full build (including JavaDocs and unit/integration tests) use JDK 8+\n\n```\ngradle clean build\n```\n\nTo perform a full build without unit/integration tests use:\n\n```\ngradle clean assemble\n```\n\n### Specifying configuration properties\n\nHarmonyJ reads the below listed user specified properties from `{user.home}/hmy-config.properties` file.\n* `node` Harmony URL to connect to\n* `keystore.dir` The keystore directory path. This should be absolute path.\n* `accounts.dir` The accounts directory alias where the accounts and key files are stored.\n* `passphrase` The default passphrase to use   \n* `mnemonics.file.path` The path to mnemonics file that stores the generated mnemonics\n\nAn example hmy-config.properties file looks like:\n\n```\nnode=http://localhost:9500/\nkeystore.dir=/Users/john/kestore.local\naccounts.dir=accounts-keys\npassphrase=harmony-one\nmnemonics.file.path=/Users/john/kestore.local/mnemonics.txt\n```\n\nAnother way to pass the configuration parameters is using the `Config.setConfigParameters` method.\n\n```java\nimport one.harmony.common.Config;\n\npublic class Test {\n\tpublic static void main(String[] args) throws Exception {\n\t\tString nodeUrl = \"http://localhost:9500\";\n\t\tString keystoreDir = \"/Users/john/mystore\";\n\t\tString accountsDir = \"accounts-keys\";\n\t\tString defaultPassPhrase = \"harmony-one\";\n\t\tConfig.setConfigParameters(nodeUrl, keystoreDir, accountsDir, defaultPassPhrase);\n\t}\n}\n```\n\nIf the user wants to specify an absolute file path to store the generated mnemonics:\n```java\n\t...\n\tString mnemonicsFilePath = keystoreDir + \"/mnemonics.txt\";\n\tConfig.setConfigParameters(nodeUrl, keystoreDir, accountsDir, defaultPassPhrase, mnemonicsFilePath);\n```\n\n### Generating Javadoc\n\nHarmonyJ provides information about SDK classes and methods also in the form of `javadoc` that can be generated using gradle.\n\n```\ngradle javadoc\n```\n\n## Examples\n\nThe key API classes can be found under `one.harmony.cmd` are:\n1. [Blockchain](https://github.com/harmony-one/harmonyj/blob/master/src/main/java/one/harmony/cmd/Blockchain.java)\n2. [Balance](https://github.com/harmony-one/harmonyj/blob/master/src/main/java/one/harmony/cmd/Balance.java)\n3. [Transfer](https://github.com/harmony-one/harmonyj/blob/master/src/main/java/one/harmony/cmd/Transfer.java)\n4. [Keys](https://github.com/harmony-one/harmonyj/blob/master/src/main/java/one/harmony/cmd/Keys.java)\n5. [Contract](https://github.com/harmony-one/harmonyj/blob/master/src/main/java/one/harmony/cmd/Contract.java)\n\n\n### Blockchain\n\nCurrently, the `Blockchain` class only provides an api for fetching the Harmony protocol version. In future, this class will support more functionalities like querying block information, etc.\nThe example shown below retrieves the protocol version. \n\n```java\nimport one.harmony.cmd.Blockchain;\n\npublic void getProtocolVersion() {\n\tString protocol = Blockchain.getProtocolVersion();\n}\n```\nBlockchain class can be used to send raw transactions.\n```java\nimport one.harmony.cmd.Blockchain;\n\npublic static void main(String[] args) throws Exception {\n\tString nodeUrl = \"http://localhost:9500\";\n\tString rawTransaction = \"0x...\";\n\tString txHash = Blockchain.sendRawTransaction(nodeUrl, rawTransaction);\n}\n\n```\n\nThe account transactions history can be queried as follows:\n\n```java\nimport one.harmony.cmd.Blockchain;\n\npublic static void main(String[] args) throws Exception {\n\t// By default Config.node is used, however, a node url can be passed\n\tString node = \"http://localhost:9500/\";\n\tString address = \"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\";\n\tHistoryParams params = new HistoryParams(address);\n\t// For getting only transaction hashes, set `params.setFullTx(false)`\n\tSystem.out.println(getAccountTransactions(node, params));\n}\n```\n\nThe output with full transaction history will be: \n```\n[\n\t{\n\t\t\"blockHash\":\"0x57db6b6622c2fc6a047d372750c4f0bbf1745847b27848126290a5e0621b9a6c\",\n\t\t\"blockNumber\":\"0x18db22\",\n\t\t\"from\":\"one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg\",\n\t\t\"gas\":\"0x33450\",\n\t\t\"gasPrice\":\"0x174876e800\",\n\t\t\"hash\":\"0x6193734698696eb8e33354a54493e0a760d5e00ef12710bd0847cddd09e85e9a\",\n\t\t\"input\":\"0x\",\n\t\t\"nonce\":\"0x1f\",\n\t\t\"r\":\"0xa00c7c12ae9ca9dbfbea0abc0fe9abc241bcd73caf9849e7194002f354c1088e\",\n\t\t\"s\":\"0x588dcfbb8fc354465d2ba6393a09b8ccb555ec647d97de639a106a071f755b77\",\n\t\t\"shardID\":0,\n\t\t\"timestamp\":\"0x5de4ca90\",\n\t\t\"to\":\"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\",\n\t\t\"toShardID\":0,\n\t\t\"transactionIndex\":\"0x0\",\n\t\t\"v\":\"0x26\",\n\t\t\"value\":\"0x16345785d8a0000\"\n\t}, ...\n]\n```\n\nThe output with only transaction hashes:\n\n```\n[\n\t\"0x6193734698696eb8e33354a54493e0a760d5e00ef12710bd0847cddd09e85e9a\",\n\t\"0xd53a22fdac3697d049f1a76c528da42502a1b4be9a37bf6e11ae5ef55d3672cd\",\n\t...\n]\n```\n\n\n### Balance\n\nThe `Balance` class provides an api for checking the balance of a Harmony account using the Harmony's one address. The `check` method retrieves balances on all shards (note that, Harmony is a sharded blockchain).\nThe example below retrieves the balance of a localnet account.\n\n```java\nimport one.harmony.cmd.Balance;\n\npublic void queryBalance() throws Exception {\n\tString oneAddress = \"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\";\n\tBalance.check(oneAddress);\n}\n```\n\nThe sample output is:\n\n\n```\n[\n\t{ \n\t\t\"shard\": 0, \n\t\t\"amount\": 15926.97359095238 \n\t},\n\t{ \n\t\t\"shard\": 1, \n\t\t\"amount\": 0.0 \n\t}\n]\n```\n\nFor checking the balance using your own Harmony node:\n\n```java\nimport one.harmony.cmd.Balance;\n\npublic void queryBalance() throws Exception {\n\tString oneAddress = \"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\";\n\tBalance.checkLocal(oneAddress);\n}\n```\nThe sample output is: `206.1904761904762`\n\n\n### Transfer\n\nThe transfer class provides functionality to transfer funds between any two Harmony accounts. The key api's are `Transfer` constructor and `execute` method. The `execute` method returns the transaction hash of the transfer. To check that transfer is committed to the blockchain, increase the `waitToConfirmTime` in seconds. \nAn example is shown below:\n\n```java\nimport one.harmony.cmd.Transfer;\n\npublic void testTransfer() throws Exception {\n\tString from = \"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\"; // Harmony localnet addresses\n\tString to = \"one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp\"; // Harmony localnet addresses\n\tString amount = \"50.714285714\";\n\tint fromShard = 0;\n\tint toShard = 1;\n\tboolean dryRun = false;\n\tint waitToConfirmTime = 0;\n\tString passphrase = \"harmony-one\";\n\tString memo = \"0x5061796d656e7420666f722078797a\";\n\tTransfer t = new Transfer(from, to, amount, fromShard, toShard, memo);\n\tt.prepare(passphrase); // prepare transfer locally, before connecting to the network\n\tString txHash = t.execute(LOCAL_NET, dryRun, waitToConfirmTime); // needs connection to the network\n}\n```\n\nFor the transfer to work, the `from` address account key must exists in the local keystore. If not, add the key using the key management apis.\nThe transfer automatically creates a transaction, encodes it, signs the transaction using `from` address's key, and sends it to the blockchain. \n\nFor performing transfers using Harmony node use:\n```java\nString nodeUrl ; \"http://127.0.0.1:9500\";\nt.prepare(passphrase, nodeUrl);\nString txHash = t.execute(LOCAL_NET, dryRun, waitToConfirmTime)\n```\n\n### Keys\n\nThe `Keys` class provides the local key management functionality such as creating new account or adding a key, importing/exporting a private key or keystore, listing local accounts, etc. \n\n#### Add key\n\nMultiple addKey apis are provided. The `addKey` api returns the Harmony one address of the created account. \n\n```java\npublic static String addKey(String accountName, String passphrase, String mnemonic);\npublic static String addKey(String accountName, String passphrase);\npublic static String addKey(String accountName);\n```\n\nAn example:\n\n```java\nimport one.harmony.cmd.Keys;\n\nString mnemonics = \"\"; // long string containing words\nString oneAddress = Keys.addKey(\"a2\", \"harmony\", mnemonics);\n```\n\n#### Import private key\n\nTo create an account using a private key, use `importPrivateKey` api. This api returns the Harmony one address of the created account.\n\n```java\npublic static String importPrivateKey(String secp256k1PRV, String accountName, String passphrase);\npublic static String importPrivateKey(String secp256k1PRV, String accountName);\n```\n\nAn example:\n\n```java\nimport one.harmony.cmd.Keys;\n\nString key = \"fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3\"; // dummy private key\nString accountName = \"a1\";\nString oneAddress = Keys.importPrivateKey(key, accountName);\n```\n\nSample output:\n\n```\none1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\n```\n\n#### Import keystore\n\nTo import a keystore file (`json` file describing the keystore) as shown below, use `importKeyStore` api and pass the account name.\n\n```\n{\n    \"address\":\"\",\n    \"id\":\"\",\n    \"version\":3,\n    \"crypto\":{\n    \t...\n    }\n}\n```\n\n```java\npublic static String importKeyStore(String keyFilePath, String accountName);\npublic static String importKeyStore(String keyFilePath, String accountName, String passphrase);\n```\n\n#### Export private key\n\n```java\npublic static String exportPrivateKeyFromAddress(String oneAddress, String passphrase);\npublic static String exportPrivateKeyFromAddress(String oneAddress);\npublic static String exportPrivateKeyFromAccountName(String accountName, String passphrase);\npublic static String exportPrivateKeyFromAccountName(String accountName);\n```\n\n\n#### Export keystore\n\nFor exporting the keystore file `exportKeyStore...` apis can be used. Multiple variations of the `exportKeyStore...` api are provided.\n\n```java\npublic static String exportKeyStoreFromAddress(String oneAddress, String passphrase);\npublic static String exportKeyStoreFromAddress(String oneAddress);\npublic static String exportKeyStoreFromAccountName(String accountName, String passphrase);\npublic static String exportKeyStoreFromAccountName(String accountName);\n```\n\n\n#### List local accounts\n\nThe list all local account information use `listAccounts` api.\n\n```java\nimport one.harmony.Keys;\n\nMap\u003cString, String\u003e accountInfo = Keys.listAccounts();\n```\nThe output will display account names and Harmony one addresses for all the local accounts.\n\n#### Get key location\n\nTo retrieve the local keystore path use `getKeysLocation` api. \n\n```java\nimport one.harmony.cmd.Keys;\n\nString keydir = Keys.getKeysLocation();\n```\n\n#### Change local account name\n\nThe `setAccountName(oneAddress, accountName)` lets users to change the account name associated with a local account with Harmony one address.\n\n```java\nimport one.harmony.cmd.Keys;\n\nString oneAddress = \"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\";\nboolean status = Keys.setAccountName(oneAddress, \"local-account-2\");\n```\n\n#### Clean keystore\n\nThe `cleanKeyStore()` api wipes out the keystore and permanently deletes all the local account informations.\n\n```java\nimport one.harmony.cmd.Keys;\n\nKeys.cleanKeyStore();\n```\n\nFor details about all the APIs, refer to javadocs.\n\n### Contract\n\nSimilar to Web3j, Harmonyj provides a codegen feature to generate a java wrapper for your contract, which can be used to deploy and interact with contract. The steps are as follows:\n1. Generate `.abi` and `.bin` file for your contract\n2. Generate `.java` wrapper for your contract\n3. Use `.java` to deploy and interact with your contract\n\nThe detailed steps are below:\n\nGenerate `.abi` and `.bin` files for your solidity contract. e.g., if you have `Counter.sol`, you could use `solc` or `solcjs`\n\n```sol\ncontract Counter {\n    int256 private count = 0;\n\n    function incrementCounter() public {\n        count += 1;\n    }\n\n    function decrementCounter() public {\n        count -= 1;\n    }\n\n    function getCount() public view returns (int256) {\n        return count;\n    }\n}\n```\n\n```\nsolcjs Counter.sol --bin --abi --optimize -o \u003coutput-dir\u003e\n```\n\nThe output directory will contain `Counter_sol_Counter.abi` and `Counter_sol_Counter.bin`.\n\nGenerate Harmonyj wrapper, using `SolidityFunctionWrapperGenerator` class. e.g.,\n\n```java\nString[] options = new String[] { \"-a\", \"Counter_sol_Counter.abi\", \"-b\", \"Counter_sol_Counter.bin\", \"-o\", \".\", \"-p\", \"one.harmony.cmd\" };\nSolidityFunctionWrapperGenerator.main(options);\n```\nThe possible options that can be passed are:\n```\n  -h, --help                 Show this help message and exit.\n  -V, --version              Print version information and exit.\n  -a, --abiFile=\u003cabiFile\u003e    abi file with contract definition.\n  -b, --binFile=\u003cbinFile\u003e    bin file with contract compiled code in order to\n                               generate deploy methods.\n  -o, --outputDir=\u003cdestinationFileDir\u003e\n                             destination base directory.\n  -p, --package=\u003cpackageName\u003e\n                             base package name.\n      -jt, --javaTypes       use native java types.\n                               Default: true\n      -st, --solidityTypes   use solidity types.\n```\n\nThe `SolidityFunctionWrapperGenerator` will generate a wrapper `Counter_sol_Counter.java` int the package `one.harmony.cmd`, which can be used to deploy the contract and interact.\n\n#### Deploying the contract\n\nImport/add the account that you wish to use for deploying the contract. e.g.,\n```java\nString key = \"fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3\";\nString accountName = \"a1\";\nKeys.importPrivateKey(key, accountName);\n```\n\nCreate a handler with account information such as one-address, passphrase, node url, and chainID. For mainnet: `ChainID.MAINNET`, testnet: `ChainID.TESTNET`, localnet: `ChainID.LOCAL`.\n```java\nString from = \"one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy\";\nString passphrase = \"harmony-one\";\nString node = \"http://127.0.0.1:9500/\";\nHandler handler = new Handler(from, passphrase, node, ChainID.LOCAL);\n```\n\nCreate a contract gas provider:\n```java\nclass MyGasProvider extends StaticGasProvider {\n\tpublic MyGasProvider(BigInteger gasPrice, BigInteger gasLimit) {\n\t\tsuper(gasPrice, gasLimit);\n\t}\n}\nMyGasProvider contractGasProvider = new MyGasProvider(new BigInteger(\"1\"), new BigInteger(\"6721900\")); \n```\n\nDeploy contract:\n```java\nCounter_sol_Counter counter = Counter_sol_Counter.deploy(handler, contractGasProvider).send();\nSystem.out.println(\"Contract deploy at \" + counter.getContractAddress());\n```\n\nLoad the deployed contract for interacting:\n```java\nMyGasProvider contractGasProvider = new MyGasProvider(new BigInteger(\"1\"), new BigInteger(\"6721900\")); \nCounter_sol_Counter contract = Counter_sol_Counter.load(contractAddress, contractGasProvider);\ncontract.setHandler(handler);\n```\nFor read-only contract interactions (such as calling a contract to fetch some value), the handler need not be associated with an account. e.g., \n```java\nString node = \"http://127.0.0.1:9500/\";\nHandler handler = new Handler(node, ChainID.LOCAL);\n```\nFor modifying (or updating) the contract, the handler must be associated with an account, as shown for deploying.\n\nCalling a read-only contract method. e.g., `getCount()` in the Counter contract:\n```java\nSystem.out.println(\"Value stored in remote smart contract: \" + contract.getCount().send());\n```\n\nUpdating the contract, e.g., `incrementCounter()` in the Counter contract:\n```java\nTransactionReceipt transactionReceipt = contract.incrementCounter().send();\n```\nThe `TransactionReceipt` will contain all the details:\n```\n{\n\ttransactionHash='0x54492458ea1b6200a481d38dc99cb8a19cea16ee777c5ea95bcfafabd7293392', \n\ttransactionIndex='0x0', \n\tblockHash='0xe5b6de4343dda1433c3fcffefbc008e17a8a1d17eaa794a8541be10acc67281f', \n\tblockNumber='0xb3a', \n\tcumulativeGasUsed='0xa289', \n\tgasUsed='0xa289', \n\tcontractAddress='null', \n\troot='null', \n\tstatus='0x1', \n\tfrom='one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', \n\tto='one19f70ncsqp3ny7wp2h5vmd2540zr6yx2yjs45n7', \n\tlogs=[], logsBloom='0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'\n}\n```\n\nFor the complete auto-generated Counter contract: [Auto-generated Counter contract wrapper](https://github.com/harmony-one/harmonyj/blob/master/src/test/java/one/harmony/cmd/Counter_sol_Counter.java)\n\nComplete example of deploying and interacting with Counter contract: [CounterContractExample](https://github.com/harmony-one/harmonyj/blob/master/src/test/java/one/harmony/cmd/CounterContractExample.java)\n\nDecoding the contract logs:\n\nAfter updating a contract, if we want to process the logs for events, e.g., in the Greeter.sol contract, we want to process the emitted event `Modified`\n```sol\nfunction newGreeting(string memory _greeting) public {\n\temit Modified(greeting, _greeting, greeting, _greeting);\n\tgreeting = _greeting;\n}\n\nevent Modified(\n\tstring indexed oldGreetingIdx, string indexed newGreetingIdx,\n\tstring oldGreeting, string newGreeting\n);\n```\n```java\nTransactionReceipt transactionReceipt = contract.newGreeting(\"Well hello again\").send();\nfor (Greeter_sol_Greeter.ModifiedEventResponse event : contract.getModifiedEvents(transactionReceipt)) {\n\tSystem.out.println(\n\t\t\t\"Modify event fired, previous value: \" + event.oldGreeting + \", new value: \" + event.newGreeting);\n\tSystem.out.println(\"Indexed event previous value: \" + Numeric.toHexString(event.oldGreetingIdx)\n\t\t\t+ \", new value: \" + Numeric.toHexString(event.newGreetingIdx));\n}\n```\n\nThe complete [GreeterContractExample](https://github.com/harmony-one/harmonyj/blob/master/src/test/java/one/harmony/cmd/GreeterContractExample.java)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmony-one%2Fharmonyj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharmony-one%2Fharmonyj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmony-one%2Fharmonyj/lists"}