Questions tagged [web3-java]

For the web3j java library and related Java issues

Ethereum client library for Java (web3j). Web3j provides code generation tools for Java and Android applications to deploy and interact with smart contracts on the blockchain.

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

Note - This is NOT for web3js, which is the JavaScript version of the Ethereum client library.

160 questions
3
votes
1 answer

Getting ERC1155 Wallet Balance Using Java Web3J

Since Web3J doesn't currently support ERC1155, is there a way to get the balance for a wallet? My guess is to use a function for this, but I can't seem to figure out how to get it to work. Function function = new Function( "balancedOf", …
juminoz
  • 3,168
  • 7
  • 35
  • 52
3
votes
1 answer

ERC20 class not found in web3 core android library

I am working with web3 in android. I am using web3j core version 4.8.7 but when I try to do a transaction I can't find the ERC20 class in the library.
Jahangir Jadi
  • 103
  • 1
  • 7
3
votes
1 answer

How to connect Metamask to Web3J (java)

I am trying to connect my Metamask wallet to my Java Spring-Boot backend. I was trying to follow the example here. I am able to autogenerate the nonce and receive the wallet ID without a problem. I am trying to verify the signed nonce from the…
whiplash
  • 695
  • 5
  • 20
3
votes
0 answers

How to sign transaction using Mnemonic?

I'm using the web3j library with the generated SmartContract wrapper. I'm able to successfully sign a transaction, deploy it to 3rd party node, and interact with the smart contract using the keystore file and the password Credentials credentials =…
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
3
votes
0 answers

Getting smart contract events (web3j)

Please check/provide contract events example with web3j. I got stuck several days, for what should be straightforward: Getting smart contract events /** * Using Web3j .ethLogFlowable(filter).subscribe() * that is sending eth_newFilter…
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
3
votes
2 answers

How to call a function that returns tuple[]

I am relatively new to interacting with smart contracts in Java and I am facing a problem while trying to retrieve a tuple[] returned by the smart contract function. Here is the ABI definition of the function I want to call: { …
Coin Lover
  • 31
  • 3
3
votes
1 answer

Web3j and Uniswap Router V2, converting wei to uint256

the issue I'm having is that I'm trying to send a value in wei to swapExactETHForTokens, but it returns Fail with error 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'. If I convert 1 ETH to wei (in code) it comes out as 1000000000000000000. When…
Sorin Grecu
  • 1,036
  • 11
  • 30
3
votes
1 answer

How could I decode the input data of a transaction?

I'm using web3j in java to get the input data of a transaction. I can get the data, but the problem is how can I decode this data. Input data:…
3
votes
1 answer

web3j replaying all contracts events

Question regarding Web3j library. How can I replay all the logs from the blockchain using web3j ? I know there is a method to replay all the logs from a particular contract: EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST, …
RB_
  • 1,195
  • 15
  • 35
3
votes
0 answers

Web3J: Subscription code for listening to event is executing twice by two different threads

I am developing an app with SpringBoot and Web3J, where i use a contract wrapper for interacting with Smart contract. Here is the autogenerated code of a method for listening to an event, called NewId: public Observable
3
votes
4 answers

What is the wallet path for credentials in web3j?

I am using the readme guide https://github.com/web3j/web3j. What I am interested is developing smart contracts from my host with Java + Web3j to private Ethereum network which runs on my virtual machine. There are such lines: Web3j web3 =…
Anna
  • 53
  • 1
  • 6
3
votes
2 answers

Listening to events in Web3j

I'm tinkering with web3j and most of the things that I want to do succeed, however I seem to not be able to listen to events. I've extended the ballot.sol contract you get with remix by adding an event VoteEnded, which is fired when a call is made…
MPL
  • 384
  • 1
  • 4
  • 20
2
votes
0 answers

Web3j - Why does my contract's method have a BigInteger param generated by the Java Wrapper? What is it for?

I'm using the Web3j cli to generate a Java Wrapper for my ethereum smart contract. function withdraw() external payable { address _caller = msg.sender; uint256 _userBalance = recipientBalances[_caller]; if (isExpired() &&…
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
2
votes
1 answer

Is there a way to get totalSupply of an ERC20 token using web3j java?

I'm developing an android app using android studio. I implemented web3j and successfully connected to ethereum using infura. I'm not sure how I can get the total supply of a specific coin. Tried using the load method to load a specific tokens…
Sparky
  • 21
  • 2
2
votes
1 answer

Sending ERC20 tokens using web3j always pending

I am trying to send erc20 tokens using web3j , it always throw the protocol exception and transaction is always pending. Is there anything wrong i did in my code? Code: Web3j web3 = Web3j.build(new…
1
2
3
10 11