Giter Club home page Giter Club logo

web3j-cli's Introduction

web3j-cli: Web3j Command Line Tools

Documentation Status Build Status codecov Join the chat at https://gitter.im/web3j/web3j

About

The Web3j command line tools enable developers to interact with blockchains more easily. The Web3j command line tools allow allow you to use some of the key functionality of web3j from your terminal, including:

  • New project creation
  • Project creation from existing Solidity code
  • Wallet creation
  • Wallet password management
  • Ether transfer from one wallet to another
  • Generation of Solidity smart contract wrappers
  • Smart contract auditing

N.B. For version prior to 4.5.7 go to web3j/web3j releases

Installation

On Linux/macOS, in a terminal, run the following command:

curl -L get.web3j.io | sh

This script will not work if Web3j has been installed using Homebrew on macOS.

On Windows, in PowerShell, run the following command:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/web3j/web3j-installer/master/installer.ps1'))

Docs

https://docs.web3j.io/latest/command_line_tools/

Credits

Smart contract auditing functionality is provided by SmartCheck

web3j-cli's People

Contributors

alexandrour avatar antonydenyer avatar cfelde avatar conor10 avatar eepstein avatar gtebrean avatar iikirilov avatar josh-richardson avatar mohamedelshami avatar nicksneo avatar okbg avatar puneetha17 avatar rach-id avatar sfyumi avatar snazha-blkio avatar yuriymyronovych avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web3j-cli's Issues

Getting build errors for clean install

When I pull down and build web3j-cli using Windows/Eclipse/Gradle, I get the following errors. Where is it supposed to be pulling the org.web3j.console.openapi package from? I don't see it anywhere.

The import org.web3j.console.openapi.OpenApiCommand cannot be resolved	Web3jCommand.java	/web3j-cli/src/main/java/org/web3j/console	line 26	Java Problem
The import org.web3j.console.openapi.project.erc777.CopyUtils cannot be resolved	Erc777JavaProjectCreator.java	/web3j-cli/src/main/java/org/web3j/console/project/java	line 16	Java Problem

'No TypeConverter registered' when import wallet from private key

When execute a command web3j wallet import <private-key> getting an error:

No TypeConverter registered for java.util.Optional of field java.util.Optional<String> org.web3j.console.wallet.subcommands.WalletImportCommand.privateKey

The issue seems to be addressed in the library
remkop/picocli#1108

I will try to update the version. If it doesn't help I will just fix the code to bypass this problem, should be pretty easy.
I will submit PR soon if no objections

Project generation Failed - Windows

Microsoft Windows [Version 10.0.18363.1556]
(c) 2019 Microsoft Corporation. All rights reserved.

F:\work\Web3Labs\releases\testing-1474-issue>web3j new
_ _____ _
| | |____ ()
__ _| | / /
\ \ /\ / / _ \ '
\ \ \ |
\ V V / __/ |
) |./ / |
_/_/ _
|
./ _/| |
_/ |
|
_/
by Web3Labs
[ / ] Creating and building project ... Subsequent builds will be faster
Project generation Failed. Check log file for more information.

F:\work\Web3Labs\releases\testing-1474-issue>web3j -v
_ _____ _
| | |____ ()
__ _| | / /
\ \ /\ / / _ \ '
\ \ \ |
\ V V / __/ |
) |./ / |
_/_/ _
|
./ _/| |
_/ |
|
_/
by Web3Labs
Version: 1.4.1
Build timestamp: 2021-02-16 20:28:46.190 UTC

Logs:-
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.(VMPluginFactory.java:43)
at org.codehaus.groovy.reflection.GroovyClassValueFactory.(GroovyClassValueFactory.java:35)
at org.codehaus.groovy.reflection.ClassInfo.(ClassInfo.java:109)
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
at org.codehaus.groovy.reflection.ReflectionCache.(ReflectionCache.java:39)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:209)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:107)
...............

Can't generate java wrapper class of a smartcontract having struct array. Error: part 'struct MLevel' is keyword

I've a smartcontract in which I've a function getLevels() that returns an array of struct type MLevel, defined at the beginning of smartcontract.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

struct MLevel{
    address id;
    string levelPrize;
    uint levelNo;
    uint levelCriteria;
}

contract Test{

  MLevel[] public mlevels;

    function addLevel(uint _levelCriteria, string memory _levelPrize)public payable{
        MLevel memory level;
        level.id = msg.sender;
        level.levelCriteria = _levelCriteria;
        level.levelPrize = _levelPrize;
        mlevels.push(level);
    }

    function getLevels() public view returns(MLevel [] memory){
        return mlevels;
    }

}

The above smartcontract works absolutely fine in Remix ide. But when I try to create its java wrapper class using web3j, wrapper class does not generate and web3j ends with a weird error part 'struct MLevel' is keyword as shown below in the image
image

Web3j on M1 is broken

Hello when i run web3j new return me:

❯ web3j new
_ _____ _
| | |____ ()
__ _| | / /
\ \ /\ / / _ \ '
\ \ \ |
\ V V / __/ |
) |./ / |
_/_/ _
|
./ _/| |
_/ |
|
_/
by Web3Labs
[ | ] Creating and building project ... Subsequent builds will be faster
Project generation Failed. Check log file for more information.

Log file:

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':nodeSetup'.

Could not resolve all files for configuration ':detachedConfiguration3'.
Could not find org.nodejs:node:12.18.1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/nodejs/node/12.18.1/node-12.18.1.pom
- https://repo.maven.apache.org/maven2/org/nodejs/node/12.18.1/node-12.18.1-darwin-arm64.tar.gz
- https://jcenter.bintray.com/org/nodejs/node/12.18.1/node-12.18.1.pom
- https://jcenter.bintray.com/org/nodejs/node/12.18.1/node-12.18.1-darwin-arm64.tar.gz
- https://nodejs.org/dist/v12.18.1/node-v12.18.1-darwin-arm64.tar.gz
Required by:
project :

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

Macbook pro M1 Pro 16" Version: MacOS 12.3.1 (21E258)

Wallet import command not working?

When I do the command -
web3j wallet import private-key
it fails saying

No TypeConverter registered for java.util.Optional of field java.util.Optional org.web3j.console.wallet.subcommands.WalletImportCommand.privateKey

web3j [OPTIONS] [COMMAND]

can anyone tell me whats wrong here?

Why invalid project type.

image

I use web3j cli to generate the Java proxy class, but returns an error:Invalid project type. Expecting one of --solidityTypes or --javaTypes

My input is:web3j generate solidity --javaTypes -a /Users/z/Desktop/FixedPool.abi -b /Users/zhuyingzheng/Desktop/FixedPool.bin -o /Users/z/Desktop -p cms.contracts

(No such file or directory)

I am trying to generate a Solidity smart contract wrapper from an abi.

The abi is located in the same folder that I am running the command from, but the following fails:
web3j generate solidity --abiFile ./token_ERC1155_IERC1155_sol_IERC1155.abi --outputDir ./ --package package.name -c "Erc1155"

The error I am getting is:
token_ERC1155_IERC1155_sol_IERC1155.abi (No such file or directory)

Web3j-cli waits until all inputs have been given before validating them


              _      _____ _     _        
             | |    |____ (_)   (_)       
__      _____| |__      / /_     _   ___  
\ \ /\ / / _ \ '_ \     \ \ |   | | / _ \ 
 \ V  V /  __/ |_) |.___/ / | _ | || (_) |
  \_/\_/ \___|_.__/ \____/| |(_)|_| \___/ 
                         _/ |             
                        |__/              

Please enter the project name (Required Field): 
permissioning-smart-contracts
Please enter the package name for your project (Required Field): 
com.com
Please enter the path to your solidity file/folder (Required Field): 
/home/joshua/Dropbox/Projects/web3labs/pegasys/permissioning-smart-contracts/contracts
Please enter the destination of your project (current by default): 
java
permissioning-smart-contracts is not valid name.

