Skip to content

Commit

Permalink
Fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed May 18, 2024
1 parent 9eee459 commit 8525027
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ If you don't like NPM, a standalone [eth-signer.js](https://github.com/paulmillr

```ts
import { addr, Transaction } from 'micro-eth-signer';
import { amounts } from 'micro-eth-signer/utils';
import { gweiDecimal, ethDecimal } from 'micro-eth-signer/utils';
const privateKey = '0x6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e';
const senderAddr = addr.fromPrivateKey(privateKey);
const unsignedTx = Transaction.prepare({
to: '0xdf90dea0e0bf5ca6d2a7f0cb86874ba6714f463e',
maxFeePerGas: 100n * amounts.GWEI, // 100 gwei in wei
value: 1n * amounts.ETHER, // 1 eth in wei
maxFeePerGas: gweiDecimal.decode('100'), // 100 gwei in wei
value: ethDecimal.decode('1.1'), // 1.1 eth in wei
nonce: 0n,
});
const tx = unsignedTx.signBy(privateKey); // Uint8Array is also accepted
console.log('signed tx', tx, tx.toHex());
console.log('need total wei', tx.calcAmounts().wei.amountWithFee);
console.log('need total eth', tx.calcAmounts().humanized.amountWithFee);
console.log('address is same', tx.sender === senderAddr);
```

Expand Down

0 comments on commit 8525027

Please sign in to comment.