As the below picture display.
If I know the raw transaction data
, then how can I sign this transaction with the ethers.js
?
Thanks.
Supplement
The raw transaction data
is display on the metamask.
I use a dapp.
And in the app, every time widthdraw, it will return the raw data, and need I to confirm with the metamask, So I want to confirm the transaction with ethers.js
.
Try
I had tried as these codes:
const ALCHEMY_GOERLI_URL = 'https://mainnet.infura.io/v3/xxxxxx';
const provider = new ethers.providers.JsonRpcProvider(ALCHEMY_GOERLI_URL);
let wallet = new ethers.Wallet(params[1]);
let walletiWithProvider = wallet.connect(provider)
const nonce = await walletiWithProvider.getTransactionCount(params[0])
let transaction = {
to: params[0],
gasLimit: '300000',
maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'),
maxFeePerGas: ethers.utils.parseUnits('20', 'gwei'),
nonce: nonce,
chainId: 1,
data: targets.payload,
value: ethers.utils.parseEther(String(formInline.amount))
};
let tx = await walletiWithProvider.sendTransaction(transaction)
await tx.wait()
console.log(tx)
console.log(tx.hash)
console.log(tx.nonce)
But this return a error:
processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":44,\"error\":{\"code\":-32602,\"message\":\"invalid argument 1: hex number \\u003e 64 bits\"}}", error={"code":-32602}, requestBody="{\"method\":\"eth_getTransactionCount\",\"params\":...)
I think this maybe the data
is error.
Thanks.
Again Supplement
I want to withdraw the ERC20 token
(not eth), and as the below codes, I just send eth to myself account.
Thanks for your help.