Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 23 17:02
    hongquan66 starred web3j/web3j
  • Nov 23 11:37
    claritize commented #1271
  • Nov 23 11:37
    claritize commented #1271
  • Nov 23 11:34
    claritize commented #1271
  • Nov 23 11:34
    claritize commented #1271
  • Nov 23 11:34
    claritize commented #1271
  • Nov 23 11:34
    claritize commented #1271
  • Nov 22 18:07
    chudinhbka starred web3j/web3j
  • Nov 22 11:37
    AlexandrouR synchronize #1294
  • Nov 22 11:37
    AlexandrouR synchronize #1294
  • Nov 20 23:57
  • Nov 19 19:09
    AlexandrouR synchronize #1294
  • Nov 19 19:09
    AlexandrouR synchronize #1294
  • Nov 19 14:02
    niiamon starred web3j/web3j
  • Nov 18 09:25
    AlexandrouR synchronize #1294
  • Nov 18 09:25
    AlexandrouR synchronize #1294
  • Nov 18 07:38
    liuhailin starred web3j/web3j
  • Nov 18 03:15
    wuhengzhi labeled #1295
  • Nov 18 03:15
    wuhengzhi opened #1295
  • Nov 18 03:15
    wuhengzhi opened #1295
Mario
@mmaryo
something like this ?
val block = web3j.ethGetBlockByNumber(DefaultBlockParameter.valueOf(123), true)
block.transactions ...
I have an error with solc command line with an import, someone know you to fix it ?
 %solc Ctr.sol --bin --abi --optimize --overwrite -o out/
Error: Source "https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol" not found: File outside of allowed directories.
 --> Ctr.sol:5:1:
the source
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.7.1;

import "https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol";

interface IWETH {
    function deposit() external payable;
    ....
IK
@thor-ragnarok
@mmaryo the --allow-paths flag might help here
hmm not sure how the import from github works tbh
Mario
@mmaryo
hello @thor-ragnarok unfortunatly not work
i'll ask solc github
Mario
@mmaryo
@thor-ragnarok
I looking for get more information about pending transactions (web3j.transactionFlowable())
can we know or sort pending transactions considering which witch transactions will have more chance to be executed ?
1 reply
Nandhitha2596
@Nandhitha2596
Error in deploying transaction contract.
Transaction 0x61fba34bfbd4b502d36bd51c4e5f2110aa29b0fd096aaec6bcb7d65c67de4149 has failed with status: 0x0. Gas used: 4300000. Revert reason: 'N/A' ,Getting the above error while deploying permission implementation contract in quorum 7 node examples. can anyone let me know if the error is because of gas limit?
DevMurugesan
@DevMurugesan
Hi,org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 600 seconds for transaction: 0xc5819b58290c282b4653ed549b7383afa1c03bb2a8a2d3e4ca9e3f411b6d6fb1
1 reply
i am facing this exception in web3j kindly some one help me resolve this
Nandhitha2596
@Nandhitha2596
Can anyone help us resolve the above issue "Transaction receipt was not generated after 600 seconds for transaction", this was given in the web3j "ContractGasProvider contractGasProvider = NdcUtil.getContractGasProvider(BigInteger.valueOf(0),
BigInteger.valueOf(3628255902L)); "where value of gas limit is referred from eth.getBlock("latest")
Nandhitha2596
@Nandhitha2596
upgraded to 2.7 version of quorum which solved the above issue.
Mario
@mmaryo
Hello
How to get raw transaction ? Raw field is null ?
Can I create the raw transaction with v, r and s fields ?
How to do ?
3 replies
Mario
@mmaryo

Hello
This is what I do

I get a pending tx from mainnet
And try to run this tx in my local private Geth node (with chainId = 731)

            val tx = getFirstPendingTx()

            val raw = SignedRawTransaction(
                web3j.ethGetTransactionCount(tx.to, DefaultBlockParameterName.PENDING).send().transactionCount,
                tx.gasPrice,
                tx.gas,
                tx.to,
                tx.value,
                tx.input,
                SignatureData(tx.v.toByte(), tx.r.toByteArray(), tx.s.toByteArray())
            )

            val signedMessage = raw.getEncodedTransaction(731L)

            val hexValue = Numeric.toHexString(signedMessage)

            val ethSendTransaction = web3jLocal.ethSendRawTransaction(hexValue).send()

            if (ethSendTransaction.hasError()) {
                println(ethSendTransaction.error.message)
            } else {
                println(ethSendTransaction.transactionHash)
            }