Web3j-cli currently waits until all inputs have been entered when importing/creating a project, and then validates them. This is a poor user experience - we should validate inputs as they are entered to avoid frustration.

curl: certificate has expired

I was installed successfully due to I added the -k option on each curl command in installer.sh.

But why curl says it is expired, the certificate expires date is Jan 4 03:22:03 2022 GMT.

The output of curl -kvvl https://internal.services.web3labs.com

* Rebuilt URL to: https://internal.services.web3labs.com/
*   Trying 104.45.69.214...
* TCP_NODELAY set
* Connected to internal.services.web3labs.com (104.45.69.214) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=internal.services.web3labs.com
*  start date: Oct  6 03:22:04 2021 GMT
*  expire date: Jan  4 03:22:03 2022 GMT
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify result: certificate has expired (10), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fef35806600)
> GET / HTTP/2
> Host: internal.services.web3labs.com
> User-Agent: curl/7.54.0
> Accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200 
< server: openresty/1.15.8.2
< date: Mon, 11 Oct 2021 04:16:43 GMT
< content-type: text/html; charset=utf-8
< content-length: 39
< strict-transport-security: max-age=15724800; includeSubDomains
< x-frame-options: SAMEORIGIN
< 
* Connection #0 to host internal.services.web3labs.com left intact

Datetime on my PC

Mon Oct 11 12:17:59 CST 2021

curl --version

curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy 

Project generation Failed with Java 8

Unable to build and start the project using Java version 8.

WhatsApp Image 2021-12-13 at 22 19 29

Details can be found in the log below.

logs.zip

With Java 11 the problem doesn't happen.

Environment

Web3j version: 4.8.7
CLI: 1.4.1
Java version : 8
Operating System : Windows

access denied

D:\Download\web3j-cli-shadow-1.4.1\web3j-cli-shadow-1.4.1\bin>web3j generate truffle --truffle-json=<CRCManager.json> -o --outputDir= -p java
拒绝访问。

Have an issue with "Unknown options" for web3j solidity generate

I am working on converting my contract.sol to contract.java by using web3j. Web3j has been installed by using

curl -L get.web3j.io | sh and web3j --version shows

Version: 1.4.1
Build timestamp: 2021-02-16 20:28:33.742 UTC 

Command to generate contract.java is:

web3j solidity generate -a swapvalue.abi -b swapvalue.bin -o . -p ru.home.swap where .abi and .bin were generated with help of Remix IDE.

The observed behavior is an error Unknown options: '-a', 'swapvalue.abi', '-b', 'swapvalue.bin', '-o', '.', '-p', 'ru.home.swap' with unclear reason as this is the same what docs and others users suggest.

What is the issue with this command?

Build fails on master

Running on OS X

➜  web3j-cli git:(master) java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
➜  web3j-cli git:(master) ./gradlew build

> Task :compileJava
/Users/cmcewen/celo/web3j-cli/src/main/java/org/web3j/console/project/ProjectCreator.java:59: warning: [deprecation] <R>run(R,String...) in CommandLine has been deprecated
            CommandLine.run(new JavaProjectCreatorCLIRunner(), args);
                       ^
  where R is a type-variable:
    R extends Runnable declared in method <R>run(R,String...)
/Users/cmcewen/celo/web3j-cli/src/main/java/org/web3j/console/project/ProjectCreator.java:62: warning: [deprecation] <R>run(R,String...) in CommandLine has been deprecated
            CommandLine.run(new KotlinProjectCreatorCLIRunner(), args);
                       ^
  where R is a type-variable:
    R extends Runnable declared in method <R>run(R,String...)
