'I met "Sorry, We are unable to locate this TxnHash"
I want to transfer ETH on Rinkeby testnet.
async function transfer(fromAccount: any, amount: any): Promise<string> {
return new Promise(async (resolve, reject) => {
console.log("start transfer", fromAccount.address, "->", amount);
const transferAmount = amount * 0.9;
const { address, privateKey } = fromAccount;
const nonce = "0x" + ((await web3.eth.getTransactionCount(address)) + 1).toString(16);
const gasPrices = await getCurrentGasPrices();
const details = {
to: CONFIG.toAddress,
value: web3.utils.toHex(web3.utils.toWei(transferAmount.toString(), "ether")),
gas: 21000,
gasPrice: gasPrices.low * 1000000000,
nonce: nonce,
chainId: 4
};
const transaction = new Transaction(details, { chain: "rinkeby" });
let privKey = privateKey.startsWith("0x") ? privateKey.split("0x") : ["", privateKey];
privKey = Buffer.from(privKey[1], "hex");
transaction.sign(privKey);
const serializedTransaction = transaction.serialize();
web3.eth.sendSignedTransaction(
"0x" + serializedTransaction.toString("hex"),
(err: any, id: any) => {
if (err) {
console.error(err);
return reject(err);
}
const url = `https://rinkeby.etherscan.io/tx/${id}`;
resolve(url);
}
);
});
}
async function getCurrentGasPrices() {
let response = await axios.get("https://ethgasstation.info/json/ethgasAPI.json");
let prices = {
low: response.data.safeLow / 10,
medium: response.data.average / 10,
high: response.data.fast / 10
};
return prices;
}
When I have run transfer function, I didn't met the error and got transaction id(0x3fd301a01c3f75412cf214de8092e0d92477011fb425e01c77f419adc51d4f22).
But on etherscan, I met Sorry, We are unable to locate this TxnHash.
I am not sure why this happens and any answer would be helpful for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
