-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tx/Common: Polygon PoS Chain Support #1289
Comments
I will give this a try later today :) |
Cool news, so Matic has a Mumbai testnet which extends goerli, so with a custom common I was able to send const customChainParams = { name: 'matic-mumbai', chainId: 80001, networkId: 80001 }
const common = Common.forCustomChain('goerli', customChainParams) I used our test dev account: const http = require('http')
import { Transaction } from '../ethereumjs-monorepo/packages/tx/src'
import Common from '../ethereumjs-monorepo/packages/common/dist'
const FROM = '0xaaec86394441f915bce3e6ab399977e9906f3b69'
const to = '0xe13ece23b514caa5b53395c01d0d53d1843258ad'
const customChainParams = { name: 'matic-mumbai', chainId: 80001, networkId: 80001 }
const common = Common.forCustomChain('goerli', customChainParams) as any
const txData = {
nonce: 3,
gasPrice: 20000000000,
gasLimit: 210000,
to,
value: 100,
data: '0x',
}
const start = async () => {
for (let i = 0; i < 1; i++) {
const tx = Transaction.fromTxData({ ...txData, nonce: txData.nonce + i }, { common })
const signedTx = tx.sign(Buffer.from(PRIV_KEY, 'hex'))
const rawTx = '0x' + signedTx.serialize().toString('hex')
const data = JSON.stringify(
{ "jsonrpc": "2.0", "method": "eth_sendRawTransaction", "params": [rawTx], "id": 1 }
)
console.log('Sending tx with nonce ' + tx.nonce.toString())
sendReq(data)
await timeout(2000)
}
}
start()
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function sendReq(data) {
const options = {
hostname: 'rpc-mumbai.matic.today',
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req = http.request(options, res => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', d => {
process.stdout.write(d + '\n')
})
})
req.on('error', error => {
console.error(error)
})
req.write(data)
req.end()
} |
Pretty cool. 😀 🎉 |
@ryanio I am not quite sure yet what to do with these first results (also with the Arbitrum example). We could: a) Simply add a section to the docs adding the networks we have confirmed Any idea? Do you already have got some picture about the HF situation on these L2 solutions? Would the hardfork files as we have them for the L1 chains also be useful for the L2 chains? Also not sure if we can then do anything with this information. It's likely not realistic to target client sync on any of these chains (or is it?). Maybe tx execution in the VM is the closest use case for some? Not sure. |
My current favorite: we add a dedicated new class of static factory method for all networks where there is still some kind of limited support, naming suggestion would be We can then internally call It is also still possible to eventually switch over at some point to add the whole chain as a chain file to give full Common support without these limitations. |
For reference: Ethers just also added Matic support with this commit. |
Hello.
I then use |
Two things I am seeing from this code and your description, which might be problematic (a bit hard to analyze, a somewhat more complete code example would have been helpful, but maybe that's already it):
Hope this helps. 😄 |
Added in #1317 |
Part of #1288
Polygon is a protocol and framework for building Ethereum compatible networks which gained a lot of traction lately. Note that the dedicated chains are named differently from the protocol, there is e.g. the Polygon PoS Chain (this is the main one I guess?).
We should test if we can get a connection going with the tx library respectively the underlying common library and ultimately send a transaction and doing an according PR on the libraries. If setting up a connection is not possible with our current library structure we should alternatively mention in the tx README.
The text was updated successfully, but these errors were encountered: