Hot answers tagged

3

This is my implementation of getting the latest block number. I set up the project using https://docs.web3j.io/getting_started/#gradle import org.web3j.protocol.Web3j; import org.web3j.protocol.core.methods.response.EthBlockNumber; import org.web3j.protocol.http.HttpService; import java.util.concurrent.ExecutionException; public class App { public ...


2

This line: contract.getCounter().send(); should be contract.getCounter().call({from:yourAccount}); Reason When you request state from Ethereum, it doesn't cost gas because you're just reading a node. If the node is on your computer, you're just reading your hard drive. On the other hand, when you change state, it requires miners to pick up the change and ...


1

In Web3 v1.2.6: To get the pending transactions, use the below API: const pendingTransactions = await web3.eth.getPendingTransactions() To check the whether your transactionHash is in the pendingTransactions array: Let transactionHash be the one you want to check whether it is pending or mined. const isMyTxPending = pendingTransactions.filter((tx) => ...


1

not sure what you ended up doing here, but when I ran into a similar issue, I decided to put web3 into my selectors. That was important because the Provider URL could change over time, so I wanted to make sure that Web3 always had the most up-to-date value from the Redux store. The big perk of doing this as a selector is that you don't need to worry about ...


1

Web3 has been updated since @Vanja Dev's answer var tokenInst = new web3.eth.Contract(tokenABI,tokenAddress); tokenInst.methods.balanceOf('0x260c25f991171850f48889eb9d8aF11998D20c30').call().then(function (bal) { console.log(bal); })


1

Transaction hash is created before the transaction is broadcasted. Transaction hash, as the name says, is just all hashed data for a signed transaction. Because Ethereum transactions have nonce parameter you can safely re-broadcast any signed transaction as many times as you want. Miners will mine transactions only in the order of one step nonce increases, ...


1

The code uses indexed parameters. In case of a string parameter it is not stored in the event log as is, but its keccak256 value instead. See solidity documentation about that https://solidity.readthedocs.io/en/v0.6.4/abi-spec.html#encoding-of-indexed-event-parameters. It is not possible to retrieve the value of an indexed string from the event log. As an ...


1

Try this import java.math.BigInteger; import org.springframework.web.bind.annotation.*; import org.web3j.protocol.Web3j; import org.web3j.protocol.core.DefaultBlockParameterName; import org.web3j.protocol.core.methods.response.Transaction; import org.web3j.protocol.core.methods.response.Web3ClientVersion; import org.web3j.protocol.http.HttpService; import ...


1

you need a new class that implements the StaticGasProvider (the value of gaslimit is just an example, you don't usually need that much for a transfer transaction) import org.web3j.tx.Contract; import org.web3j.tx.gas.StaticGasProvider; import java.math.BigInteger; public class GasProvider extends StaticGasProvider { public static final BigInteger ...


1

Transaction was failing because of fixed gasLimit : 37000. Gas depends on what the function is doing. For example, it is more expensive to set a zero-value storage value to non-zero, than it is to set a non-zero storage value to another non-zero storage value. In my case it was because of SSTORE opcode as it takes 20000 when storage value is set to non-...


1

If you are trying to generate a Java smart contract wrapper you should use the web3j cli. You can still use truffles contract schema. $ web3j truffle generate [--javaTypes|--solidityTypes] /path/to/<truffle-smart-contract-output>.json -o /path/to/src/main/java -p com.your.organisation.name https://web3j.readthedocs.io/en/latest/smart_contracts.html


1

The problem was actually not with the Project.load method but with .send() when using Web3j on android you have to use sendAsync().get() to make it work. So the problem is solved.


1

I got the same question, did you get the answer, if you solved this question ,please tell me how to solve it, Thinks


Only top voted, non community-wiki answers of a minimum length are eligible