Skip to content

How to send transaction with Ethers? #2342

Answered by zemse
chronicIntrovert asked this question in Q&A
Discussion options

You must be logged in to vote

What is your web3 object? Is it an ethers provider? Can you mention where didi you get this example in the docs.

const provider = new ethers.provider.InfuraProvider('ropsten');
const wallet = new ethers.Wallet('privatekey', provider);
const unsignedTransaction = {
  from: address,
  to: recipient,
  data: txnData,
};
const tx = wallet.sendTransaction(unsignedTransaction);
console.log(tx.hash)

Does the above example help?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chronicIntrovert
Comment options

Answer selected by chronicIntrovert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants