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
1
vote
0 answers

Could not construct a recoverable key. Are your credentials valid?

I have the following code: 212 (def CGP 213 (reify ContractGasProvider 214 (getGasPrice [_ contract-func] (Numeric/decodeQuantity "100")) 215 (getGasLimit [_ contract-func] (Numeric/decodeQuantity "100")))) 216 217 218 (.send 219 …
zendevil.eth
  • 974
  • 2
  • 9
  • 28
1
vote
1 answer

How can i store a contract address

I have create a Voting Dapp using web3j and ganache, but their is a small problem. I decide to deploy a voting contract every time a new election begin, and there will be a administrator who control the deploy of the contract and the begin and end…
Jensen0726
  • 13
  • 3
1
vote
0 answers

How to encode tuple as output parameter to function using web3j in java

struct AccountReaderResult { int256 cash; int256 position; int256 availableMargin; int256 margin; int256 settleableMargin; bool isInitialMarginSafe; bool isMaintenanceMarginSafe; bool isMarginSafe; int256…
liyu
  • 11
  • 1
1
vote
1 answer

BroadCasting an offline transaction

I want to broadcast a raw ETH transaction and pay the fees for it in web3j, i used the following code to get the hex value of the transaction EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount(credentials.getAddress(),…
EAOE
  • 65
  • 6
1
vote
2 answers

Signatures different in web3j and web3js?

I am using web3J version "org.web3j:core:4.6.0" and get following problem. When I sign the same raw message (a string) I get different signatures using web3js and web3j. The signature from web3js is valid (and web3j is not), I test it using solidity…
Guarav
  • 73
  • 1
  • 8
1
vote
1 answer

How to pass a variable from a smart contract to java project using web3j

Here is a very simple smart contract: pragma solidity ^0.7.0; contract Name { string name = "Tom"; function getName() public view returns (string memory) { return name; } } Then I have converted this into a…
Haowan Cui
  • 11
  • 1
1
vote
1 answer

Web3j read all the emitted events of a sinle transaction

I have a smart contract method "transferFrom" which, at the end, emits an event "EventTransf". From a java program using web3j I call such a method and I obtain the receipt. TransactionReceipt tr=contract.transferFrom(from,to, tk).send(); Now, I…
Discipulos
  • 423
  • 8
  • 23
1
vote
3 answers

Web3j gets stack underflow error with Ganache

I'm experiencing the error "Error processing transaction request: VM Exception while processing transaction: stack underflow" basically with any contract. I'm using Ganache v2.1.2 and Web3j 4.5.15. Same thing with Ganache CLI v6.9.1 (ganache-core:…
Discipulos
  • 423
  • 8
  • 23
1
vote
1 answer

To interact with smart contract without gasprice

I am using web3j java library to deploy and to interact with the smart contract. When I tried to send a transaction that invoke a function in smart contract by setting the gas price to 0 and gas limit to DefaultGasProvider.GAS_LIMIT. I am getting…
Minisha
  • 2,117
  • 2
  • 25
  • 56
1
vote
2 answers

how to fix 'no such algorithm ecdsa for provider bc' while creating new wallet file using web3j

I am doing this on the latest version of the android studio and minimum SDK version is 15 dependencies: > implementation fileTree(dir: 'libs', include: ['*.jar']) > implementation 'com.android.support:appcompat-v7:28.0.0' > implementation…
1
vote
0 answers

Can't call method in static class

I've written a bare-bones class to call the Web3j ethereum library. I've added the maven dependencies and I think that is ok. I've written one line of code to check that it is working but get a strange error. When I call the static factory method…
tommccann
  • 133
  • 1
  • 10
1
vote
1 answer

can we use web3j and the experimental ABIEncoderV2?

I developed a Dapp using nodejs with web3js API, and I used the experimental ABIEncoderV2 features. Now I want to migrate to spring instead of nodejs, so I will use the web3j module, but I am not sure that it supports the "experimental…
maroodb
  • 1,026
  • 2
  • 16
  • 28
1
vote
1 answer

Working web3j.replayTransactionsObservable example

I want to retrieve the transaction history between 2 blocks and I came upon this replay filter To replay the individual transactions contained within a range of blocks: Subscription subscription = web3j.replayTransactionsObservable(…
mzaidi
  • 109
  • 1
  • 10
1
vote
0 answers

How to decode public key from a transaction signed by private key using web3j?

I want to verify if a transaction is signed by the specific user. So i want to decode the public key from transaction and compare it. As seen in the code below, i encoded and signed a transaction using my credential. But it seems that the public key…
Gang Zhao
  • 126
  • 8
1
vote
2 answers

Web3J - Creation of Light Wallet takes too long

I am creating the wallet in my Android app, using the library Web3j: https://web3j.io/ See the code: String seed = UUID.randomUUID().toString(); ECKeyPair exKey = Keys.createEcKeyPair(); WalletFile wallet = Wallet.createLight(seed,exKey); It is…
Alex Bean
  • 493
  • 7
  • 19