/Users/cmcewen/celo/web3j-cli/src/main/java/org/web3j/console/project/ProjectImporter.java:39: warning: [deprecation] <R>run(R,String...) in CommandLine has been deprecated
            CommandLine.run(new JavaProjectImporterCLIRunner(), args);
                       ^
  where R is a type-variable:
    R extends Runnable declared in method <R>run(R,String...)
/Users/cmcewen/celo/web3j-cli/src/main/java/org/web3j/console/project/ProjectImporter.java:42: warning: [deprecation] <R>run(R,String...) in CommandLine has been deprecated
            CommandLine.run(new KotlinProjectImporterCLIRunner(), args);
                       ^
  where R is a type-variable:
    R extends Runnable declared in method <R>run(R,String...)
/Users/cmcewen/celo/web3j-cli/src/main/java/org/web3j/console/project/UnitTestCreator.java:46: warning: [deprecation] <R>run(R,String...) in CommandLine has been deprecated
            CommandLine.run(new JavaTestCLIRunner(), args);
                       ^
  where R is a type-variable:
    R extends Runnable declared in method <R>run(R,String...)
/Users/cmcewen/celo/web3j-cli/src/main/java/org/web3j/console/project/UnitTestCreator.java:49: warning: [deprecation] <R>run(R,String...) in CommandLine has been deprecated
            CommandLine.run(new KotlinTestCLIRunner(), args);
                       ^
  where R is a type-variable:
    R extends Runnable declared in method <R>run(R,String...)
6 warnings

> Task :test

org.web3j.console.WalletUpdaterTest > testWalletUpdate(Path) PASSED

org.web3j.console.WalletCreatorTest > testWalletCreation(Path) PASSED

org.web3j.console.KeyImporterTest > testLoadPrivateKeyFromFile(Path) PASSED

org.web3j.console.KeyImporterTest > testSpecifyPrivateKey(Path) PASSED

org.web3j.console.project.InteractiveOptionsTest > runInteractiveModeTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getProjectName() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getProjectRootTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getRootUserDirSubfolder() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getRootUserDir() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getWrapperPathTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getTestPathTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getPackageNameTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getSolidityPathTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getMainPathTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getRootTest() PASSED

org.web3j.console.project.java.JavaProjectStructureTest > getRootSpecialTildeCase() PASSED
[ / ] Creating Test5EXECould not build project.

org.web3j.console.project.java.JavaProjectImporterTest > testWithPicoCliWhenArgumentsAreCorrect() FAILED
    org.opentest4j.AssertionFailedError at JavaProjectImporterTest.java:76

org.web3j.console.project.java.JavaProjectImporterTest > verifyWhenInteractiveThatTestsHaveBeenGenerated() FAILED
    org.opentest4j.AssertionFailedError at JavaProjectImporterTest.java:95

org.web3j.console.project.java.JavaProjectImporterTest > testWhenCorrectArgsArePassedProjectStructureCreated() PASSED

org.web3j.console.project.java.JavaProjectImporterTest > testWithPicoCliWhenArgumentsAreEmpty() PASSED

org.web3j.console.project.java.JavaTestCreatorTest > testThatCorrectArgumentsArePassed() PASSED
[ / ] Creating TestingECUCould not build project.

org.web3j.console.project.java.JavaTestCreatorTest > verifyThatTestsAreGenerated() FAILED
    org.opentest4j.AssertionFailedError at JavaTestCreatorTest.java:77

org.web3j.console.project.java.JavaProjectImporterCLIRunnerTest > testWhenDuplicateArgsArePassed() PASSED

org.web3j.console.project.java.JavaProjectImporterCLIRunnerTest > testWhenNonDefinedArgsArePassed() PASSED

org.web3j.console.project.java.JavaProjectImporterCLIRunnerTest > testWhenNoArgsArePassed() PASSED

org.web3j.console.project.java.TemplateProviderTest > loadMainJavaClassTest() PASSED

org.web3j.console.project.java.TemplateProviderTest > loadGradlewScriptTest() PASSED

org.web3j.console.project.java.TemplateProviderTest > loadGradleSettingsTest() PASSED

org.web3j.console.project.java.TemplateProviderTest > loadGradleBuildTest() PASSED

org.web3j.console.project.java.TemplateProviderTest > loadGradlewBatScriptTest() PASSED

org.web3j.console.project.java.TemplateProviderTest > loadGradleWrapperTest() PASSED

org.web3j.console.project.java.JavaProjectCreatorCLIRunnerTest > testWhenDuplicateArgsArePassed() PASSED

org.web3j.console.project.java.JavaProjectCreatorCLIRunnerTest > testWhenNonDefinedArgsArePassed() PASSED

org.web3j.console.project.java.JavaProjectCreatorCLIRunnerTest > testWhenNoArgsArePassed() PASSED
[ / ] Creating TestCould not build project.

org.web3j.console.project.java.JavaProjectCreatorTest > testWithPicoCliWhenArgumentsAreCorrect() FAILED
    org.opentest4j.AssertionFailedError at JavaProjectCreatorTest.java:75

org.web3j.console.project.java.JavaProjectCreatorTest > testWhenCorrectArgsArePassedProjectStructureCreated() PASSED

org.web3j.console.project.java.JavaProjectCreatorTest > testWithPicoCliWhenArgumentsAreEmpty() PASSED

org.web3j.console.project.java.JavaProjectCreatorTest > testWhenInteractiveAndArgumentsAreCorrect() PASSED

org.web3j.console.project.java.JavaProjectCreatorTest > verifyThatTestsAreGenerated() FAILED
    org.opentest4j.AssertionFailedError at JavaProjectCreatorTest.java:95

org.web3j.console.project.java.JavaProjectTest > fileCreationTest() SKIPPED

40 tests completed, 5 failed, 1 skipped

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 1' finished with non-zero exit value 1
  This problem might be caused by incorrect test process configuration.
  Please refer to the test execution section in the User Manual at https://docs.gradle.org/5.6.3/userguide/java_testing.html#sec:test_execution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 36s
18 actionable tasks: 16 executed, 2 up-to-date```

[Windows 11] JCDP realted exception

OS Version
Windows 11

Web3j-CLI version

Version: 1.4.1
Build timestamp: 2021-02-16 20:28:46.190 UTC

Java version

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Tried on OpenJDK 11, Oracle JDK 8 too but came to the same exception.
Maybe the JCDP library doesn't consider that Windows 11 is compatible with Windows 10

Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.web3j.console.project.utils.ProjectCreationUtils.executeProcess(ProjectCreationUtils.java:62)
        at org.web3j.console.project.utils.ProjectCreationUtils.executeBuild(ProjectCreationUtils.java:49)
        at org.web3j.console.project.utils.ProjectCreationUtils.generateWrappers(ProjectCreationUtils.java:32)
        at org.web3j.console.project.AbstractProject.createProject(AbstractProject.java:65)
        at org.web3j.console.project.kotlin.KotlinProjectRunner.generateKotlin(KotlinProjectRunner.java:50)
        at org.web3j.console.project.kotlin.KotlinProjectCreatorRunner.createProject(KotlinProjectCreatorRunner.java:26)        at org.web3j.console.project.ProjectRunner.run(ProjectRunner.java:86)
        at org.web3j.console.project.NewProjectCommand.run(NewProjectCommand.java:55)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1729)
        at picocli.CommandLine.access$900(CommandLine.java:145)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1935)
        at picocli.CommandLine.execute(CommandLine.java:1864)
        at org.web3j.console.Web3jCommand.parse(Web3jCommand.java:113)
        at org.web3j.console.Web3j.main(Web3j.java:18)
Caused by: java.lang.UnsupportedOperationException: Your version of JCDP (v4.*) requires Windows 10 -- if you cannot upgrade, then use JCDP v3.*
        at com.diogonunes.jcdp.color.ColoredPrinter.<init>(ColoredPrinter.java:56)
        at com.diogonunes.jcdp.color.ColoredPrinter$Builder.build(ColoredPrinter.java:132)
        at org.web3j.console.openapi.utils.PrettyPrinter.<clinit>(PrettyPrinter.kt:24)
        ... 16 more

java file generated by web3j generate have error with dynamic array

super(org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.Bytes32>(userList),new org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.Bytes32>(ipList),new);

this 2 have same error

The constructor DynamicArray<Bytes32>(List<byte[]>) is undefined

can anyone help?

compatibility with web3j 4.2.0 android version

Which version of web3j cli is compatible with web3j 4.2.0 android version? Because when I am executing the solidity generation command the output generated has many errors.

Please help

Unable to install web3j cli on Mac

Hi everybody,

I got the following error when trying to install web3j cli on Mac :

curl -L get.web3j.io | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  6008  100  6008    0     0   4674      0  0:00:01  0:00:01 --:--:--     0
sh: line 2: jq: command not found

Var Binary is generated uncorrecly

faucet.sol.txt
Using web3j solidity command produces an uncorrect variable BINARY in the java wrapper file. For example, it produces

public static final String BINARY = "{\r\n" + "\t\"linkReferences\": {},\r\n" + "\t\"object\": \"608060405234801561001057600080fd5b5060e78061001f6000396000f3fe608060405260043610601c5760003560e01c80632e1a7d4d14601e575b005b348015602957600080fd5b50605360048036036020811015603e57600080fd5b81019080803590602001909291905050506055565b005b67016345785d8a0000811115606957600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801560ae573d6000803e3d6000fd5b505056fea265627a7a7231582084c311b9ac0189ec88df157c4bb2f87670475f5c6e5a3e1272778ceddc746d6064736f6c634300050c0032\",\r\n" + "\t\"opcodes\": \"PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0xE7 DUP1 PUSH2 0x1F PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH1 0x1C JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x2E1A7D4D EQ PUSH1 0x1E JUMPI JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH1 0x29 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x53 PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH1 0x3E JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH1 0x55 JUMP JUMPDEST STOP JUMPDEST PUSH8 0x16345785D8A0000 DUP2 GT ISZERO PUSH1 0x69 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH2 0x8FC DUP3 SWAP1 DUP2 ISZERO MUL SWAP1 PUSH1 0x40 MLOAD PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP4 SUB DUP2 DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1 ISZERO PUSH1 0xAE JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP POP JUMP INVALID LOG2 PUSH6 0x627A7A723158 KECCAK256 DUP5 0xc3 GT 0xb9 0xac ADD DUP10 0xec DUP9 0xdf ISZERO PUSH29 0x4BB2F87670475F5C6E5A3E1272778CEDDC746D6064736F6C634300050C STOP ORIGIN \",\r\n" + "\t\"sourceMap\": \"130:445:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;130:445:0;;;;;;;\"\r\n" + "}";
From the ABI and BIN attached, generated from Remix-IDE.
faucet.abi.txt
faucet.bin.txt

Could not generate ERC3643 Factory contract wrapper

Contract ABI json :

 {
  "anonymous": false,
  "inputs": [
   {
    "indexed": true,
    "internalType": "address",
    "name": "_addr",
    "type": "address"
   }
  ],
  "name": "Deployed",
  "type": "event"
 },
 {
  "anonymous": false,
  "inputs": [
   {
    "indexed": false,
    "internalType": "address",
    "name": "_idFactory",
    "type": "address"
   }
  ],
  "name": "IdFactorySet",
  "type": "event"
 },
 {
  "anonymous": false,
  "inputs": [
   {
    "indexed": false,
    "internalType": "address",
    "name": "_implementationAuthority",
    "type": "address"
   }
  ],
  "name": "ImplementationAuthoritySet",
  "type": "event"
 },
 {
  "anonymous": false,
  "inputs": [
   {
    "indexed": true,
    "internalType": "address",
    "name": "_token",
    "type": "address"
   },
   {
    "indexed": false,
    "internalType": "address",
    "name": "_ir",
    "type": "address"
   },
   {
    "indexed": false,
    "internalType": "address",
    "name": "_irs",
    "type": "address"
   },
   {
    "indexed": false,
    "internalType": "address",
    "name": "_tir",
    "type": "address"
   },
   {
    "indexed": false,
    "internalType": "address",
    "name": "_ctr",
    "type": "address"
   },
   {
    "indexed": false,
    "internalType": "address",
    "name": "_mc",
    "type": "address"
   },
   {
    "indexed": true,
    "internalType": "string",
    "name": "_salt",
    "type": "string"
   }
  ],
  "name": "TREXSuiteDeployed",
  "type": "event"
 },
 {
  "inputs": [
   {
    "internalType": "string",
    "name": "_salt",
    "type": "string"
   },
   {
    "components": [
     {
      "internalType": "address",
      "name": "owner",
      "type": "address"
     },
     {
      "internalType": "string",
      "name": "name",
      "type": "string"
     },
     {
      "internalType": "string",
      "name": "symbol",
      "type": "string"
     },
     {
      "internalType": "uint8",
      "name": "decimals",
      "type": "uint8"
     },
     {
      "internalType": "address",
      "name": "irs",
      "type": "address"
     },
     {
      "internalType": "address",
      "name": "ONCHAINID",
      "type": "address"
     },
     {
      "internalType": "address[]",
      "name": "irAgents",
      "type": "address[]"
     },
     {
      "internalType": "address[]",
      "name": "tokenAgents",
      "type": "address[]"
     },
     {
      "internalType": "address[]",
      "name": "complianceModules",
      "type": "address[]"
     },
     {
      "internalType": "bytes[]",
      "name": "complianceSettings",
      "type": "bytes[]"
     }
    ],
    "internalType": "struct ITREXFactory.TokenDetails",
    "name": "_tokenDetails",
    "type": "tuple"
   },
   {
    "components": [
     {
      "internalType": "uint256[]",
      "name": "claimTopics",
      "type": "uint256[]"
     },
     {
      "internalType": "address[]",
      "name": "issuers",
      "type": "address[]"
     },
     {
      "internalType": "uint256[][]",
      "name": "issuerClaims",
      "type": "uint256[][]"
     }
    ],
    "internalType": "struct ITREXFactory.ClaimDetails",
    "name": "_claimDetails",
    "type": "tuple"
   }
  ],
  "name": "deployTREXSuite",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
 },
 {
  "inputs": [],
  "name": "getIdFactory",
  "outputs": [
   {
    "internalType": "address",
    "name": "",
    "type": "address"
   }
  ],
  "stateMutability": "view",
  "type": "function"
 },
 {
  "inputs": [],
  "name": "getImplementationAuthority",
  "outputs": [
   {
    "internalType": "address",
    "name": "",
    "type": "address"
   }
  ],
  "stateMutability": "view",
  "type": "function"
 },
 {
  "inputs": [
   {
    "internalType": "string",
    "name": "_salt",
    "type": "string"
   }
  ],
  "name": "getToken",
  "outputs": [
   {
    "internalType": "address",
    "name": "",
    "type": "address"
   }
  ],
  "stateMutability": "view",
  "type": "function"
 },
 {
  "inputs": [
   {
    "internalType": "address",
    "name": "_contract",
    "type": "address"
   },
   {
    "internalType": "address",
    "name": "_newOwner",
    "type": "address"
   }
  ],
  "name": "recoverContractOwnership",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
 },
 {
  "inputs": [
   {
    "internalType": "address",
    "name": "_idFactory",
    "type": "address"
   }
  ],
  "name": "setIdFactory",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
 },
 {
  "inputs": [
   {
    "internalType": "address",
    "name": "_implementationAuthority",
    "type": "address"
   }
  ],
  "name": "setImplementationAuthority",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
 }
]```