And the response is invalid sender

Do I re-create well the transaction ?
What is "invalid sender"
Mario
@mmaryo
I changed the chainId to 1 with Geth command line
And put 1 in code
Same error
Mario
@mmaryo

I try this
Not works :/

rlp: expected input list for types.txdata

    fun encode(tx: Transaction): ByteArray {
        val rlpTypes: MutableList<RlpType> = ArrayList()
        rlpTypes.add(RlpString.create(Bytes.trimLeadingZeroes(arrayOf(tx.v.toByte()).toByteArray())))
        rlpTypes.add(RlpString.create(Bytes.trimLeadingZeroes(tx.r.toByteArray())))
        rlpTypes.add(RlpString.create(Bytes.trimLeadingZeroes(tx.s.toByteArray())))
        val rlpList = RlpList(rlpTypes)
        val values: List<RlpType> = rlpList.values
        var result = ByteArray(0)
        for (entry in values) {
            result = concat(result, RlpEncoder.encode(entry))
        }
        return result
    }

...
            val signedMessage = encode(tx)
IK
@thor-ragnarok
@mmaryo the signature depends on the rest of the transaction data so you cannot put arbitrary r,s,v values in a transaction
kunalbarchha
@kunalbarchha
@thor-ragnarok pls check dm
longyujun
@githubityu
Caused by: org.web3j.protocol.exceptions.TransactionException: Transaction has failed with status: 0x0. Gas used: 7600000. (not-enough gas?)
image.png
why
Mario
@mmaryo
Hello @thor-ragnarok
the idea is to get a pending transaction and execute it on local node
I looking for Raw Transaction, but web3 api do not give me this, but I may re-create raw transaction with v, r and s fields ?
https://etherscan.io/getRawTx?tx=0x2d6a7b0f6adeff38423d4c62cd8b6ccb708ddad85da5d3d06756ad4d8a04a6a2
5 replies

Another question, can put option in web3j like web3js ?

const web3 = new Web3(provider, null, { transactionConfirmationBlocks: 1 });

3 replies
DevMurugesan
@DevMurugesan
Hi, I am trying to add permission organization in quorum and i am getting following error. Transaction 0xa9b5ee044ddeacfa7f35f84130842b7ccc9b6f708a92695d40d590d921aa7793 has failed with status: 0x0. Gas used: 26125. Revert reason: 'invalid caller'.
1 reply
Some one please help me to resolve this
@Override
public String addOrg(String orgContractAddress, String orgId) throws Exception {
OrgManager orgManager = loadOrgManager(orgContractAddress);
TransactionReceipt receipt = orgManager.addOrg(orgId).send();
return receipt.getTransactionHash();
}
Jahid Shohel
@jahidshohel_gitlab
Hey guys, just indecisive if I should use web3js or web3j. I am a Java guy, but also know NodeJs. I will prefer to code on Java over Nodejs. All these being said, just a question to you experts, "can I do everything using web3j, that I can do with web3js"?
2 replies
JChoy
@JhChoy
Hello there, I need to query logs by blockHash(According to eth_getLogs part of ethereum json-rpc wiki, blockHash filter was added by EIP-234.) but it's not in EthFilter.
Can I work with this issue?
3 replies
André Reiter
@andre77
hi everybody, i try to use the uniswap smart contract over web3j
https://uniswap.org/docs/v2/smart-contracts/router02/
so far the *.sol files are compiled and the java wrapper classes are generated
i run a local geth node, everything is fine and good to go
what i do not understand, is how to set the amount of ETH, i want to send to the smart contract
see for example this method https://uniswap.org/docs/v2/smart-contracts/router02/#swapexactethfortokens
i need to set the msg.value, which is the amount of ETH to send
but the generated java method (swapExactETHForTokens) does not have this parameter
André Reiter
@andre77
so far i could investigate. the generated code extends the org.web3j.tx.Contract class and uses this method
https://github.com/web3j/web3j/blob/master/core/src/main/java/org/web3j/tx/Contract.java#L407
in this case the parameter "weiValue" is passed with ZERO
i would need to somehow call this method https://github.com/web3j/web3j/blob/master/core/src/main/java/org/web3j/tx/Contract.java#L412, where i can pass the desired weiValue
any idea ?
3 replies
kunalbarchha
@kunalbarchha
@thor-ragnarok just out curiosity, what happens to existing integration after eth 2.0 staking roll out ? Do we need to remove web3j and integrate something new. Or things will work as it is ?
IK
@thor-ragnarok
@kunalbarchha eth 2.0 does not affect anything at this time - don't expect anything to change until execution environments are rolled out on eth 2.0 chain which won't happen any time soon
kunalbarchha
@kunalbarchha
@thor-ragnarok Thanks.
Christopher McGregor
@chrismcgregor
abi
tendemo1
@tendemo1
Hi trying to do a sendTransaction via Infura to a test smart contract . Im getting an "Uncaught TypeError: e.data.startsWith is not a function". How will I prorpely format a manual datafield.
longyujun
@githubityu
how get web3j-4.8.1.zip
Contains bin
IK
@thor-ragnarok
web3j library is not executable so there are no binaries to publish
if you are looking for command line interface checkout https://github.com/epirus-io/epirus-cli
kunalbarchha
@kunalbarchha

