B4J Question [ Web3X ] Have a way to send Ether between wallets on mainNet ?

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
Hello everyone !
Is there any example of how to send ether between 2 accounts on the backend using MainNet?
 

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
dont works ;-; what am I doing wrong ?

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Web3Ropsten As Web3X
    Private Utils As W3Utils
    Private InfuraRopstenLink As String = "https://ropsten.infura.io/v3/MY_INFURA_ID"
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    B4XPages.GetManager.LogEvents = True
    Root = Root1
    Root.LoadLayout("MainPage")
    Utils.Initialize
    Web3Ropsten = Utils.BuildWeb3Infura(InfuraRopstenLink)

    
    Dim Path As String = "D:\wallet\UTC--2022-04-18T20-06-35.daksdkas8das7da7sdha8sj2d931kj8d7agehdajd8.json"
    Wait For (Utils.LoadWallet(Path, "MY_PASSWORD")) Complete (Result As W3AsyncResult)
    If Result.Success Then
        Dim Credentials As W3Credentials = Result.Value
        Log(Credentials.Address) ' on this line show my wallet address, works fine ...
    End If
    ' send funds dont work ;-;
    Dim ToAddress As String = "0xaas8dha89dhnas8da76sgdffda6ygs69999eg"
    Dim Amount As BigInteger = Utils.BigIntFromUnit("0.01", "ether")
    Dim MaxPriorityFeePerGas As BigInteger = Utils.BigIntFromUnit("3", "gwei")
    Dim MaxFeePerGas As BigInteger = Utils.BigIntFromUnit("200", "gwei")
    Dim ChainId As Int = Utils.CHAINID_ROPSTEN
    Wait For (Web3Ropsten.SendFunds(ChainId, Credentials, ToAddress, Amount, MaxPriorityFeePerGas, MaxFeePerGas)) Complete (Result As W3AsyncResult)
    If Result.Success Then
        Dim hash As W3TransactionHash = Result.Value
        Log("Transaction sent successfully: ")
        Log(hash.Hash)
        Dim Timeout As Int = 300 'seconds
        Wait For (Web3Ropsten.EthGetTransactionReceipt(hash, Timeout)) Complete (Result As W3AsyncResult)
        If Result.Success Then
            Dim tr As W3TransactionReceipt = Result.Value
            If tr.Pending Then
                Log("Transaction still pending")
            Else
                Log("Transaction completed, ok? " & tr.StatusOk)
                Log(tr)
            End If
        Else
            Log("Error getting receipt: " & Result.Error)
        End If
    End If

End Sub
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
when i run in Release, show it on log :
Bash:
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
0xdhfyr293jdh8aus929jdasak01923jdajjsldas 'my wallet
*** mainpage: B4XPage_Resize [mainpage]
*** mainpage: B4XPage_Resize [mainpage]
*** mainpage: B4XPage_Resize [mainpage]

after several minutes with the application open, the same log remains as above... looks like it's not calling send funds or something...
 