Got error:
web3j generate solidity --abiFile=/smart-contracts/TREXFactory.json --outputDir=./ --package=com.contract
              _      _____ _
             | |    |____ (_)
__      _____| |__      / /_
\ \ /\ / / _ \ '_ \     \ \ |
 \ V  V /  __/ |_) |.___/ / |
  \_/\_/ \___|_.__/ \____/| |
                         _/ |
                        |__/
by Web3Labs
Generating com.hamsa.TREXFactory ... SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/Users/lijunjie/.web3j/web3j-cli-shadow-1.5.3/lib/web3j-cli-1.5.3-all.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
class com.squareup.javapoet.ParameterizedTypeName cannot be cast to class com.squareup.javapoet.ClassName (com.squareup.javapoet.ParameterizedTypeName and com.squareup.javapoet.ClassName are in unnamed module of loader 'app')

Wallet import bug

Import besu test account

web3j wallet import 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3

and there is an import error

No TypeConverter registered for java.util.Optional of field java.util.Optional<String> org.web3j.console.wallet.subcommands.WalletImportCommand.privateKey

I see that web3j-cli uses picocli of version 4.0.4. This version of picocli cann't handle Optional<T> Parameter field, and picocli supports Optional<T> type for options and positional parameters after version 4.6.0.

I will submit a pull request to fix this.