@thor-ragnarok I am done with ETH integration for production. Now next task is to integrate ERC20 Tokens. Below is the basic code snippet (in progress)

Web3j web3j=Web3j.build(new HttpService("wss://mainnet.infura.io/ws/v3/<KEY>"));

@PostConstruct
public void subcribeToEvents(){

    String contractAddress="0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c";
    EthFilter ethFilter=new EthFilter(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST, contractAddress);

    log.info("starting subscription");
    web3j.ethLogFlowable(ethFilter).subscribe(event -> {
        log.info("Smart contract Tx Hash >>>> " +event.getTransactionHash());
        log.info("Wallet address >>>>> " + event.getAddress());
    }, error -> error.getMessage());
}

Question:

Above code will subscribe to just one contract address, but let's say if we are intergrating 50 ERC20 tokens, do we need to create filter for each of them and subscribe to it ? How Binance or other big exchanges handle this scenario ?

IK
@thor-ragnarok
yes - filter per token
kunalbarchha
@kunalbarchha
Oh !
I see that EthFilter takes contractAddress as Arrays.asList, can we provide multiple contract address there in Array ?
public EthFilter(DefaultBlockParameter fromBlock, DefaultBlockParameter toBlock, List<String> address) {
    this.fromBlock = fromBlock;
    this.toBlock = toBlock;
    this.address = address;
EthFilter.Class
IK
@thor-ragnarok
not idea to be honest
kunalbarchha
@kunalbarchha
No worries. I'll make and break things and update you for future reference
Thorsten Hirsch
@thorstenhirsch

hey guys, I've written a client that sends signed messages to a server, but I'm doing something wrong, because the server cannot recover the correct public key of my wallet. the server recovers a different key for each message I send, but my wallet stays the same. since other clients work with the server the issue has to be my code. here's how I sign the message:

        String toSign = "foo" + nonce;
        String toSignAsHex = Numeric.toHexString(toSign.getBytes());
        Sign.SignatureData signedMessage = Sign.signMessage(toSignAsHex.getBytes(), InstanceHolder.instance.credentials.getEcKeyPair(), true);

        String hexSigR = Numeric.toHexString(signedMessage.getR());
        String hexSigS = Numeric.toHexString(signedMessage.getS());
        String hexSigV = Numeric.toHexString(signedMessage.getV());

        String messageForServer = Hash.sha3(toSignAsHex) + "-" + nonce + "-" + hexSigR + "-" + hexSigS + "-" + hexSigV;

And the server receives this messageForServer, splits it into the different parts, and finally calls:

String pubkey = Sign.signedMessageToKey(sha3part-after-some-preprocessing,
                        new Sign.SignatureData(
                                Numeric.hexStringToByteArray(v)[0],
                                Numeric.hexStringToByteArray(r),
                                Numeric.hexStringToByteArray(s)))

And this is where the server calculates a different pubkey for each message I send.

Thorsten Hirsch
@thorstenhirsch
found the answer: sha3part-after-some-preprocessing (on the server) included some static prefix. my client had no such prefix.