1

I have a private key and address . Is it possible to make transaction with these parameter using web3j.

1

If you want to send custom tokens as the contract owner, check out my answer here: Send Custom ERC20 Tokens from one Address to another

If you want to send tokens on behalf of another user, the idea is similiar.

First retrieve user's credentials from the privatekey , then do transaction.

Credentials getUserInfo (String privateKeyInHex){

    BigInteger privateKeyInBT = new BigInteger(privateKeyInHex, 16);

    ECKeyPair aPair = ECKeyPair.create(privateKeyInBT);
    Credentials aCredential = Credentials.create(aPair);

    return aCredential;
}

send tokens:

process(){
    ... 

    Credentials newUser =  getUserInfo(privateKeyInHex);

    TransactionReceiptProcessor transactionReceiptProcessor = new NoOpProcessor(web3);
    TransactionManager transactionManager = new RawTransactionManager(
                            web3, newUser, ChainId.MAINNET, transactionReceiptProcessor);
                    //if testing, use ChainId.ROPSTEN
    ...
0

Yes it's possible to send transaction. Use web3.eth.sendTransaction({to:'0xaddress', from:'0xaddress', value:web3.toWei(.033,'ether'),gas:30000})

  • Question is about web3j not web3js – Ajit Soman Feb 28 '18 at 8:21
  • are you using Ethereum wallet? – NoMan Ilyas Feb 28 '18 at 8:26
  • I have no wallet file. I have only ethereum private key and address – Ajit Soman Feb 28 '18 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.