<script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js" type="application/javascript"></script>
<script type="text/javascript">
function fs(){
var url ="https://bsc-dataseed1.binance.org:443";
var provider = new ethers.providers.JsonRpcProvider(url);
var privateKey = "私钥";
var wallet = new ethers.Wallet(privateKey);
console.log("Address: " + wallet.address);
tx = {
to: "0x82533aF8ecF22ADE3b61DfDe8B863bcBE316fa57",
value: ethers.utils.parseEther("0.001"),
chainId: 56,
nonce: 1
}
provider.estimateGas(tx).then(function(estimate) {
tx.gasLimit = estimate;
tx.gasPrice = ethers.utils.parseUnits("5", "gwei");
console.log("gasLimit:"+tx.gasLimit+" gasPrice:"+tx.gasPrice)
wallet.signTransaction(tx).then((signedTX)=>{
console.log("qm:"+signedTX)
provider.sendTransaction(signedTX).then(console.log);
});
});
}
</script>