using the latest version of web3j-cli locally while waiting for the new release

When trying to create contract wrapper with web3j generate solidity -b -pathToBinaryFile -a pathToAbiFile -o -p path, the following exception is thrown "part 'struct *'" is keyword. The issue appears because in the solidity contract I have a function which has a list of structs as a parameter.
Web3j used is ### 1.4.1.
Does web3j support this type of function params or can you suggest any workaround for this? I saw this pr https://github.com/web3j/web3j-cli/pull/85 and I was wondering if this may fix this issue, if so can you please give me some indication on how to set it locally till it is merged and published?

Is PreCompiledContractOptions used at all when calling web3j openapi generate?

Trying to use the cli's web3j openapi generate command on a project that uses external imports (solidity files in a directory other than the one specified with the -s option) swiftly runs into errors. I found a workaround for this when generating wrappers by having truffle generate ABIs, then passing that to web3j with the --abi option, however I can't find this being implemented for web3j openapi generate. The only hint to it being considered at one point is the existence of PreCompiledContractOptions, but I couldn't find any usage of it, so I assume it is also not implemented.

Am I mistaken here, and is there a way to pass ABIs to openapi generate? If not, I'd be grateful if this feature was implemented. (Not having to use a workaround for a common scenario would also be excellent, but this in itself would save me a fair bit of headache.)

Issue generating Java class from truffle json

Hey folks, I'm hoping someone can help me with this. Basically trying to generate a Java contract class from the compiled JSON from Remix:

web3j generate truffle generate -t CoinFlip.json -o . -p com.mypackage
              _      _____ _ 
             | |    |____ (_)
__      _____| |__      / /_ 
\ \ /\ / / _ \ '_ \     \ \ |
 \ V  V /  __/ |_) |.___/ / |
  \_/\_/ \___|_.__/ \____/| |
                         _/ |
                        |__/ 
by Web3Labs
Generating com.mypackage.CoinFlip ... null

No output, and it just appends null to the console message for some reason.

I tried poking around in SolidityFunctionWrapperGenerator and SolidityFunctionWrapper but nothing stood out to me as being amiss. Any pointers on how to get that to work would be great!

File outside of allowed directories

This seems similar to: hyperledger/web3j-solidity-gradle-plugin#1

> Task :compileSolidity FAILED
Error: Source "src/main/solidity/lib/contractmodule.sol" not found: File outside of allowed directories.
 --> src/main/solidity/core/impl/mycontract.sol:6:1:
  |
6 | import "../../lib/contractmodule.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Is there a workaround for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.