Last edited:
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
Is it reached?
Is not reached :(

Code : ( bp2 and bp3 logs are not reached )

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Web3Ropsten As Web3X
    Private Utils As W3Utils
    Private InfuraRopstenLink As String = "https://ropsten.infura.io/v3/MY_INFURA_ID"
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    B4XPages.GetManager.LogEvents = True
    Root = Root1
    Root.LoadLayout("MainPage")
    Utils.Initialize
    Web3Ropsten = Utils.BuildWeb3Infura(InfuraRopstenLink)
    Log("Web3Ropsten = "&Web3Ropsten)
   
    Dim Path As String = "D:\wallet\UTC--2022-04-18T20-06-35.daksdkas8das7da7sdha8sj2d931kj8d7agehdajd8.json"
    Wait For (Utils.LoadWallet(Path, "MY_PASSWORD")) Complete (Result As W3AsyncResult)
    If Result.Success Then
        Dim Credentials As W3Credentials = Result.Value
        Log(Credentials.Address) ' on this line show my wallet address, works fine ...
    End If
    ' send funds dont work ;-;
    Dim ToAddress As String = "0xaas8dha89dhnas8da76sgdffda6ygs69999eg"
    Dim Amount As BigInteger = Utils.BigIntFromUnit("0.01", "ether")
    Dim MaxPriorityFeePerGas As BigInteger = Utils.BigIntFromUnit("3", "gwei")
    Dim MaxFeePerGas As BigInteger = Utils.BigIntFromUnit("200", "gwei")
    Dim ChainId As Int = Utils.CHAINID_ROPSTEN
    Log("bp1 ") ' <<<<<<< got here, below does not run.
    Wait For (Web3Ropsten.EthChainId) Complete (Resultc As W3AsyncResult)
    Log("bp2 = "&Resultc)
    Wait For (Web3Ropsten.SendFunds(ChainId, Credentials, ToAddress, Amount, MaxPriorityFeePerGas, MaxFeePerGas)) Complete (Result As W3AsyncResult)
    Log("bp3 = "&Result)
    If Result.Success Then
        Dim hash As W3TransactionHash = Result.Value
        Log("Transaction sent successfully: ")
        Log(hash.Hash)
        Dim Timeout As Int = 300 'seconds
        Wait For (Web3Ropsten.EthGetTransactionReceipt(hash, Timeout)) Complete (Result As W3AsyncResult)
        If Result.Success Then
            Dim tr As W3TransactionReceipt = Result.Value
            If tr.Pending Then
                Log("Transaction still pending")
            Else
                Log("Transaction completed, ok? " & tr.StatusOk)
                Log(tr)
            End If
        Else
            Log("Error getting receipt: " & Result.Error)
        End If
    End If

End Sub


Log :

Bash:
Web3Ropsten = [w3=(JsonRpc2_0Web3j) org.web3j.protocol.core.JsonRpc2_0Web3j@94949d3, mutils=[jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) [jme=(w3utils) , block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], block_earliest=EARLIEST, block_latest=LATEST
, block_pending=PENDING, units=(MyMap) {wei=wei, kwei=kwei, mwei=mwei, gwei=gwei, szabo=szabo, finney=finney, ether=ether}, signclass=(Class) class org.web3j.crypto.Sign
, numericclass=(Class) class org.web3j.utils.Numeric, hashclass=(Class) class org.web3j.crypto.Hash, keysclass=(Class) class org.web3j.crypto.Keys
, chainid_mainnet=1, chainid_ropsten=3, chainid_rinkeby=4
, chainid_goerli=5, chainid_kotti=6, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
], jme=(web3x)
, ensresolver=(EnsResolver) org.web3j.ens.EnsResolver@66a5bb64, transactionmanagers=(MyMap) {}, bc=anywheresoftware.b4a.agraham.byteconverter.ByteConverter@256161b2
, sendfundslock=false, pollingduration=10000, main=null
, b4xpages=null, b4xcollections=null, httputils2service=null
]
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
0x29KDSAK9DK09DKA0991K9D90190K90DA ' my wallet address
bp1
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Start with this:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    B4XPages.GetManager.LogEvents = True
    Root = Root1
    Root.LoadLayout("MainPage")
    Utils.Initialize
    Web3Ropsten = Utils.BuildWeb3Infura(InfuraRopstenLink)

    Dim credentials As W3Credentials = Utils.CreateCredentialsFromPrivateKey(Utils.BigIntFromHex(pk).ToByteArray)
    Wait For (Web3Ropsten.EthChainId) Complete (Result As W3AsyncResult)
    Log(Result.Value)
    Wait For (Web3Ropsten.EthGetBalance(credentials.Address, Utils.BLOCK_LATEST)) Complete (Result As W3AsyncResult)
    Log(Result)
End Sub

pk is a global string with the account private key. You can use a wallet instead.

If it doesn't work for you then something is misconfigured. Maybe your infura link or the set of libraries.
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
I tested this example code, but even so without a link to the wallet, there is no return... it's as if the http request was not made...

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Web3Ropsten As Web3X
    Private Utils As W3Utils
    Private InfuraRopstenLink As String = "https://ropsten.infura.io/v3/your_project_id_here"
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Utils.Initialize
    Web3Ropsten = Utils.BuildWeb3Infura(InfuraRopstenLink)
    Wait For (Web3Ropsten.EthBlockNumber) Complete (Result As W3AsyncResult)
    If Result.Success Then
        Log("Current block: " & Result.Value)
    End If
End Sub

I'm studying the web3x .bas to try to understand what's going on behind .
1650649515741.png

on line 75 of Web3X.bas when calling the example above, it gets stuck on RunAsync_Complete
as the screenshot above shows.

what is preventing the request?
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
My mistake, I forgot that to update the okhttp library, I would need to update the b4j root directory... ?
Thanks a lot for the help ?
 
Upvote 0
Top