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
2
votes
1 answer

Web3j - How to read the contract without credentials?

I'm using Web3j to interact with my deployed smart contract. I've deployed my contract onto the testnet and can interact with it, however using the generated wrapper code, it requires my wallet. Web3j web3 = Web3j.build(new…
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
2
votes
2 answers

Listening to events emmited from smart contracts using web3j library

How it is possible to listen to events emitted from smart contract using web3j library based on java?
shaikh47
  • 21
  • 1
2
votes
1 answer

web3j - TypeReference for event with string parameter

Let's say that I have the following event in my Solidity smart contract: event Buy(address buyer, string itemName); I am trying to construct the corresponding event in web3j Java library. This is what I have done: public static final Event BUY = new…
Sam Carlson
  • 1,891
  • 1
  • 17
  • 44
2
votes
2 answers

How to connect BSC wesocket provider with Web3J or Web3js

I`ve tried to connect to the websocket api over getblock.io but it always fails. Here below is JS code. But HttpProvider works fine on "https://bsc-mainnet.web3api.com/v1/API_KEY". web3ws = new Web3(new…
mathew sada
  • 77
  • 1
  • 6
2
votes
1 answer

Web3j: Get value of transaction token transfered using Transaction Hash

With Web3j (not Web3js), how do I get the value of token transferred using transaction hash?
Azrulm
  • 23
  • 6
2
votes
2 answers

Getting decoded output from a smart contract transaction

I am executing functions of a smart contract through web3j using the following code : Credentials creds = getCredentialsFromPrivateKey("private-key"); RawTransactionManager manager = new RawTransactionManager(web3j, creds); …
EAOE
  • 65
  • 6
2
votes
1 answer

Web3j call a variable in a smart contract

I am trying to get the value of a variable in a Smart Contract using solidity, geth and web3j. The contract HelloWorld is very simple: pragma solidity ^0.6.10; contract HelloWorld { uint256 public counter = 5; function add() public { …
2
votes
1 answer

Subscribe for ERC20 transfer events

I have been trying to observe the transactions taking place on mainnet for a specific contract, specifically Tether (USDT). I am able to download the contract and compile the solidity code with Web3 (Java). However I am unable to subscribe for…
2
votes
3 answers

BigInteger throws numberFormatException

Edit: Resolved the issue with below code: String tokenId="0x1800000000001289000000000000000000000000000000000000000000000000"; BigInteger token1; if (tokenId.startsWith("0x")){ token1=new…
2
votes
1 answer

Web3j-Cli does not generate correct java methods for view solc methods

I would really appreciate some help with this... I have generated java smart contract wrappers for two smart contracts (SheepHelper and SheepFactory). When I try to use these methods in android I can only return TransactionReciept objects (Even for…
2
votes
1 answer

how to use Credential wallet path with metamask account on infura in Web3j

Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/ Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile"); How to connect rinkeby network using Web3j. I try to change…
2
votes
1 answer

Ganache hash doesn't match Web3j response with error `TxHashMismatchException`

When trying to run any transaction using Web3j on Ganache it fails with the exception: TxHashMismatchException. It seems that something has changed on Ganache that is breaking the interoperability.
Adrian Lopez
  • 1,776
  • 1
  • 17
  • 35
2
votes
1 answer

Is it possible to generate mnemonic code from privatekey from web3j and bitcoin sdk

I am an Android developer and I try to import a wallet from its private key, everything goes well but there will no mnemonic code for this wallet, and I know private key comes from mnemonic code too. I only just wonder isn't possible to generate…
ijustyce
  • 328
  • 1
  • 3
  • 13
2
votes
1 answer

Is it possible to sign/encrypt a message (string) in web3j and then decrypt the message with the public key (address)

Trying to figure out the best approach to this. Working on a web3j/ethereum app, I need a way to verify an address is generated and in use by the app user by a server. My approach idea: Use the private ethereum key the sign/encrypt a message Send…
2
votes
1 answer

web3j Error processing transaction request: insufficient funds for gas * price + value

Following this tutorial https://github.com/web3j/web3j Started the geth client as a private network. Here is the contract code pragma solidity ^0.4.10; contract Counter { uint256 counter =0; function increase() public { …
swaheed
  • 3,671
  • 10
  • 42
  • 103
1 2
3
10 11