Ethers.js: Send anunsigned transaction from an unlocked account

Created on 2 Mar 2019  路  2Comments  路  Source: ethers-io/ethers.js

What is the equivalent in ethers.js to

web3.eth.sendTransaction({from: "0x...", to: "0x...", value: ...})

to send a transaction from an unlocked account in geth.

I only can find signed transactions described in the docs.

discussion

Most helpful comment

// However you connect to your JSON-RPC node
let provider = new ethers.providers.JsonRpcProvider();

// You can pass in either the from address or the index
let signer = provider.getSigner(addressOrIndex);

// Send 1 ether to me... :)
signer.sendTransaction({
    to: "ricmoo.firefly.eth",
    value: ethers.utils.parseEther("1.0")
});

See: Signer API

All 2 comments

// However you connect to your JSON-RPC node
let provider = new ethers.providers.JsonRpcProvider();

// You can pass in either the from address or the index
let signer = provider.getSigner(addressOrIndex);

// Send 1 ether to me... :)
signer.sendTransaction({
    to: "ricmoo.firefly.eth",
    value: ethers.utils.parseEther("1.0")
});

See: Signer API

Got it!

Was this page helpful?
0 / 5 - 0 ratings