micro-eth-signer
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "micro-eth-signer", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Create, sign and validate Ethereum transactions & addresses with minimum deps. Supports London & Berlin txs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,5 +5,5 @@ # micro-eth-signer | ||
Library's size is 4.7KB minified. Uses three dependencies (SHA-3, RLP & secp256k1), all libraries combined are 12KB gzipped. | ||
Library's size is <500 lines of code, or 3KiB gzipped (8.7KiB minified). Uses three dependencies (SHA-3, RLP & secp256k1), four libraries combined are 13KiB gzipped (37KiB minified). | ||
Validated with over 3 MB of ethers.js test vectors! | ||
Validated with over 3MiB of ethers.js test vectors! | ||
@@ -44,2 +44,26 @@ ## Usage | ||
console.log(signedTx); | ||
// London style txs, EIP 1559 | ||
const londonTx = new Transaction({ | ||
to: '0xdf90dea0e0bf5ca6d2a7f0cb86874ba6714f463e', | ||
maxFeePerGas: 100n * 10n ** 9n, // 100 gwei in wei | ||
maxPriorityFeePerGas: 1n * 10n ** 9n, // 1 gwei in wei | ||
value: 10n ** 18n, // 1 eth in wei | ||
nonce: 1 | ||
}, undefined, undefined, 'eip1559'); | ||
const berlinTx = new Transaction({ | ||
to: '0xdf90dea0e0bf5ca6d2a7f0cb86874ba6714f463e', | ||
maxFeePerGas: 100n * 10n ** 9n, // 100 gwei in wei | ||
maxPriorityFeePerGas: 1n * 10n ** 9n, // 1 gwei in wei | ||
value: 10n ** 18n, // 1 eth in wei | ||
nonce: 1, | ||
// the field can also be used in eip1559 txs | ||
accessList: [{ | ||
"address": "0x123456789a123456789a123456789a123456789a", | ||
"storageKeys": [ | ||
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" | ||
] | ||
}] | ||
}, undefined, undefined, 'eip2930'); | ||
})(); | ||
@@ -91,8 +115,9 @@ ``` | ||
- `chain`: optional argument (default is `mainnet`; `ropsten`, `rinkeby`, `goerli`, `kovan` etc) | ||
- `hardfork`: optional argument (default is `berlin`). The only place we're checking for `hardfork` | ||
- `hardfork`: optional argument (default is `london`). The only place we're checking for `hardfork` | ||
is the replay protection code. There are very old transactions that don't support replay protection, | ||
you'll probably won't need them | ||
- `new Transaction(rawTx[, chain, hardfork])` - creates transaction from Raw TX data. | ||
- `rawTx` must have fields `to`, `value`, `nonce`, `gasPrice`, `gasLimit` | ||
- It could optionally specify `data` | ||
- `type`: optional argument (default is `legacy`). Can be either `legacy`, `eip2930`, or `eip1559` (Berlin and London style transactions with access lists and maxFeePerGas/maxPriorityFeePerGas) | ||
- `new Transaction(rawTx[, chain, hardfork, type])` - creates transaction from Raw TX data. | ||
- `rawTx` must have fields `to`, `value`, `nonce`, `gasLimit` | ||
- `rawTx` must have `maxFeePerGas` (eip1559 txs) or `gasPrice` (berlin & legacy txs) | ||
- `to` is recipient's address | ||
@@ -102,4 +127,7 @@ - `value` is amount to send in wei | ||
- `gasLimit` is transaction's Gas Limit in wei (minimum is `21000`) | ||
- `gasPrice` is transaction's Gas Price in wei (100 gwei is `100 * 10 ** 9`) | ||
- `maxFeePerGas` is eip1559 transaction's max acceptable gas price in wei (100 gwei is `100 * 10 ** 9`). Not applicable to legacy transactions | ||
- `maxPriorityFeePerGas` is eip1559 transaction's max acceptable tip in wei. Not applicable to legacy transactions | ||
- `gasPrice` is legacy transaction's Gas Price in wei. Not applicable to eip1559 transactions | ||
- `data` is transaction's data if it's calling some smart contracts | ||
- `accessList` is transaction's Access List, a list of addresses that its smart contract call touches. Basically an array of strings: `["0x123...", "0x456..."]`. Not applicable to legacy transactions | ||
- `Transaction#sign(privateKey: string | Uint8Array): Promise<Transaction>` — | ||
@@ -113,3 +141,3 @@ creates new transaction with same data, but signed by following private key | ||
- `amount: bigint` - amount (aka `value`) in wei | ||
- `fee: bigint` - fee in wei (`gasLimit` * `gasPrice`) | ||
- `fee: bigint` - fee in wei (`maxFeePerGas` * `gasLimit` or `gasPrice` * `gasLimit`) | ||
- `upfrontCost: bigint` - amount + fee in wei, combined | ||
@@ -116,0 +144,0 @@ - `to: string` - address that receives the tx |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28565
150