Hot answers tagged

3

Opcode 0x1c is SHR or right shift, which was introduced in the recent update (more here). It was not available prior to February, 2019. It is likely that your Java tool (web3j?) is out dated and does not recognize this opcode. You may be able to upgrade to a newer version which has Constantinople/St. Petersburg support.


3

There is different way to send transactions to a smart contract through node: (1) A client signs a transaction with his account (private key) and send it to the node. Then the node only broadcasts it to the network. Transaction fees are paid by the client. (2) A client sends a clear transaction (no signature) and ask the node to sign and broadcast the ...


3

Under the hood, the Web3J SmartContract Java Wrapper calculates the nonce by getting the number of transactions getTransactionCount for the account (credential). EthGetTransactionCount ethGetTransactionCount = web3.ethGetTransactionCount(credentials.getAddress(), DefaultBlockParameterName.PENDING).send(); BigInteger nonce = ethGetTransactionCount....


2

In the latest version of the web3j-android library 'org.web3j:core:4.1.0-android', org.web3j.protocol.Web3jFactory is indeed removed. However, the documentation still says we should use it. I believe they haven't updated the documentation yet. Instead, we should actually use the regular one: Web3j web3j = Web3j.build(new HttpService(url)); *Note: This ...


2

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

A transaction receipt is only available after the transaction has been mined. For a pending transaction, you won't get any transaction receipt, so you also won't see any status.


2

if you face this issue, it can be solved by two things (that I am aware of): make sure to increase the gasPrice by 10-20%. This not given on the ETh paper but this how the miners generally work. The other way round is to increase the nonce and then redo the transaction.


2

As is the case with many blockchain business ideas you should really consider why you want to use blockchain for your use and why exactly you need a blockchain. All too often the end result of this is "I actually don't need a blockchain but it still sounds cool". Furthermore with a private blockchain it might be questionable how immutable your data is. ...


2

From its version 4.0, web3j started using RxJava 2.0 FLowable instead of RxJava 2.0 Obsersable to handle events processing, notably because Flowable are much more efficient during high load using a backpressure mechanism. The new function to catch events is now the following: EthFilter filter = new EthFilter( DefaultBlockParameterName.EARLIEST, ...


2

Alright, let's start from scratch. Let's say you have a very simple contract which increments and decrements a counter deployed to the address CONTRACT_X pragma solidity ^0.4.20; contract Counter { int counter; // Global state event CounterIncremented(address indexed _by, int _newValue); event CounterDecremented(address indexed _by, int ...


2

I think something like this should work // Create the Transaction RawTransaction rawTransaction = RawTransaction.createEtherTransaction(<nonce>, <gasPrice>, <gasLimit>, <to>, <value>); // Sign the Transaction byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, <your-Credentials>); String ...


2

eth_newFilter is used to receive and filter Ethereum logs. Logs are produced when a transaction is included in a block, hits a smart-contract and generates a log, which is not what you want. You may want to look at web3js pending transaction subscriptions: https://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html#subscribe-pendingtransactions const ...


2

Let's take for example the following simple storage contract: pragma solidity ^0.5.6; contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; } function get() public view returns (uint) { return storedData; } } You can send a transaction to a (already deployed) smart contract with the ...


1

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


1

use the load(...) method from SampleContract Wrapper and then call getSample() I can't test it now but it should look something like this // your code for deploy and wait until it deployed SampleContract myContract = SampleContract.load(<your-contract-address>, web3j, credentails, ......etc); BigInteger sNumber = myContract.getSample().send(); //...


1

That opcode is a recent addition to geth in the Constantinople release. You need to add the following to your genesis to enable Constantinople: "constantinopleBlock":0,


1

You probably need to dig around SignedRawTransaction and TransactionEncoder classes.


1

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 ...


1

The function can be made view and then you can use call from web3. This won't make a transaction but will just execute the function on the node you are connected to. The result will be the values that you expect. Hope this helps


1

The problem is that the returned value is a transaction-receipt. How can I recover both values? Add view to the function declaration, and the returned value will be a tuple (bool, uint32). Otherwise (if there's something that you're not telling us about the function, for which it cannot be declared view), you'll need to emit an event with the return values,...


1

I have the exact same problem and I managed to make it work just one time using the following call. Now I cannot obtain the value again. You could also try, or read more about this String owner = managedWalletLookup.getOwner(contractAddress).sendAsync().get();


1

The nonce you are giving in the transaction has already been consumed for this address on a blockchain. Each Ethereum address, has a nonce starting from zero and increased by one for each new transaction. When you give the nonce when building the transaction it does not match one for the address in Ethereum blockchain itself. The solution is to sync the ...


1

I think there is a little bit of confusions. eth.accounts returns the list of accounts managed and owned by your node. It means the lists of private keys stored on your node keystore. With Ganache, it's a set of randomly generated accounts With Geth, it's in $HOME/.ethereum/keystore With Parity, it's in $HOME/.local/share/io.parity.ethereum/keys/ When ...


1

Most probably you have a pending transaction in the transaction pool. You can check this via eth.pendingTransactions. If you're using the same nonce like used in the pending transaction, the node will try to replace it. But this will only work if the gasPrice is larger than the old gasPrice.


1

I tested the code below and it is working now for me. The arguments can be extracted from getParameters as follow: List<Type> args = FunctionReturnDecoder.decode( log.getData(), my_event.getParameters()); System.out.println("Seller : "+args(0).getValue()); System.out.println("Price : "+args(1).getValue()); And this is the ...


1

I guess you are trying to decode erc20 transfer method. You must use the object org.web3j.abi.datatypes.Address rather than String.class. Example: final Address address = (Address) refMethod.invoke( null, to, 0, Address.class); System.out.println(address.toString()); and address.toString() is the real recipient of the ERC20 transaction.


1

In solidity 0.4.22 the require and revert reason were added. As can be seen here, they are abi-encoded as if it were a call to a function "Error(string)". You'll need to make an eth_call to your contract. This blog post gives an example: an eth_call to a function function myFunction(uint256 input) public view returns (uint256) { require(input >= 5, ...


1

I did this: public class MainActivity extends AppCompatActivity { private WalletFile wallet; private String password = "PASSWORD"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupBouncyCastle(); try { ...


1

If you use kotlin version you may code like this: private var web3: Web3j? = Web3j.build(HttpService("https://ropsten.infura.io/v3/youtoken")) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val web3ClientVersion = web3!!.web3ClientVersion().sendAsync(...


1

Smart contracts have two main types of functions: - Transactions: transaction on the Blockchain can change the state of the Blockchain by modifying a smart contract storage for instance. By design, a transaction is asynchronous because, it needs to be broadcasted on the network, picked up by a miner before being added to a block. This process can take a ...


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