B4J Question [Solved] [Web3X] how extract privatekey ?

behnam_tr

Active Member
Licensed User
Longtime User
hi

I want to extract private key form wallet that generated with web3x library and import to metamak
But i got error in metamask while importing
Where is the problem in my code?

B4X:
'Connecting to Binance Smart Chain Network - Testnet

web3 = Utils.BuildWeb3Http("https://data-seed-prebsc-1-s3.binance.org:8545/")
    Wait For (web3.EthBlockNumber) Complete (Result As W3AsyncResult)
    If Result.Success Then
        MyLog("Current block: " & Result.Value)
    End If

    'Load a wallet
    Dim Path As String =File.Combine(File.DirApp,"UTC--2022-07-27T08-54-03.3000000Z--237656063ceca525134d043565157748d5e5b376.json")
    MyLog(Path)
    Wait For (Utils.LoadWallet(Path, "secret password")) Complete (Result As W3AsyncResult)
    If Result.Success Then
        Dim Credentials As W3Credentials = Result.Value
      
        Log("Wallet Address : " & Credentials.Address)
        Log("Wallet PublicKey : " & Credentials.PublicKey.ToString)
        Log("Wallet PrivateKey : " & Utils.BigIntFromBytes(Credentials.PrivateKey).ToString)
    End If
 

behnam_tr

Active Member
Licensed User
Longtime User
Solved :

B4X:
 Utils.BigIntToHex(Utils.BigIntFromBytes(Credentials.PrivateKey))
 
Last edited:
Upvote 1
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…