0

Help me out how do i resolve the issue of ethereum smartcontract for getting my wallet when i enter my private key in the text area

Use WalletUtils functionality
The WalletUtils class can be used to load your credentials from various 
formats:

WalletUtils.loadCredentials(String password,String source)
WalletUtils.loadBip39Credentials(String password,String mnemonic)
WalletUtils.loadBip39Credentials(String password,String mnemonic)
WalletUtils.loadJsonCredentials(String password,String content)

http://docs.web3j.io/latest/transactions/credentials/#use-walletutils-functionality

These are the methods provided by the web3j library can anyone help me out to import my wallet from 
ethereum using private key??

2 Answers2

0

It's not a good idea to enter your private key in a smartcontract. Everything saaved on the blockchain has public visibilty. So if you enter your private key in a smartcontract it will be visible by anyone. It's better to send ether to the contract from your wallet and than let the smartcontract manages them following your rules.

Ad Fortia
  • 333
  • 1
  • 3
  • 12
  • but trustwallet in android is able to do that when i enter my private key it restore my wallet in the mobile ijust need to implement tat in my app so that i can recover my wallet in my app using private key – BIPIN YADAV Mar 23 '21 at 16:42
  • Trustwallet is a crypto wallet not a smartcontract. If you want to do the same your app must be a wallet too. In which language is your app written? – Ad Fortia Mar 23 '21 at 17:15
  • android java and am using web3j – BIPIN YADAV Mar 24 '21 at 03:41
0

Using Credentials.create:

String privateKey = "0x40f315666f065b1113eaa538357ed9150db08e329fff15e417977bdc13099403";
Credentials credentials = Credentials.create(privateKey);
Martin Monperrus
  • 1,845
  • 2
  • 19
  • 28