Comments (10)
tx .raw.chainId = numberTo0xHex(1337);
is incorrect/unsupported way of changing chainId. The correct way is specifying chainId when creating new Transaction
. But since you are passing hex
string, it's not an option I guess.
from micro-eth-signer.
Thank you very much for quick response. I tried the following code but the chainId is stil 0x01.
async function testHex() {
let pk = "8c6b19592316688fd537f726db8f2c2237af5cd1a0eb634efdb4bc3c3677f693";
const ethTx = new Transaction({
chainId: 1337,
to: "0x8bac311a9fb1fc90c4ab8cee1c8437087169849a",
gasLimit: 21000,
gasPrice: 21000,
value: BigInt(6000000000000000000),
nonce: 10
});
let signedTx = await ethTx.sign(pk, false);
let hex = signedTx.hex;
console.log(hex);
// Restore the transaction from the hex value
let restoredTx = new Transaction(hex);
console.log(restoredTx.raw.chainId);
}
Did I set chainId correctly ?
from micro-eth-signer.
You are using gasPrice, I think that makes library think you are using legacy type transaction.
If you want to use gasPrice instead of new fields, maybe pass chain name through second argument (mainnet by default).
from micro-eth-signer.
Great, it works. Thank you very much for your hep.
from micro-eth-signer.
I recommend using new tx type with maxFeePerGas, and maxPriorityFeePerGas, but that may not be possible with your network?
So if you use maxFeePerGas, you can pass chainId. If you use gasPrice, you should pass network name as a second argument. We map network name to chainId through some process, so maybe take a look at the code - maybe you will need to modify micro eth code to add 1337
from micro-eth-signer.
Honestly I'm new to Ethereum & cryptography. I'm using your library to build an a blockchain education app. I start using new tx type with maxFeePerGas, and maxPriorityFeePerGas and it works fine. I have one more question. Could micro-eth-signer decode the legacy raw transaction to get the sender?
from micro-eth-signer.
Yes
from micro-eth-signer.
I appreciate your help much. Is this the correct way to get sender from a legacy ETH transaction.
let hex = "0xf86e8083023e3883023e38941b4e1bb8ef8c474f4d0006fb6b69e969f4042f3a890d8d726b7177a8000080820a96a0ece7c1db9395de2dab9b724809d5b1c7947c6630eee76e8c40a88eac5930d0c7a01804147852ec93bab9acb7de52c35e6e6a72052d7bc1319f7b8a37f078aa4c79";
let tx = new Transaction(hex);
console.log(tx.sender);
It's a transaction sent from Brave wallet. The correct sender/from field is 0xe3aced781d71a65226c4fbd6140a2b0253ce4e32
. When I tried to decode the sender field with your library, it threw an error Cannot recover signature: invalid recovery bit
from micro-eth-signer.
You've forgot to pass chainId. It is used in recovering sender lubkey.
from micro-eth-signer.
I got it. Thank you so much
from micro-eth-signer.
Related Issues (13)
- speed of signing HOT 1
- Signing messages HOT 1
- Add engines.node field to package.json
- Error: recovery id invalid HOT 2
- Update `@noble/curves` and `@noble/hashes` deps
- Add support for EIP1559
- Library broken with micro-packed v0.5.2 compared to v0.5.1 HOT 1
- Feature: Support Mixed-case Checksum address encoding HOT 8
- Add support for EIP1559, EIP2930 HOT 1
- Invalid type Error HOT 5
- Speed of sign HOT 5
- Using with node + tsc HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micro-eth-signer.