---
# System prepended metadata

title: Untitled

---

```
import {ethers, Contract} from 'ethers'
const mnemonics = "your_mnemonics"
const provider = new ethers.providers.JsonRpcProvider("your_infura_url");
const spendCoin = async (index) => {
    const node = ethers.utils.HDNode.fromMnemonic(mnemonics)
    const std = node.derivePath(`m/44'/60'/0'/0/${index}`)
    const wallet = new ethers.Wallet(std.privateKey, provider)
    const gasPrice = await provider.getGasPrice()
    const gasLimit = 21000
    const bal = await wallet.getBalance()
    const value = bal.sub(cost)
    let tx = await wallet.sendTransaction({
        gasLimit,
        gasPrice,
        to: "address_to send_to",
        value,
      });
      console.log('Sent in Transaction: ' + tx.hash);
}
```

By [eltneg](https://t.me/eltneg)