-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support for matic #1546
Comments
You can define custom import { Network } from "@ethersproject/networks";
export const matic: Network = {
name: 'matic',
chainId: 137,
_defaultProvider: (providers) => new providers.JsonRpcProvider('rpc-url')
}
// import those networks where ever you want to use it with getDefaultProvider
const provider = ethers.getDefaultProvider(matic); If you're asking if the rpc URLs can be hardcoded in ethers.js codebase, then actually there are plenty of evm chains who should also be included. And then some RPCs can get outdated, and it gets difficult to maintain them. It'd be helpful to somehow leverage information available at ethereum-lists/chains, but this can cause some security issues, i.e. if the website source is hijacked then an attacker can cause incorrect information to be displayed in dapps, and they take advantage of it. |
Given the recent popularity, I will likely add matic (and a few others) to the networks package, but that will only entail the chain ID and network name, so they won’t be valid for If equivalent services like INFURA, Alchemy and Etherscan exist though, I would add support for |
kk thx! |
Hi @ricmoo, first of all, thanks for developing and maintaining this awesome library :) Also, Infura had added support to matic/polygon recently: https://blog.infura.io/polygon-now-available/ |
Matic has support for infura, alchemy, quiknode, chainstack and a lot more, I would like to add support for matic if you can guide towards what steps are required, also, I can look at one of the past PR adding support for any particular EVM chain, process would be pretty similar I guess. |
I’ve already added the chain data to the networks. I need to do a bit more research before adding it to the providers and offering it as part of a default provider option, but if alchemy and INFURA already support it, a lot of that research is already done. :) It should be quite simple to add and doesn’t require any signature changes. I just have to get a bit more to get done (and testing) on eip-1559 before the call on Friday. I should be able to get it in next week. |
it will also nice to have Matic testnet's (Mumbai) support for |
I don't see Matic as an option for either INFURA or Alchemy. The default provider only works for the networks it does because some of the large backend services in the space have been so gracious as to offer beefed-up API keys for community use. I've added the Mumbai chain information to the networks package though (locally) and the change will go out with the next release. |
The testnet has been added in 5.3.1. Further support won't be able to be added until there is wider community-available resources though, so I'll close this for now. Once we have standard (non-paid tier) access to Matic endpoints, I can add |
I've added support for The |
when ethers added official support, they chose maticmum as the name. see here: ethers-io/ethers.js#1546 (comment)
* add box mainnet logic contract * update environment variables * update dependencies * factor out VRF interfaces * Add Seed Storage contract and test stub * add order oracle * add pizza interfaces * add initial deployment script * add initial pizza contract (WIP) * Update Deployment scripts remove env vars that are not actually used. Add a mint pizza sequence diagram. update docs, etc * Add fulfillment event update fallback function * npm upgrade * dont run the bonding curve tests all the time they take a while * moar tool updates * clean up seed storage deployment add a deployment to mumbai * update gitignore and packages * rename mumbai to maticmum when ethers added official support, they chose maticmum as the name. see here: ethers-io/ethers.js#1546 (comment) * add deployment for polygon random consumer * pizza storage set random consumer * update docs * Remove purchase logic, use box token id remove the logic to purchase a pizza. it now just redirects to the box contract (for api consistency). Also use the box id as the token id for the pizza for now. * missed interface upgrade * clean up the order api consumer deployment add the job as a string and use assembly to load it into bytes32. note this is dangerous. * check the chainlink callback is a contract use openzep's _msgSender() in some places * remove references to kovan update packages * fix test * reanme * update pizza deployment * Fix the IPFS hash resolution The IPFS hashes are too big when coming in from the chainlink oracle to fit in bytes32 so they get converted from base58 into a uint and the multihash bytes are stripped off, then recombined when reading out the hash when calling tokenURI. * PR self review * add a couple tests and scripts * add missing interface members add missing function parameters add a few missing checks. change the data type of the address to a uint * add toggle for sale * add authorized requesstor to order api consumer * update deployed addresses * use call() when calling order api response contract * use token id var
* add box mainnet logic contract * update environment variables * update dependencies * factor out VRF interfaces * Add Seed Storage contract and test stub * add order oracle * add pizza interfaces * add initial deployment script * add initial pizza contract (WIP) * Update Deployment scripts remove env vars that are not actually used. Add a mint pizza sequence diagram. update docs, etc * Add fulfillment event update fallback function * npm upgrade * dont run the bonding curve tests all the time they take a while * moar tool updates * clean up seed storage deployment add a deployment to mumbai * update gitignore and packages * rename mumbai to maticmum when ethers added official support, they chose maticmum as the name. see here: ethers-io/ethers.js#1546 (comment) * add deployment for polygon random consumer * pizza storage set random consumer * update docs * Remove purchase logic, use box token id remove the logic to purchase a pizza. it now just redirects to the box contract (for api consistency). Also use the box id as the token id for the pizza for now. * missed interface upgrade * clean up the order api consumer deployment add the job as a string and use assembly to load it into bytes32. note this is dangerous. * check the chainlink callback is a contract use openzep's _msgSender() in some places * remove references to kovan update packages * fix test * reanme * update pizza deployment * Fix the IPFS hash resolution The IPFS hashes are too big when coming in from the chainlink oracle to fit in bytes32 so they get converted from base58 into a uint and the multihash bytes are stripped off, then recombined when reading out the hash when calling tokenURI. * PR self review * add a couple tests and scripts * add missing interface members add missing function parameters add a few missing checks. change the data type of the address to a uint * add toggle for sale * add partially implemented dapp * Changes to align old and new dapp patterns, some renaming, and tried to align the semantics of the contracts. * further stub out the dapp * stub out pricing and token fetch * add webpack and compile * couple deployments remove unnecessary methods update dapp * update docs Co-authored-by: Julian Bleecker <bleeckerj@gmail.com>
@ricmoo I am trying to put this code in common js, but due to my inexperience I'm not able the central part. This is the code I mention import { Network } from "@ethersproject/networks";
export const matic: Network = {
name: 'matic',
chainId: 137,
_defaultProvider: (providers) => new providers.JsonRpcProvider('rpc-url')
}
// import those networks where ever you want to use it with getDefaultProvider
const provider = ethers.getDefaultProvider(matic); and here is my try, const ethers = require('ethers');
const Network = require('@ethersproject/networks');
// 1st try..
Network dic_net= {
name: 'matic',
chainId: 137,
_defaultProvider: (providers) => new providers.JsonRpcProvider('rpc-url')
};
// 2nd try..
dic_net = new Network('matic', 137, (providers) => new providers.JsonRpcProvider('rpc-url') );
const provider = ethers.getDefaultProvider(dic_net); thank you in advance |
It looks like you are trying to write JavaScript, in your example, not TypeScript. When using JavaScript directly, you don't use types or interfaces, you just specify the values directly, so Network, which is a type in v6, cannot be newed: Something more like this is prolly what you are looking for: const ethers = require('ethers');
const dic_net = {
name: 'matic',
chainId: 137,
_defaultProvider: (providers) => new providers.JsonRpcProvider('rpc-url')
};
const provider = ethers.getDefaultProvider(dic_net); Make sense? |
Hi @ricmoo, I am trying to deploy a smart contract. My RPC provider is Alchemy and I am working on Polygon and Mumbai. You have said above that you have fixed the problem on "support for matic issue". However when I try to deploy a contract on mumbai or polygon, it gives "getDefaultProvider does not support matic/maticmum" error . After that, I tried to change the variable I am passing to getDefaultProvider function. Initially it was; getDefaultProvider(matic, ..); , and I have made it; getDefaultProvider( { Then it worked and deployed the contract. However, now, when I try to call a function on my smart contract like setBaseTokenUri, MintTo, or any functionality I added to my smart contract, it gives "transaction underpriced" error and cancel the operation. When I tried the same contract and functions on rinkeby, everything works perfectly fine. I do not understand why it is giving "getDefaultProvider" error when "matic" is sent as a paramater to getDefaultProvider and the "transaction underpriced" error after I changed the paramater "matic" passed to getDefaultProvider. Appreciate your response, Have a nice day! **Note: I have used latest version 5.6.2 of ethers.js. |
Hi @ricmoo, unfortunately, I have the same issue as @OsmanYagc |
Hi, You can find the solution here; |
Infura's endpoints for Polygon requires credit card to activate. I've been getting failed call errors ("Project ID does not have access to polygon l2") due to this when using Can you just use Polygon's official free endpoints?: Source: |
So how can we force the use of Polygon's official endpoints instead of Infura's whilst still specifying an Infura key for |
Currently in
"ethers": "5.1.4"
getDefaultProvider
usinggetNetwork
under the hood doesnt seem to supportmatic
(chainId: 137).Would be sweet if it did :)
The text was updated successfully, but these errors were encountered: